mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[dart2js] Remove more dead code.
Change-Id: Iff5b3921f40981c8122d7720ce80a5f01731aa47 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151883 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com>
This commit is contained in:
parent
197308560a
commit
7425b3de51
|
@ -412,14 +412,10 @@ abstract class CommonElements {
|
|||
|
||||
FunctionEntity get exceptionUnwrapper;
|
||||
|
||||
FunctionEntity get throwRuntimeError;
|
||||
|
||||
FunctionEntity get throwUnsupportedError;
|
||||
|
||||
FunctionEntity get throwTypeError;
|
||||
|
||||
FunctionEntity get throwAbstractClassInstantiationError;
|
||||
|
||||
/// Recognizes the `checkConcurrentModificationError` helper without needing
|
||||
/// it to be resolved.
|
||||
bool isCheckConcurrentModificationError(MemberEntity member);
|
||||
|
@ -1697,10 +1693,6 @@ class CommonElementsImpl
|
|||
FunctionEntity get exceptionUnwrapper =>
|
||||
_findHelperFunction('unwrapException');
|
||||
|
||||
@override
|
||||
FunctionEntity get throwRuntimeError =>
|
||||
_findHelperFunction('throwRuntimeError');
|
||||
|
||||
@override
|
||||
FunctionEntity get throwUnsupportedError =>
|
||||
_findHelperFunction('throwUnsupportedError');
|
||||
|
@ -1708,10 +1700,6 @@ class CommonElementsImpl
|
|||
@override
|
||||
FunctionEntity get throwTypeError => _findRtiFunction('throwTypeError');
|
||||
|
||||
@override
|
||||
FunctionEntity get throwAbstractClassInstantiationError =>
|
||||
_findHelperFunction('throwAbstractClassInstantiationError');
|
||||
|
||||
@override
|
||||
bool isCheckConcurrentModificationError(MemberEntity member) {
|
||||
return member.name == 'checkConcurrentModificationError' &&
|
||||
|
|
|
@ -165,14 +165,6 @@ class BackendImpacts {
|
|||
]);
|
||||
}
|
||||
|
||||
BackendImpact _abstractClassInstantiation;
|
||||
|
||||
BackendImpact get abstractClassInstantiation {
|
||||
return _abstractClassInstantiation ??= new BackendImpact(
|
||||
staticUses: [_commonElements.throwAbstractClassInstantiationError],
|
||||
otherImpacts: [_needsString('Needed to encode the message.')]);
|
||||
}
|
||||
|
||||
BackendImpact _fallThroughError;
|
||||
|
||||
BackendImpact get fallThroughError {
|
||||
|
@ -183,9 +175,7 @@ class BackendImpacts {
|
|||
BackendImpact _asCheck;
|
||||
|
||||
BackendImpact get asCheck {
|
||||
return _asCheck ??= new BackendImpact(staticUses: [
|
||||
_commonElements.throwRuntimeError,
|
||||
], otherImpacts: [
|
||||
return _asCheck ??= new BackendImpact(staticUses: [], otherImpacts: [
|
||||
newRtiImpact,
|
||||
]);
|
||||
}
|
||||
|
@ -256,9 +246,7 @@ class BackendImpacts {
|
|||
BackendImpact _throwRuntimeError;
|
||||
|
||||
BackendImpact get throwRuntimeError {
|
||||
return _throwRuntimeError ??= new BackendImpact(staticUses: [
|
||||
_commonElements.throwRuntimeError,
|
||||
], otherImpacts: [
|
||||
return _throwRuntimeError ??= new BackendImpact(otherImpacts: [
|
||||
// Also register the types of the arguments passed to this method.
|
||||
stringValues
|
||||
]);
|
||||
|
|
|
@ -72,9 +72,6 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
|
|||
|
||||
for (Feature feature in worldImpact.features) {
|
||||
switch (feature) {
|
||||
case Feature.ABSTRACT_CLASS_INSTANTIATION:
|
||||
registerImpact(_impacts.abstractClassInstantiation);
|
||||
break;
|
||||
case Feature.ASSERT:
|
||||
registerImpact(_impacts.assertWithoutMessage);
|
||||
break;
|
||||
|
|
|
@ -4495,10 +4495,6 @@ class KernelSsaGraphBuilder extends ir.Visitor {
|
|||
return js.js
|
||||
.expressionTemplateYielding(_emitter.typeAccess(closureClass));
|
||||
|
||||
case JsBuiltin.isCheckPropertyToJsConstructorName:
|
||||
int isPrefixLength = _namer.fixedNames.operatorIsPrefix.length;
|
||||
return js.js.expressionTemplateFor('#.substring($isPrefixLength)');
|
||||
|
||||
case JsBuiltin.getMetadata:
|
||||
String metadataAccess =
|
||||
_emitter.generateEmbeddedGlobalAccessString(METADATA);
|
||||
|
|
|
@ -16,9 +16,6 @@ import '../util/util.dart';
|
|||
/// A language feature that may be seen in the program.
|
||||
// TODO(johnniwinther): Should mirror usage be part of this?
|
||||
enum Feature {
|
||||
/// Invocation of a generative construction on an abstract class.
|
||||
ABSTRACT_CLASS_INSTANTIATION,
|
||||
|
||||
/// An assert statement with no message.
|
||||
ASSERT,
|
||||
|
||||
|
|
|
@ -1329,8 +1329,7 @@ testIsTypedefDeep() => null is List<GenericTypedef<int, GenericTypedef>>;
|
|||
_isString(1),
|
||||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
throwRuntimeError(1)],
|
||||
instanceType(1)],
|
||||
type=[
|
||||
as:Class,
|
||||
inst:Closure,
|
||||
|
@ -1372,8 +1371,7 @@ testIsTypedefDeep() => null is List<GenericTypedef<int, GenericTypedef>>;
|
|||
_isString(1),
|
||||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
throwRuntimeError(1)],
|
||||
instanceType(1)],
|
||||
type=[
|
||||
as:Class*,
|
||||
inst:Closure,
|
||||
|
@ -1416,8 +1414,7 @@ testAs(dynamic o) => o as Class;
|
|||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
setRuntimeTypeInfo(2),
|
||||
throwRuntimeError(1)],
|
||||
setRuntimeTypeInfo(2)],
|
||||
type=[
|
||||
as:GenericClass<int,String>,
|
||||
inst:Closure,
|
||||
|
@ -1465,8 +1462,7 @@ testAs(dynamic o) => o as Class;
|
|||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
setRuntimeTypeInfo(2),
|
||||
throwRuntimeError(1)],
|
||||
setRuntimeTypeInfo(2)],
|
||||
type=[
|
||||
as:GenericClass<int*,String*>*,
|
||||
inst:Closure,
|
||||
|
@ -1513,8 +1509,7 @@ testAsGeneric(dynamic o) => o as GenericClass<int, String>;
|
|||
_isString(1),
|
||||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
throwRuntimeError(1)],
|
||||
instanceType(1)],
|
||||
type=[
|
||||
as:GenericClass<dynamic,dynamic>,
|
||||
inst:Closure,
|
||||
|
@ -1556,8 +1551,7 @@ testAsGeneric(dynamic o) => o as GenericClass<int, String>;
|
|||
_isString(1),
|
||||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
throwRuntimeError(1)],
|
||||
instanceType(1)],
|
||||
type=[
|
||||
as:GenericClass<dynamic,dynamic>*,
|
||||
inst:Closure,
|
||||
|
@ -1599,8 +1593,7 @@ testAsGenericRaw(dynamic o) => o as GenericClass;
|
|||
_isString(1),
|
||||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
throwRuntimeError(1)],
|
||||
instanceType(1)],
|
||||
type=[
|
||||
as:GenericClass<dynamic,dynamic>,
|
||||
inst:Closure,
|
||||
|
@ -1642,8 +1635,7 @@ testAsGenericRaw(dynamic o) => o as GenericClass;
|
|||
_isString(1),
|
||||
_isTop(1),
|
||||
findType(1),
|
||||
instanceType(1),
|
||||
throwRuntimeError(1)],
|
||||
instanceType(1)],
|
||||
type=[
|
||||
as:GenericClass<dynamic,dynamic>*,
|
||||
inst:Closure,
|
||||
|
|
|
@ -82,14 +82,6 @@ part 'linked_hash_map.dart';
|
|||
/// them.
|
||||
abstract class InternalMap {}
|
||||
|
||||
/// Extracts the JavaScript-constructor name from the given isCheckProperty.
|
||||
// TODO(floitsch): move this to foreign_helper.dart or similar.
|
||||
@pragma('dart2js:tryInline')
|
||||
String isCheckPropertyToJsConstructorName(String isCheckProperty) {
|
||||
return JS_BUILTIN('returns:String;depends:none;effects:none',
|
||||
JsBuiltin.isCheckPropertyToJsConstructorName, isCheckProperty);
|
||||
}
|
||||
|
||||
/// Given a raw constructor name, return the unminified name, if available,
|
||||
/// otherwise tag the name with `minified:`.
|
||||
String unminifyOrTag(String rawClassName) {
|
||||
|
@ -389,72 +381,6 @@ class Primitives {
|
|||
return _objectTypeNameNewRti(object);
|
||||
}
|
||||
|
||||
static String _objectClassName(Object object) {
|
||||
var interceptor = getInterceptor(object);
|
||||
// The interceptor is either an object (self-intercepting plain Dart class),
|
||||
// the prototype of the constructor for an Interceptor class (like
|
||||
// `JSString.prototype`, `JSNull.prototype`), or an Interceptor object
|
||||
// instance (`const JSString()`, should use `JSString.prototype`).
|
||||
//
|
||||
// These all should have a `constructor` property with a `name` property.
|
||||
String? name;
|
||||
var interceptorConstructor = JS('', '#.constructor', interceptor);
|
||||
if (JS('bool', 'typeof # == "function"', interceptorConstructor)) {
|
||||
var interceptorConstructorName = JS('', '#.name', interceptorConstructor);
|
||||
if (interceptorConstructorName is String) {
|
||||
name = interceptorConstructorName;
|
||||
}
|
||||
}
|
||||
|
||||
if (name == null ||
|
||||
identical(interceptor, JS_INTERCEPTOR_CONSTANT(Interceptor)) ||
|
||||
object is UnknownJavaScriptObject) {
|
||||
// Try to do better. If we do not find something better, leave the name
|
||||
// as 'UnknownJavaScriptObject' or 'Interceptor' (or the minified name).
|
||||
//
|
||||
// When we get here via the UnknownJavaScriptObject test (for JavaScript
|
||||
// objects from outside the program), the object's constructor has a
|
||||
// better name that 'UnknownJavaScriptObject'.
|
||||
//
|
||||
// When we get here the Interceptor test (for Native classes that are
|
||||
// declared in the Dart program but have been 'folded' into Interceptor),
|
||||
// the native class's constructor name is better than the generic
|
||||
// 'Interceptor' (an abstract class).
|
||||
|
||||
// Try the [constructorNameFallback]. This gets the constructor name for
|
||||
// any browser (used by [getNativeInterceptor]).
|
||||
String dispatchName = constructorNameFallback(object);
|
||||
name ??= dispatchName;
|
||||
if (dispatchName == 'Object') {
|
||||
// Try to decompile the constructor by turning it into a string and get
|
||||
// the name out of that. If the decompiled name is a string containing
|
||||
// an identifier, we use that instead of the very generic 'Object'.
|
||||
var objectConstructor = JS('', '#.constructor', object);
|
||||
if (JS('bool', 'typeof # == "function"', objectConstructor)) {
|
||||
var match = JS('var', r'#.match(/^\s*function\s*([\w$]*)\s*\(/)',
|
||||
JS('var', r'String(#)', objectConstructor));
|
||||
var decompiledName = match == null ? null : JS('var', r'#[1]', match);
|
||||
if (decompiledName is String &&
|
||||
JS('bool', r'/^\w+$/.test(#)', decompiledName)) {
|
||||
name = decompiledName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return JS('String', '#', name);
|
||||
}
|
||||
|
||||
// Type inference does not understand that [name] is now always a non-null
|
||||
// String. (There is some imprecision in the negation of the disjunction.)
|
||||
name = JS<String>('String', '#', name);
|
||||
|
||||
// TODO(kasperl): If the namer gave us a fresh global name, we may
|
||||
// want to remove the numeric suffix that makes it unique too.
|
||||
if (name.length > 1 && identical(name.codeUnitAt(0), DOLLAR_CHAR_VALUE)) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
return unminifyOrTag(name);
|
||||
}
|
||||
|
||||
/// Returns the type of [object] as a string (including type arguments).
|
||||
/// Tries to return a sensible name for non-Dart objects.
|
||||
///
|
||||
|
@ -1234,18 +1160,10 @@ throwExpression(ex) {
|
|||
JS('void', 'throw #', wrapException(ex));
|
||||
}
|
||||
|
||||
throwRuntimeError(message) {
|
||||
throw new RuntimeError(message);
|
||||
}
|
||||
|
||||
throwUnsupportedError(message) {
|
||||
throw new UnsupportedError(message);
|
||||
}
|
||||
|
||||
throwAbstractClassInstantiationError(className) {
|
||||
throw new AbstractClassInstantiationError(className);
|
||||
}
|
||||
|
||||
// This is used in open coded for-in loops on arrays.
|
||||
//
|
||||
// checkConcurrentModificationError(a.length == startLength, a)
|
||||
|
@ -2111,45 +2029,6 @@ abstract class Closure implements Function {
|
|||
return constructor;
|
||||
}
|
||||
|
||||
static _computeSignatureFunctionLegacy(
|
||||
Object functionType, bool isStatic, bool isIntercepted) {
|
||||
if (JS('bool', 'typeof # == "number"', functionType)) {
|
||||
// We cannot call [getType] here, since the types-metadata might not be
|
||||
// set yet. This is, because fromTearOff might be called for constants
|
||||
// when the program isn't completely set up yet.
|
||||
//
|
||||
// Note that we cannot just textually inline the call
|
||||
// `getType(functionType)` since we cannot guarantee that the (then)
|
||||
// captured variable `functionType` isn't reused.
|
||||
return JS(
|
||||
'',
|
||||
'''(function(getType, t) {
|
||||
return function(){ return getType(t); };
|
||||
})(#, #)''',
|
||||
RAW_DART_FUNCTION_REF(getType),
|
||||
functionType);
|
||||
}
|
||||
if (JS('bool', 'typeof # == "function"', functionType)) {
|
||||
if (isStatic) {
|
||||
return functionType;
|
||||
} else {
|
||||
var getReceiver = isIntercepted
|
||||
? RAW_DART_FUNCTION_REF(BoundClosure.receiverOf)
|
||||
: RAW_DART_FUNCTION_REF(BoundClosure.selfOf);
|
||||
return JS(
|
||||
'',
|
||||
'function(f,r){'
|
||||
'return function(){'
|
||||
'return f.apply({\$receiver:r(this)},arguments)'
|
||||
'}'
|
||||
'}(#,#)',
|
||||
functionType,
|
||||
getReceiver);
|
||||
}
|
||||
}
|
||||
throw 'Error in functionType of tearoff';
|
||||
}
|
||||
|
||||
static _computeSignatureFunctionNewRti(
|
||||
Object functionType, bool isStatic, bool isIntercepted) {
|
||||
if (JS('bool', 'typeof # == "number"', functionType)) {
|
||||
|
|
|
@ -252,17 +252,6 @@ enum JsBuiltin {
|
|||
/// ...
|
||||
dartClosureConstructor,
|
||||
|
||||
/// Returns the JavaScript-constructor name given an [isCheckProperty].
|
||||
///
|
||||
/// This relies on a deterministic encoding of is-check properties (for
|
||||
/// example `$isFoo` for a class `Foo`). In minified code the returned
|
||||
/// classname is the minified name of the class.
|
||||
///
|
||||
/// JS_BUILTIN('returns:String;depends:none;effects:none',
|
||||
/// JsBuiltin.isCheckPropertyToJsConstructorName,
|
||||
/// isCheckProperty);
|
||||
isCheckPropertyToJsConstructorName,
|
||||
|
||||
/// Returns true if the given type is a type argument of a js-interop class
|
||||
/// or a supertype of a js-interop class.
|
||||
///
|
||||
|
|
|
@ -275,8 +275,6 @@ const Map<String, String> DEFAULT_JS_HELPER_LIBRARY = const <String, String>{
|
|||
'stringTypeCheck': 'stringTypeCheck(x) {}',
|
||||
'subtypeCast': 'subtypeCast(object, isField, checks, asField) {}',
|
||||
'subtypeOfRuntimeTypeCast': 'subtypeOfRuntimeTypeCast(object, type) {}',
|
||||
'throwAbstractClassInstantiationError':
|
||||
'throwAbstractClassInstantiationError(className) {}',
|
||||
'checkConcurrentModificationError':
|
||||
'checkConcurrentModificationError(collection) {}',
|
||||
'throwConcurrentModificationError':
|
||||
|
@ -285,7 +283,6 @@ const Map<String, String> DEFAULT_JS_HELPER_LIBRARY = const <String, String>{
|
|||
'throwExpression': 'throwExpression(e) {}',
|
||||
'throwNoSuchMethod':
|
||||
'throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {}',
|
||||
'throwRuntimeError': 'throwRuntimeError(message) {}',
|
||||
'throwUnsupportedError': 'throwUnsupportedError(message) {}',
|
||||
'throwTypeError': 'throwTypeError(message) {}',
|
||||
'unwrapException': 'unwrapException(e) {}',
|
||||
|
|
|
@ -234,8 +234,6 @@ const Map<String, String> DEFAULT_JS_HELPER_LIBRARY = const <String, String>{
|
|||
'S': 'S() {}',
|
||||
'setRuntimeTypeInfo': 'setRuntimeTypeInfo(a, b) {}',
|
||||
'subtypeOfRuntimeTypeCast': 'subtypeOfRuntimeTypeCast(object, type) {}',
|
||||
'throwAbstractClassInstantiationError':
|
||||
'throwAbstractClassInstantiationError(className) {}',
|
||||
'checkConcurrentModificationError':
|
||||
'checkConcurrentModificationError(collection) {}',
|
||||
'throwConcurrentModificationError':
|
||||
|
@ -244,7 +242,6 @@ const Map<String, String> DEFAULT_JS_HELPER_LIBRARY = const <String, String>{
|
|||
'throwExpression': 'throwExpression(e) {}',
|
||||
'throwNoSuchMethod':
|
||||
'throwNoSuchMethod(obj, name, arguments, expectedArgumentNames) {}',
|
||||
'throwRuntimeError': 'throwRuntimeError(message) {}',
|
||||
'throwUnsupportedError': 'throwUnsupportedError(message) {}',
|
||||
'unwrapException': 'unwrapException(e) {}',
|
||||
'voidTypeCheck': 'voidTypeCheck(value) {}',
|
||||
|
|
Loading…
Reference in a new issue