Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js/rewrite_async.dart ('k') | pkg/compiler/lib/src/js_backend/backend_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index f8afee062c78c0fb3d16f7e13fcb31a4779647de..7f751dbab719bafcc8576c6b6b6b38ec11dae63b 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -107,7 +107,8 @@ class FunctionInlineCache {
if (insideLoop) {
switch (oldDecision) {
case _mustNotInline:
- throw new SpannableAssertionFailure(element,
+ throw new SpannableAssertionFailure(
+ element,
"Can't mark a function as non-inlinable and inlinable at the "
"same time.");
@@ -133,7 +134,8 @@ class FunctionInlineCache {
case _mustNotInline:
case _mayInlineInLoopMustNotOutside:
case _canInlineInLoopMustNotOutside:
- throw new SpannableAssertionFailure(element,
+ throw new SpannableAssertionFailure(
+ element,
"Can't mark a function as non-inlinable and inlinable at the "
"same time.");
@@ -146,7 +148,6 @@ class FunctionInlineCache {
case _mustInline:
// Do nothing.
break;
-
}
}
}
@@ -164,7 +165,8 @@ class FunctionInlineCache {
case _canInlineInLoopMayInlineOutside:
case _canInline:
case _mustInline:
- throw new SpannableAssertionFailure(element,
+ throw new SpannableAssertionFailure(
+ element,
"Can't mark a function as non-inlinable and inlinable at the "
"same time.");
@@ -181,7 +183,8 @@ class FunctionInlineCache {
switch (oldDecision) {
case _canInline:
case _mustInline:
- throw new SpannableAssertionFailure(element,
+ throw new SpannableAssertionFailure(
+ element,
"Can't mark a function as non-inlinable and inlinable at the "
"same time.");
@@ -215,7 +218,7 @@ class FunctionInlineCache {
enum SyntheticConstantKind {
DUMMY_INTERCEPTOR,
EMPTY_VALUE,
- TYPEVARIABLE_REFERENCE, // Reference to a type in reflection data.
+ TYPEVARIABLE_REFERENCE, // Reference to a type in reflection data.
NAME
}
@@ -226,7 +229,6 @@ class JavaScriptBackend extends Backend {
final Annotations annotations;
-
/// Set of classes that need to be considered for reflection although not
/// otherwise visible during resolution.
Iterable<ClassElement> get classesRequiredForReflection {
@@ -253,7 +255,7 @@ class JavaScriptBackend extends Backend {
/// information will be sent to a server via a POST request.
static const String TRACE_METHOD = const String.fromEnvironment('traceCalls');
static const bool TRACE_CALLS =
- TRACE_METHOD == 'post' || TRACE_METHOD == 'console';
+ TRACE_METHOD == 'post' || TRACE_METHOD == 'console';
Element traceHelper;
TypeMask get stringType => compiler.typesTask.stringType;
@@ -271,8 +273,8 @@ class JavaScriptBackend extends Backend {
TypeMask _indexablePrimitiveTypeCache;
TypeMask get indexablePrimitiveType {
if (_indexablePrimitiveTypeCache == null) {
- _indexablePrimitiveTypeCache = new TypeMask.nonNullSubtype(
- helpers.jsIndexableClass, compiler.world);
+ _indexablePrimitiveTypeCache =
+ new TypeMask.nonNullSubtype(helpers.jsIndexableClass, compiler.world);
}
return _indexablePrimitiveTypeCache;
}
@@ -280,8 +282,8 @@ class JavaScriptBackend extends Backend {
TypeMask _readableArrayTypeCache;
TypeMask get readableArrayType {
if (_readableArrayTypeCache == null) {
- _readableArrayTypeCache = new TypeMask.nonNullSubclass(
- helpers.jsArrayClass, compiler.world);
+ _readableArrayTypeCache =
+ new TypeMask.nonNullSubclass(helpers.jsArrayClass, compiler.world);
}
return _readableArrayTypeCache;
}
@@ -298,8 +300,8 @@ class JavaScriptBackend extends Backend {
TypeMask _fixedArrayTypeCache;
TypeMask get fixedArrayType {
if (_fixedArrayTypeCache == null) {
- _fixedArrayTypeCache = new TypeMask.nonNullExact(
- helpers.jsFixedArrayClass, compiler.world);
+ _fixedArrayTypeCache =
+ new TypeMask.nonNullExact(helpers.jsFixedArrayClass, compiler.world);
}
return _fixedArrayTypeCache;
}
@@ -325,8 +327,7 @@ class JavaScriptBackend extends Backend {
TypeMask _nonNullTypeCache;
TypeMask get nonNullType {
if (_nonNullTypeCache == null) {
- _nonNullTypeCache =
- compiler.typesTask.dynamicType.nonNullable();
+ _nonNullTypeCache = compiler.typesTask.dynamicType.nonNullable();
}
return _nonNullTypeCache;
}
@@ -472,8 +473,7 @@ class JavaScriptBackend extends Backend {
// Checked mode helpers indexed by name.
Map<String, CheckedModeHelper> checkedModeHelperByName =
- new Map<String, CheckedModeHelper>.fromIterable(
- checkedModeHelpers,
+ new Map<String, CheckedModeHelper>.fromIterable(checkedModeHelpers,
key: (helper) => helper.name);
TypeVariableHandler typeVariableHandler;
@@ -512,9 +512,9 @@ class JavaScriptBackend extends Backend {
final BackendImpacts impacts;
JavaScriptBackend(Compiler compiler,
- {bool generateSourceMap: true,
- bool useStartupEmitter: false,
- bool useNewSourceInfo: false})
+ {bool generateSourceMap: true,
+ bool useStartupEmitter: false,
+ bool useNewSourceInfo: false})
: namer = determineNamer(compiler),
oneShotInterceptors = new Map<jsAst.Name, Selector>(),
interceptedElements = new Map<String, Set<Element>>(),
@@ -522,12 +522,11 @@ class JavaScriptBackend extends Backend {
rtiEncoder = new _RuntimeTypesEncoder(compiler),
specializedGetInterceptors = new Map<jsAst.Name, Set<ClassElement>>(),
annotations = new Annotations(compiler),
- this.sourceInformationStrategy =
- generateSourceMap
- ? (useNewSourceInfo
- ? new PositionSourceInformationStrategy()
- : const StartEndSourceInformationStrategy())
- : const JavaScriptSourceInformationStrategy(),
+ this.sourceInformationStrategy = generateSourceMap
+ ? (useNewSourceInfo
+ ? new PositionSourceInformationStrategy()
+ : const StartEndSourceInformationStrategy())
+ : const JavaScriptSourceInformationStrategy(),
helpers = new BackendHelpers(compiler),
impacts = new BackendImpacts(compiler),
super(compiler) {
@@ -543,9 +542,8 @@ class JavaScriptBackend extends Backend {
impactTransformer = new JavaScriptImpactTransformer(this);
patchResolverTask = new PatchResolverTask(compiler);
functionCompiler = compiler.options.useCpsIr
- ? new CpsFunctionCompiler(
- compiler, this, sourceInformationStrategy)
- : new SsaFunctionCompiler(this, sourceInformationStrategy);
+ ? new CpsFunctionCompiler(compiler, this, sourceInformationStrategy)
+ : new SsaFunctionCompiler(this, sourceInformationStrategy);
serialization = new JavaScriptBackendSerialization(this);
}
@@ -569,11 +567,11 @@ class JavaScriptBackend extends Backend {
if (isForeign(element)) {
return element;
}
- if (isJsInterop(element)) {
+ if (isJsInterop(element)) {
if (element.memberName == const PublicName('[]') ||
element.memberName == const PublicName('[]=')) {
- reporter.reportErrorMessage(element,
- MessageKind.JS_INTEROP_INDEX_NOT_SUPPORTED);
+ reporter.reportErrorMessage(
+ element, MessageKind.JS_INTEROP_INDEX_NOT_SUPPORTED);
}
return element;
}
@@ -586,15 +584,15 @@ class JavaScriptBackend extends Backend {
bool isBackendLibrary(LibraryElement library) {
return library == helpers.interceptorsLibrary ||
- library == helpers.jsHelperLibrary;
+ library == helpers.jsHelperLibrary;
}
static Namer determineNamer(Compiler compiler) {
- return compiler.options.enableMinification ?
- compiler.options.useFrequencyNamer ?
- new FrequencyBasedNamer(compiler) :
- new MinifyNamer(compiler) :
- new Namer(compiler);
+ return compiler.options.enableMinification
+ ? compiler.options.useFrequencyNamer
+ ? new FrequencyBasedNamer(compiler)
+ : new MinifyNamer(compiler)
+ : new Namer(compiler);
}
/// The backend must *always* call this method when enqueuing an
@@ -618,8 +616,7 @@ class JavaScriptBackend extends Backend {
}
bool _isValidBackendUse(Element element) {
- assert(invariant(element, element.isDeclaration,
- message: ""));
+ assert(invariant(element, element.isDeclaration, message: ""));
if (element == helpers.streamIteratorConstructor ||
element == helpers.compiler.symbolConstructor ||
element == helpers.compiler.symbolValidatedConstructor ||
@@ -629,20 +626,20 @@ class JavaScriptBackend extends Backend {
// TODO(johnniwinther): These are valid but we could be more precise.
return true;
} else if (element.implementationLibrary.isPatch ||
- // Needed to detect deserialized injected elements, that is
- // element declared in patch files.
- (element.library.isPlatformLibrary &&
- element.sourcePosition.uri.path.contains(
- '_internal/js_runtime/lib/')) ||
- element.library == helpers.jsHelperLibrary ||
- element.library == helpers.interceptorsLibrary ||
- element.library == helpers.isolateHelperLibrary) {
+ // Needed to detect deserialized injected elements, that is
+ // element declared in patch files.
+ (element.library.isPlatformLibrary &&
+ element.sourcePosition.uri.path
+ .contains('_internal/js_runtime/lib/')) ||
+ element.library == helpers.jsHelperLibrary ||
+ element.library == helpers.interceptorsLibrary ||
+ element.library == helpers.isolateHelperLibrary) {
// TODO(johnniwinther): We should be more precise about these.
return true;
} else if (element == coreClasses.listClass ||
- element == helpers.mapLiteralClass ||
- element == coreClasses.functionClass ||
- element == coreClasses.stringClass) {
+ element == helpers.mapLiteralClass ||
+ element == coreClasses.functionClass ||
+ element == coreClasses.stringClass) {
// TODO(johnniwinther): Avoid these.
return true;
}
@@ -650,9 +647,9 @@ class JavaScriptBackend extends Backend {
}
bool usedByBackend(Element element) {
- if (element.isParameter
- || element.isInitializingFormal
- || element.isField) {
+ if (element.isParameter ||
+ element.isInitializingFormal ||
+ element.isField) {
if (usedByBackend(element.enclosingElement)) return true;
}
return helpersUsed.contains(element.declaration);
@@ -665,8 +662,8 @@ class JavaScriptBackend extends Backend {
}
if (element.isField) {
- if (Elements.isStaticOrTopLevel(element)
- && (element.isFinal || element.isConst)) {
+ if (Elements.isStaticOrTopLevel(element) &&
+ (element.isFinal || element.isConst)) {
return false;
}
}
@@ -775,23 +772,21 @@ class JavaScriptBackend extends Backend {
* explicit receiver' optimization.
*/
bool isInterceptedMixinSelector(Selector selector, TypeMask mask) {
- Set<Element> elements = interceptedMixinElements.putIfAbsent(
- selector.name,
- () {
- Set<Element> elements = interceptedElements[selector.name];
- if (elements == null) return null;
- return elements
- .where((element) =>
- classesMixedIntoInterceptedClasses.contains(
- element.enclosingClass))
- .toSet();
- });
+ Set<Element> elements =
+ interceptedMixinElements.putIfAbsent(selector.name, () {
+ Set<Element> elements = interceptedElements[selector.name];
+ if (elements == null) return null;
+ return elements
+ .where((element) => classesMixedIntoInterceptedClasses
+ .contains(element.enclosingClass))
+ .toSet();
+ });
if (elements == null) return false;
if (elements.isEmpty) return false;
return elements.any((element) {
return selector.applies(element, compiler.world) &&
- (mask == null || mask.canHit(element, selector, compiler.world));
+ (mask == null || mask.canHit(element, selector, compiler.world));
});
}
@@ -799,12 +794,12 @@ class JavaScriptBackend extends Backend {
/// and never exists at runtime.
bool isCompileTimeOnlyClass(ClassElement class_) {
return class_ == helpers.jsPositiveIntClass ||
- class_ == helpers.jsUInt32Class ||
- class_ == helpers.jsUInt31Class ||
- class_ == helpers.jsFixedArrayClass ||
- class_ == helpers.jsUnmodifiableArrayClass ||
- class_ == helpers.jsMutableArrayClass ||
- class_ == helpers.jsExtendableArrayClass;
+ class_ == helpers.jsUInt32Class ||
+ class_ == helpers.jsUInt31Class ||
+ class_ == helpers.jsFixedArrayClass ||
+ class_ == helpers.jsUnmodifiableArrayClass ||
+ class_ == helpers.jsMutableArrayClass ||
+ class_ == helpers.jsExtendableArrayClass;
}
/// Maps compile-time classes to their runtime class. The runtime class is
@@ -832,8 +827,8 @@ class JavaScriptBackend extends Backend {
for (Element element in intercepted) {
ClassElement classElement = element.enclosingClass;
if (isCompileTimeOnlyClass(classElement)) continue;
- if (isNativeOrExtendsNative(classElement)
- || interceptedClasses.contains(classElement)) {
+ if (isNativeOrExtendsNative(classElement) ||
+ interceptedClasses.contains(classElement)) {
result.add(classElement);
}
if (classesMixedIntoInterceptedClasses.contains(classElement)) {
@@ -862,8 +857,7 @@ class JavaScriptBackend extends Backend {
}
bool operatorEqHandlesNullArgument(FunctionElement operatorEqfunction) {
- return specialOperatorEqClasses.contains(
- operatorEqfunction.enclosingClass);
+ return specialOperatorEqClasses.contains(operatorEqfunction.enclosingClass);
}
void validateInterceptorImplementsAllObjectMethods(
@@ -875,13 +869,12 @@ class JavaScriptBackend extends Backend {
Element interceptorMember = interceptorClass.lookupMember(member.name);
// Interceptors must override all Object methods due to calling convention
// differences.
- assert(invariant(
- interceptorMember,
+ assert(invariant(interceptorMember,
interceptorMember.enclosingClass == interceptorClass,
message:
- "Member ${member.name} not overridden in ${interceptorClass}. "
- "Found $interceptorMember from "
- "${interceptorMember.enclosingClass}."));
+ "Member ${member.name} not overridden in ${interceptorClass}. "
+ "Found $interceptorMember from "
+ "${interceptorMember.enclosingClass}."));
});
}
@@ -892,8 +885,7 @@ class JavaScriptBackend extends Backend {
cls.forEachMember((ClassElement classElement, Element member) {
if (member.name == Identifiers.call) {
reporter.reportErrorMessage(
- member,
- MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS);
+ member, MessageKind.CALL_NOT_SUPPORTED_ON_NATIVE_CLASS);
return;
}
if (member.isSynthesized) return;
@@ -902,8 +894,7 @@ class JavaScriptBackend extends Backend {
Set<Element> set = interceptedElements.putIfAbsent(
member.name, () => new Set<Element>());
set.add(member);
- },
- includeSuperAndInjectedMembers: true);
+ }, includeSuperAndInjectedMembers: true);
// Walk superclass chain to find mixins.
for (; cls != null; cls = cls.superclass) {
@@ -915,21 +906,18 @@ class JavaScriptBackend extends Backend {
}
}
- void addInterceptors(ClassElement cls,
- Enqueuer enqueuer,
- Registry registry) {
+ void addInterceptors(ClassElement cls, Enqueuer enqueuer, Registry registry) {
if (enqueuer.isResolutionQueue) {
_interceptedClasses.add(helpers.jsInterceptorClass);
_interceptedClasses.add(cls);
cls.ensureResolved(resolution);
cls.forEachMember((ClassElement classElement, Element member) {
- // All methods on [Object] are shadowed by [Interceptor].
- if (classElement == coreClasses.objectClass) return;
- Set<Element> set = interceptedElements.putIfAbsent(
- member.name, () => new Set<Element>());
- set.add(member);
- },
- includeSuperAndInjectedMembers: true);
+ // All methods on [Object] are shadowed by [Interceptor].
+ if (classElement == coreClasses.objectClass) return;
+ Set<Element> set = interceptedElements.putIfAbsent(
+ member.name, () => new Set<Element>());
+ set.add(member);
+ }, includeSuperAndInjectedMembers: true);
}
enqueueClass(enqueuer, cls, registry);
}
@@ -953,8 +941,7 @@ class JavaScriptBackend extends Backend {
void registerCompileTimeConstant(ConstantValue constant, Registry registry) {
registerCompileTimeConstantInternal(constant, registry);
- if (!registry.isForResolution &&
- lookupMapAnalysis.isLookupMap(constant)) {
+ if (!registry.isForResolution && lookupMapAnalysis.isLookupMap(constant)) {
// Note: internally, this registration will temporarily remove the
// constant dependencies and add them later on-demand.
lookupMapAnalysis.registerLookupMapReference(constant);
@@ -969,8 +956,8 @@ class JavaScriptBackend extends Backend {
constants.addCompileTimeConstantForEmission(constant);
}
- void registerCompileTimeConstantInternal(ConstantValue constant,
- Registry registry) {
+ void registerCompileTimeConstantInternal(
+ ConstantValue constant, Registry registry) {
DartType type = constant.getType(compiler.coreTypes);
registerInstantiatedConstantType(type, registry);
@@ -994,51 +981,46 @@ class JavaScriptBackend extends Backend {
if (type is InterfaceType) {
registry.registerInstantiation(instantiatedType);
if (!type.treatAsRaw && classNeedsRti(type.element)) {
- registry.registerStaticUse(
- new StaticUse.staticInvoke(
- // TODO(johnniwinther): Find the right [CallStructure].
- helpers.setRuntimeTypeInfo, null));
+ registry.registerStaticUse(new StaticUse.staticInvoke(
+ // TODO(johnniwinther): Find the right [CallStructure].
+ helpers.setRuntimeTypeInfo,
+ null));
}
if (type.element == typeImplementation) {
// If we use a type literal in a constant, the compile time
// constant emitter will generate a call to the createRuntimeType
// helper so we register a use of that.
- registry.registerStaticUse(
- new StaticUse.staticInvoke(
- // TODO(johnniwinther): Find the right [CallStructure].
+ registry.registerStaticUse(new StaticUse.staticInvoke(
+ // TODO(johnniwinther): Find the right [CallStructure].
- helpers.createRuntimeType, null));
+ helpers.createRuntimeType,
+ null));
}
}
}
void registerMetadataConstant(MetadataAnnotation metadata,
- Element annotatedElement,
- Registry registry) {
+ Element annotatedElement, Registry registry) {
assert(registry.isForResolution);
ConstantValue constant = constants.getConstantValueForMetadata(metadata);
registerCompileTimeConstant(constant, registry);
metadataConstants.add(new Dependency(constant, annotatedElement));
}
- void registerInstantiatedClass(ClassElement cls,
- Enqueuer enqueuer,
- Registry registry) {
+ void registerInstantiatedClass(
+ ClassElement cls, Enqueuer enqueuer, Registry registry) {
_processClass(cls, enqueuer, registry);
}
- void registerImplementedClass(ClassElement cls,
- Enqueuer enqueuer,
- Registry registry) {
+ void registerImplementedClass(
+ ClassElement cls, Enqueuer enqueuer, Registry registry) {
_processClass(cls, enqueuer, registry);
}
- void _processClass(ClassElement cls,
- Enqueuer enqueuer,
- Registry registry) {
+ void _processClass(ClassElement cls, Enqueuer enqueuer, Registry registry) {
if (!cls.typeVariables.isEmpty) {
- typeVariableHandler.registerClassWithTypeVariables(cls, enqueuer,
- registry);
+ typeVariableHandler.registerClassWithTypeVariables(
+ cls, enqueuer, registry);
}
// Register any helper that will be needed by the backend.
@@ -1050,7 +1032,7 @@ class JavaScriptBackend extends Backend {
// `iae` helper directly.
enqueue(enqueuer, helpers.throwIllegalArgumentException, registry);
} else if (cls == coreClasses.listClass ||
- cls == coreClasses.stringClass) {
+ cls == coreClasses.stringClass) {
// The backend will try to optimize array and string access and use the
// `ioore` and `iae` helpers directly.
enqueue(enqueuer, helpers.throwIndexOutOfRangeException, registry);
@@ -1070,8 +1052,8 @@ class JavaScriptBackend extends Backend {
enqueueClass(enqueuer, helpers.boundClosureClass, registry);
} else if (isNativeOrExtendsNative(cls)) {
enqueue(enqueuer, helpers.getNativeInterceptorMethod, registry);
- enqueueClass(enqueuer, helpers.jsInterceptorClass,
- compiler.globalDependencies);
+ enqueueClass(
+ enqueuer, helpers.jsInterceptorClass, compiler.globalDependencies);
enqueueClass(enqueuer, helpers.jsJavaScriptObjectClass, registry);
enqueueClass(enqueuer, helpers.jsPlainJavaScriptObjectClass, registry);
enqueueClass(enqueuer, helpers.jsJavaScriptFunctionClass, registry);
@@ -1085,7 +1067,7 @@ class JavaScriptBackend extends Backend {
ConstructorElement ctor = implementation.lookupConstructor(name);
if (ctor == null ||
(Name.isPrivateName(name) &&
- ctor.library != helpers.mapLiteralClass.library)) {
+ ctor.library != helpers.mapLiteralClass.library)) {
reporter.internalError(
helpers.mapLiteralClass,
"Map literal class ${helpers.mapLiteralClass} missing "
@@ -1100,7 +1082,8 @@ class JavaScriptBackend extends Backend {
ClassElement implementation = cls.implementation;
Element element = implementation.lookupLocalMember(name);
if (element == null || !element.isFunction || !element.isStatic) {
- reporter.internalError(helpers.mapLiteralClass,
+ reporter.internalError(
+ helpers.mapLiteralClass,
"Map literal class ${helpers.mapLiteralClass} missing "
"'$name' static member function");
}
@@ -1120,14 +1103,13 @@ class JavaScriptBackend extends Backend {
if (cls == helpers.closureClass) {
enqueue(enqueuer, helpers.closureFromTearOff, registry);
}
- if (cls == coreClasses.stringClass ||
- cls == helpers.jsStringClass) {
+ if (cls == coreClasses.stringClass || cls == helpers.jsStringClass) {
addInterceptors(helpers.jsStringClass, enqueuer, registry);
} else if (cls == coreClasses.listClass ||
- cls == helpers.jsArrayClass ||
- cls == helpers.jsFixedArrayClass ||
- cls == helpers.jsExtendableArrayClass ||
- cls == helpers.jsUnmodifiableArrayClass) {
+ cls == helpers.jsArrayClass ||
+ cls == helpers.jsFixedArrayClass ||
+ cls == helpers.jsExtendableArrayClass ||
+ cls == helpers.jsUnmodifiableArrayClass) {
addInterceptors(helpers.jsArrayClass, enqueuer, registry);
addInterceptors(helpers.jsMutableArrayClass, enqueuer, registry);
addInterceptors(helpers.jsFixedArrayClass, enqueuer, registry);
@@ -1137,25 +1119,20 @@ class JavaScriptBackend extends Backend {
enqueueInResolution(helpers.jsArrayTypedConstructor, registry);
enqueueInResolution(helpers.setRuntimeTypeInfo, registry);
enqueueInResolution(helpers.getTypeArgumentByIndex, registry);
- } else if (cls == coreClasses.intClass ||
- cls == helpers.jsIntClass) {
+ } else if (cls == coreClasses.intClass || cls == helpers.jsIntClass) {
addInterceptors(helpers.jsIntClass, enqueuer, registry);
addInterceptors(helpers.jsPositiveIntClass, enqueuer, registry);
addInterceptors(helpers.jsUInt32Class, enqueuer, registry);
addInterceptors(helpers.jsUInt31Class, enqueuer, registry);
addInterceptors(helpers.jsNumberClass, enqueuer, registry);
- } else if (cls == coreClasses.doubleClass ||
- cls == helpers.jsDoubleClass) {
+ } else if (cls == coreClasses.doubleClass || cls == helpers.jsDoubleClass) {
addInterceptors(helpers.jsDoubleClass, enqueuer, registry);
addInterceptors(helpers.jsNumberClass, enqueuer, registry);
- } else if (cls == coreClasses.boolClass ||
- cls == helpers.jsBoolClass) {
+ } else if (cls == coreClasses.boolClass || cls == helpers.jsBoolClass) {
addInterceptors(helpers.jsBoolClass, enqueuer, registry);
- } else if (cls == coreClasses.nullClass ||
- cls == helpers.jsNullClass) {
+ } else if (cls == coreClasses.nullClass || cls == helpers.jsNullClass) {
addInterceptors(helpers.jsNullClass, enqueuer, registry);
- } else if (cls == coreClasses.numClass ||
- cls == helpers.jsNumberClass) {
+ } else if (cls == coreClasses.numClass || cls == helpers.jsNumberClass) {
addInterceptors(helpers.jsIntClass, enqueuer, registry);
addInterceptors(helpers.jsPositiveIntClass, enqueuer, registry);
addInterceptors(helpers.jsUInt32Class, enqueuer, registry);
@@ -1167,7 +1144,8 @@ class JavaScriptBackend extends Backend {
} else if (cls == helpers.jsPlainJavaScriptObjectClass) {
addInterceptors(helpers.jsPlainJavaScriptObjectClass, enqueuer, registry);
} else if (cls == helpers.jsUnknownJavaScriptObjectClass) {
- addInterceptors(helpers.jsUnknownJavaScriptObjectClass, enqueuer, registry);
+ addInterceptors(
+ helpers.jsUnknownJavaScriptObjectClass, enqueuer, registry);
} else if (cls == helpers.jsJavaScriptFunctionClass) {
addInterceptors(helpers.jsJavaScriptFunctionClass, enqueuer, registry);
} else if (isNativeOrExtendsNative(cls)) {
@@ -1185,13 +1163,12 @@ class JavaScriptBackend extends Backend {
}
}
- void registerInstantiatedType(InterfaceType type,
- Enqueuer enqueuer,
- Registry registry,
- {bool mirrorUsage: false}) {
+ void registerInstantiatedType(
+ InterfaceType type, Enqueuer enqueuer, Registry registry,
+ {bool mirrorUsage: false}) {
lookupMapAnalysis.registerInstantiatedType(type, registry);
- super.registerInstantiatedType(
- type, enqueuer, registry, mirrorUsage: mirrorUsage);
+ super.registerInstantiatedType(type, enqueuer, registry,
+ mirrorUsage: mirrorUsage);
}
void registerUseInterceptor(Enqueuer enqueuer) {
@@ -1227,7 +1204,8 @@ class JavaScriptBackend extends Backend {
if (TRACE_CALLS) {
traceHelper = TRACE_METHOD == 'console'
- ? helpers.consoleTraceHelper : helpers.postTraceHelper;
+ ? helpers.consoleTraceHelper
+ : helpers.postTraceHelper;
assert(traceHelper != null);
enqueueInResolution(traceHelper, registry);
}
@@ -1248,24 +1226,18 @@ class JavaScriptBackend extends Backend {
void registerGetRuntimeTypeArgument(Registry registry) {
enqueueImpact(
- compiler.enqueuer.resolution,
- impacts.getRuntimeTypeArgument,
- registry);
+ compiler.enqueuer.resolution, impacts.getRuntimeTypeArgument, registry);
}
void registerCallMethodWithFreeTypeVariables(
- Element callMethod,
- Enqueuer enqueuer,
- Registry registry) {
+ Element callMethod, Enqueuer enqueuer, Registry registry) {
if (enqueuer.isResolutionQueue || methodNeedsRti(callMethod)) {
registerComputeSignature(enqueuer, registry);
}
}
void registerClosureWithFreeTypeVariables(
- Element closure,
- Enqueuer enqueuer,
- Registry registry) {
+ Element closure, Enqueuer enqueuer, Registry registry) {
if (enqueuer.isResolutionQueue || methodNeedsRti(closure)) {
registerComputeSignature(enqueuer, registry);
}
@@ -1284,9 +1256,7 @@ class JavaScriptBackend extends Backend {
void registerGetOfStaticFunction(Enqueuer enqueuer) {
helpers.closureClass.ensureResolved(resolution);
registerInstantiatedType(
- helpers.closureClass.rawType,
- enqueuer,
- compiler.globalDependencies);
+ helpers.closureClass.rawType, enqueuer, compiler.globalDependencies);
}
void registerComputeSignature(Enqueuer enqueuer, Registry registry) {
@@ -1304,8 +1274,8 @@ class JavaScriptBackend extends Backend {
enqueueClass(enqueuer, coreClasses.listClass, registry);
}
- void registerTypeVariableBoundsSubtypeCheck(DartType typeArgument,
- DartType bound) {
+ void registerTypeVariableBoundsSubtypeCheck(
+ DartType typeArgument, DartType bound) {
rti.registerTypeVariableBoundsSubtypeCheck(typeArgument, bound);
}
@@ -1321,10 +1291,8 @@ class JavaScriptBackend extends Backend {
}
/// Called when resolving a call to a foreign function.
- void registerForeignCall(Send node,
- Element element,
- CallStructure callStructure,
- ForeignResolver resolver) {
+ void registerForeignCall(Send node, Element element,
+ CallStructure callStructure, ForeignResolver resolver) {
native.NativeResolutionEnqueuer nativeEnqueuer =
compiler.enqueuer.resolution.nativeEnqueuer;
if (element.name == 'JS') {
@@ -1349,15 +1317,13 @@ class JavaScriptBackend extends Backend {
}
}
reporter.reportErrorMessage(
- node,
- MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
+ node, MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
}
}
void enableNoSuchMethod(Enqueuer world) {
enqueue(world, helpers.createInvocationMirror, compiler.globalDependencies);
- world.registerDynamicUse(
- new DynamicUse(Selectors.noSuchMethod_, null));
+ world.registerDynamicUse(new DynamicUse(Selectors.noSuchMethod_, null));
}
void enableIsolateSupport(Enqueuer enqueuer) {
@@ -1375,7 +1341,6 @@ class JavaScriptBackend extends Backend {
new StaticUse.staticTearOff(compiler.mainFunction));
}
if (enqueuer.isResolutionQueue) {
-
void enqueue(Element element) {
enqueuer.addToWorkList(element);
compiler.globalDependencies.registerDependency(element);
@@ -1396,19 +1361,19 @@ class JavaScriptBackend extends Backend {
}
bool isComplexNoSuchMethod(FunctionElement element) =>
- noSuchMethodRegistry.isComplex(element);
+ noSuchMethodRegistry.isComplex(element);
bool isDefaultEqualityImplementation(Element element) {
assert(element.name == '==');
ClassElement classElement = element.enclosingClass;
- return classElement == coreClasses.objectClass
- || classElement == helpers.jsInterceptorClass
- || classElement == helpers.jsNullClass;
+ return classElement == coreClasses.objectClass ||
+ classElement == helpers.jsInterceptorClass ||
+ classElement == helpers.jsNullClass;
}
bool methodNeedsRti(FunctionElement function) {
return rti.methodsNeedingRti.contains(function) ||
- compiler.enabledRuntimeType;
+ compiler.enabledRuntimeType;
}
/// Enqueue [e] in [enqueuer].
@@ -1459,9 +1424,8 @@ class JavaScriptBackend extends Backend {
registerInstantiatedType(type, enqueuer, registry);
}
- void enqueueImpact(Enqueuer enqueuer,
- BackendImpact impact,
- Registry registry) {
+ void enqueueImpact(
+ Enqueuer enqueuer, BackendImpact impact, Registry registry) {
for (Element staticUse in impact.staticUses) {
enqueue(enqueuer, staticUse, registry);
}
@@ -1502,17 +1466,16 @@ class JavaScriptBackend extends Backend {
// variables. For instance variables, we may need to generate
// the checked setter.
if (Elements.isStaticOrTopLevel(element)) {
- return impactTransformer.transformCodegenImpact(
- work.registry.worldImpact);
+ return impactTransformer
+ .transformCodegenImpact(work.registry.worldImpact);
}
} else {
// If the constant-handler was not able to produce a result we have to
// go through the builder (below) to generate the lazy initializer for
// the static variable.
// We also need to register the use of the cyclic-error helper.
- compiler.enqueuer.codegen.registerStaticUse(
- new StaticUse.staticInvoke(
- helpers.cyclicThrowHelper, CallStructure.ONE_ARG));
+ compiler.enqueuer.codegen.registerStaticUse(new StaticUse.staticInvoke(
+ helpers.cyclicThrowHelper, CallStructure.ONE_ARG));
}
}
@@ -1542,7 +1505,8 @@ class JavaScriptBackend extends Backend {
}
// Native classes inherit from Interceptor.
return isNative(element)
- ? helpers.jsInterceptorClass : coreClasses.objectClass;
+ ? helpers.jsInterceptorClass
+ : coreClasses.objectClass;
}
/**
@@ -1562,11 +1526,12 @@ class JavaScriptBackend extends Backend {
if (totalMethodCount != preMirrorsMethodCount) {
int mirrorCount = totalMethodCount - preMirrorsMethodCount;
double percentage = (mirrorCount / totalMethodCount) * 100;
- DiagnosticMessage hint = reporter.createMessage(
- compiler.mainApp, MessageKind.MIRROR_BLOAT,
- {'count': mirrorCount,
- 'total': totalMethodCount,
- 'percentage': percentage.round()});
+ DiagnosticMessage hint =
+ reporter.createMessage(compiler.mainApp, MessageKind.MIRROR_BLOAT, {
+ 'count': mirrorCount,
+ 'total': totalMethodCount,
+ 'percentage': percentage.round()
+ });
List<DiagnosticMessage> infos = <DiagnosticMessage>[];
for (LibraryElement library in compiler.libraryLoader.libraries) {
@@ -1576,8 +1541,8 @@ class JavaScriptBackend extends Backend {
if (importedLibrary != compiler.mirrorsLibrary) continue;
MessageKind kind =
compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(library)
- ? MessageKind.MIRROR_IMPORT
- : MessageKind.MIRROR_IMPORT_NO_USAGE;
+ ? MessageKind.MIRROR_IMPORT
+ : MessageKind.MIRROR_IMPORT_NO_USAGE;
reporter.withCurrentElement(library, () {
infos.add(reporter.createMessage(import, kind));
});
@@ -1604,8 +1569,8 @@ class JavaScriptBackend extends Backend {
* backend with implementation types (JSInt, JSString, ...).
*/
CheckedModeHelper getCheckedModeHelper(DartType type, {bool typeCast}) {
- return getCheckedModeHelperInternal(
- type, typeCast: typeCast, nativeCheckOnly: false);
+ return getCheckedModeHelperInternal(type,
+ typeCast: typeCast, nativeCheckOnly: false);
}
/**
@@ -1614,8 +1579,8 @@ class JavaScriptBackend extends Backend {
* [type], [:null:] is returned.
*/
CheckedModeHelper getNativeCheckedModeHelper(DartType type, {bool typeCast}) {
- return getCheckedModeHelperInternal(
- type, typeCast: typeCast, nativeCheckOnly: true);
+ return getCheckedModeHelperInternal(type,
+ typeCast: typeCast, nativeCheckOnly: true);
}
/**
@@ -1623,8 +1588,7 @@ class JavaScriptBackend extends Backend {
* [nativeCheckOnly] is [:true:], only names for native helpers are returned.
*/
CheckedModeHelper getCheckedModeHelperInternal(DartType type,
- {bool typeCast,
- bool nativeCheckOnly}) {
+ {bool typeCast, bool nativeCheckOnly}) {
String name = getCheckedModeHelperNameInternal(type,
typeCast: typeCast, nativeCheckOnly: nativeCheckOnly);
if (name == null) return null;
@@ -1634,8 +1598,7 @@ class JavaScriptBackend extends Backend {
}
String getCheckedModeHelperNameInternal(DartType type,
- {bool typeCast,
- bool nativeCheckOnly}) {
+ {bool typeCast, bool nativeCheckOnly}) {
assert(type.kind != TypeKind.TYPEDEF);
if (type.isMalformed) {
// The same error is thrown for type test and type cast of a malformed
@@ -1643,8 +1606,8 @@ class JavaScriptBackend extends Backend {
return 'checkMalformedType';
}
Element element = type.element;
- bool nativeCheck = nativeCheckOnly ||
- emitter.nativeEmitter.requiresNativeIsCheck(element);
+ bool nativeCheck =
+ nativeCheckOnly || emitter.nativeEmitter.requiresNativeIsCheck(element);
// TODO(13955), TODO(9731). The test for non-primitive types should use an
// interceptor. The interceptor should be an argument to HTypeConversion so
@@ -1656,38 +1619,28 @@ class JavaScriptBackend extends Backend {
if (nativeCheckOnly) return null;
return 'voidTypeCheck';
} else if (element == helpers.jsStringClass ||
- element == coreClasses.stringClass) {
+ element == coreClasses.stringClass) {
if (nativeCheckOnly) return null;
- return typeCast
- ? 'stringTypeCast'
- : 'stringTypeCheck';
+ return typeCast ? 'stringTypeCast' : 'stringTypeCheck';
} else if (element == helpers.jsDoubleClass ||
- element == coreClasses.doubleClass) {
+ element == coreClasses.doubleClass) {
if (nativeCheckOnly) return null;
- return typeCast
- ? 'doubleTypeCast'
- : 'doubleTypeCheck';
+ return typeCast ? 'doubleTypeCast' : 'doubleTypeCheck';
} else if (element == helpers.jsNumberClass ||
- element == coreClasses.numClass) {
+ element == coreClasses.numClass) {
if (nativeCheckOnly) return null;
- return typeCast
- ? 'numTypeCast'
- : 'numTypeCheck';
+ return typeCast ? 'numTypeCast' : 'numTypeCheck';
} else if (element == helpers.jsBoolClass ||
- element == coreClasses.boolClass) {
+ element == coreClasses.boolClass) {
if (nativeCheckOnly) return null;
- return typeCast
- ? 'boolTypeCast'
- : 'boolTypeCheck';
+ return typeCast ? 'boolTypeCast' : 'boolTypeCheck';
} else if (element == helpers.jsIntClass ||
- element == coreClasses.intClass ||
- element == helpers.jsUInt32Class ||
- element == helpers.jsUInt31Class ||
- element == helpers.jsPositiveIntClass) {
+ element == coreClasses.intClass ||
+ element == helpers.jsUInt32Class ||
+ element == helpers.jsUInt31Class ||
+ element == helpers.jsPositiveIntClass) {
if (nativeCheckOnly) return null;
- return typeCast
- ? 'intTypeCast'
- : 'intTypeCheck';
+ return typeCast ? 'intTypeCast' : 'intTypeCheck';
} else if (Elements.isNumberOrStringSupertype(element, compiler)) {
if (nativeCheck) {
return typeCast
@@ -1695,8 +1648,8 @@ class JavaScriptBackend extends Backend {
: 'numberOrStringSuperNativeTypeCheck';
} else {
return typeCast
- ? 'numberOrStringSuperTypeCast'
- : 'numberOrStringSuperTypeCheck';
+ ? 'numberOrStringSuperTypeCast'
+ : 'numberOrStringSuperTypeCheck';
}
} else if (Elements.isStringOnlySupertype(element, compiler)) {
if (nativeCheck) {
@@ -1704,17 +1657,13 @@ class JavaScriptBackend extends Backend {
? 'stringSuperNativeTypeCast'
: 'stringSuperNativeTypeCheck';
} else {
- return typeCast
- ? 'stringSuperTypeCast'
- : 'stringSuperTypeCheck';
+ return typeCast ? 'stringSuperTypeCast' : 'stringSuperTypeCheck';
}
} else if ((element == coreClasses.listClass ||
- element == helpers.jsArrayClass) &&
- type.treatAsRaw) {
+ element == helpers.jsArrayClass) &&
+ type.treatAsRaw) {
if (nativeCheckOnly) return null;
- return typeCast
- ? 'listTypeCast'
- : 'listTypeCheck';
+ return typeCast ? 'listTypeCast' : 'listTypeCheck';
} else {
if (Elements.isListSupertype(element, compiler)) {
if (nativeCheck) {
@@ -1722,15 +1671,11 @@ class JavaScriptBackend extends Backend {
? 'listSuperNativeTypeCast'
: 'listSuperNativeTypeCheck';
} else {
- return typeCast
- ? 'listSuperTypeCast'
- : 'listSuperTypeCheck';
+ return typeCast ? 'listSuperTypeCast' : 'listSuperTypeCheck';
}
} else {
if (type.isInterfaceType && !type.treatAsRaw) {
- return typeCast
- ? 'subtypeCast'
- : 'assertSubtype';
+ return typeCast ? 'subtypeCast' : 'assertSubtype';
} else if (type.isTypeVariable) {
return typeCast
? 'subtypeOfRuntimeTypeCast'
@@ -1741,13 +1686,9 @@ class JavaScriptBackend extends Backend {
if (nativeCheck) {
// TODO(karlklose): can we get rid of this branch when we use
// interceptors?
- return typeCast
- ? 'interceptedTypeCast'
- : 'interceptedTypeCheck';
+ return typeCast ? 'interceptedTypeCast' : 'interceptedTypeCheck';
} else {
- return typeCast
- ? 'propertyTypeCast'
- : 'propertyTypeCheck';
+ return typeCast ? 'propertyTypeCast' : 'propertyTypeCheck';
}
}
}
@@ -1831,8 +1772,8 @@ class JavaScriptBackend extends Backend {
// TODO(sigurdm): Create a function registerLoadLibraryAccess.
if (compiler.loadLibraryFunction == null) {
compiler.loadLibraryFunction = helpers.loadLibraryWrapper;
- enqueueInResolution(compiler.loadLibraryFunction,
- compiler.globalDependencies);
+ enqueueInResolution(
+ compiler.loadLibraryFunction, compiler.globalDependencies);
}
} else if (element == helpers.requiresPreambleMarker) {
requiresPreamble = true;
@@ -1849,8 +1790,7 @@ class JavaScriptBackend extends Backend {
}
/// Called when [:new Symbol(...):] is seen.
- void registerNewSymbol(Registry registry) {
- }
+ void registerNewSymbol(Registry registry) {}
/// Should [element] (a getter) that would normally not be generated due to
/// treeshaking be retained for reflection?
@@ -1930,13 +1870,13 @@ class JavaScriptBackend extends Backend {
implementationClasses[coreClasses.nullClass] = helpers.jsNullClass;
// These methods are overwritten with generated versions.
- inlineCache.markAsNonInlinable(
- helpers.getInterceptorMethod, insideLoop: true);
+ inlineCache.markAsNonInlinable(helpers.getInterceptorMethod,
+ insideLoop: true);
specialOperatorEqClasses
- ..add(coreClasses.objectClass)
- ..add(helpers.jsInterceptorClass)
- ..add(helpers.jsNullClass);
+ ..add(coreClasses.objectClass)
+ ..add(helpers.jsInterceptorClass)
+ ..add(helpers.jsNullClass);
validateInterceptorImplementsAllObjectMethods(helpers.jsInterceptorClass);
// The null-interceptor must also implement *all* methods.
@@ -1945,9 +1885,8 @@ class JavaScriptBackend extends Backend {
return new Future.value();
}
- void registerMirrorUsage(Set<String> symbols,
- Set<Element> targets,
- Set<Element> metaTargets) {
+ void registerMirrorUsage(
+ Set<String> symbols, Set<Element> targets, Set<Element> metaTargets) {
if (symbols == null && targets == null && metaTargets == null) {
// The user didn't specify anything, or there are imports of
// 'dart:mirrors' without @MirrorsUsed.
@@ -1992,8 +1931,8 @@ class JavaScriptBackend extends Backend {
*/
bool requiredByMirrorSystem(Element element) {
return hasInsufficientMirrorsUsed && isTreeShakingDisabled ||
- matchesMirrorsMetaTarget(element) ||
- targetsUsed.contains(element);
+ matchesMirrorsMetaTarget(element) ||
+ targetsUsed.contains(element);
}
/**
@@ -2005,9 +1944,9 @@ class JavaScriptBackend extends Backend {
Element enclosing = recursive ? element.enclosingElement : null;
return hasInsufficientMirrorsUsed ||
- matchesMirrorsMetaTarget(element) ||
- targetsUsed.contains(element) ||
- (enclosing != null && referencedFromMirrorSystem(enclosing));
+ matchesMirrorsMetaTarget(element) ||
+ targetsUsed.contains(element) ||
+ (enclosing != null && referencedFromMirrorSystem(enclosing));
}
/**
@@ -2180,8 +2119,8 @@ class JavaScriptBackend extends Backend {
_membersNeededForReflection.add(globalizedElement);
}
- jsAst.Call generateIsJsIndexableCall(jsAst.Expression use1,
- jsAst.Expression use2) {
+ jsAst.Call generateIsJsIndexableCall(
+ jsAst.Expression use1, jsAst.Expression use2) {
String dispatchPropertyName = embeddedNames.DISPATCH_PROPERTY_NAME;
jsAst.Expression dispatchProperty =
emitter.generateEmbeddedGlobalAccess(dispatchPropertyName);
@@ -2202,8 +2141,7 @@ class JavaScriptBackend extends Backend {
// Just checking for [:TypedData:] is not sufficient, as it is an
// abstract class any user-defined class can implement. So we also
// check for the interface [JavaScriptIndexingBehavior].
- return
- compiler.typedDataClass != null &&
+ return compiler.typedDataClass != null &&
compiler.world.isInstantiated(compiler.typedDataClass) &&
mask.satisfies(compiler.typedDataClass, compiler.world) &&
mask.satisfies(helpers.jsIndexingBehaviorInterface, compiler.world);
@@ -2214,13 +2152,14 @@ class JavaScriptBackend extends Backend {
!type1.intersection(type2, compiler.world).isEmpty;
// TODO(herhut): Maybe cache the TypeMask for typedDataClass and
// jsIndexingBehaviourInterface.
- return
- compiler.typedDataClass != null &&
+ return compiler.typedDataClass != null &&
compiler.world.isInstantiated(compiler.typedDataClass) &&
intersects(mask,
new TypeMask.subtype(compiler.typedDataClass, compiler.world)) &&
- intersects(mask,
- new TypeMask.subtype(helpers.jsIndexingBehaviorInterface, compiler.world));
+ intersects(
+ mask,
+ new TypeMask.subtype(
+ helpers.jsIndexingBehaviorInterface, compiler.world));
}
/// Returns all static fields that are referenced through [targetsUsed].
@@ -2260,7 +2199,7 @@ class JavaScriptBackend extends Backend {
noSuchMethodRegistry.onQueueEmpty();
if (!enabledNoSuchMethod &&
(noSuchMethodRegistry.hasThrowingNoSuchMethod ||
- noSuchMethodRegistry.hasComplexNoSuchMethod)) {
+ noSuchMethodRegistry.hasComplexNoSuchMethod)) {
enableNoSuchMethod(enqueuer);
enabledNoSuchMethod = true;
}
@@ -2294,8 +2233,7 @@ class JavaScriptBackend extends Backend {
compiler.libraryLoader.libraries.forEach(retainMetadataOf);
for (Dependency dependency in metadataConstants) {
- registerCompileTimeConstant(
- dependency.constant,
+ registerCompileTimeConstant(dependency.constant,
new EagerRegistry('EagerRegistry for ${dependency}', enqueuer));
}
if (!enqueuer.isResolutionQueue) {
@@ -2343,53 +2281,46 @@ class JavaScriptBackend extends Backend {
hasForceInline = true;
if (VERBOSE_OPTIMIZER_HINTS) {
reporter.reportHintMessage(
- element,
- MessageKind.GENERIC,
- {'text': "Must inline"});
+ element, MessageKind.GENERIC, {'text': "Must inline"});
}
inlineCache.markAsMustInline(element);
} else if (cls == helpers.noInlineClass) {
hasNoInline = true;
if (VERBOSE_OPTIMIZER_HINTS) {
reporter.reportHintMessage(
- element,
- MessageKind.GENERIC,
- {'text': "Cannot inline"});
+ element, MessageKind.GENERIC, {'text': "Cannot inline"});
}
inlineCache.markAsNonInlinable(element);
} else if (cls == helpers.noThrowsClass) {
hasNoThrows = true;
if (!Elements.isStaticOrTopLevelFunction(element) &&
!element.isFactoryConstructor) {
- reporter.internalError(element,
+ reporter.internalError(
+ element,
"@NoThrows() is currently limited to top-level"
" or static functions and factory constructors.");
}
if (VERBOSE_OPTIMIZER_HINTS) {
reporter.reportHintMessage(
- element,
- MessageKind.GENERIC,
- {'text': "Cannot throw"});
+ element, MessageKind.GENERIC, {'text': "Cannot throw"});
}
compiler.world.registerCannotThrow(element);
} else if (cls == helpers.noSideEffectsClass) {
hasNoSideEffects = true;
if (VERBOSE_OPTIMIZER_HINTS) {
reporter.reportHintMessage(
- element,
- MessageKind.GENERIC,
- {'text': "Has no side effects"});
+ element, MessageKind.GENERIC, {'text': "Has no side effects"});
}
compiler.world.registerSideEffectsFree(element);
}
}
if (hasForceInline && hasNoInline) {
- reporter.internalError(element,
- "@ForceInline() must not be used with @NoInline.");
+ reporter.internalError(
+ element, "@ForceInline() must not be used with @NoInline.");
}
if (hasNoThrows && !hasNoInline) {
- reporter.internalError(element,
- "@NoThrows() should always be combined with @NoInline.");
+ reporter.internalError(
+ element, "@NoThrows() should always be combined with @NoInline.");
}
if (hasNoSideEffects && !hasNoInline) {
reporter.internalError(element,
@@ -2399,6 +2330,7 @@ class JavaScriptBackend extends Backend {
compiler.enabledInvokeOn = true;
}
}
+
/*
CodeBuffer codeOf(Element element) {
return generatedCode.containsKey(element)
@@ -2450,66 +2382,55 @@ class JavaScriptBackend extends Backend {
bool enableCodegenWithErrorsIfSupported(Spannable node) {
if (compiler.options.useCpsIr) {
// TODO(25747): Support code generation with compile-time errors.
- reporter.reportHintMessage(
- node,
- MessageKind.GENERIC,
- {'text': "Generation of code with compile time errors is currently "
- "not supported with the CPS IR."});
+ reporter.reportHintMessage(node, MessageKind.GENERIC, {
+ 'text': "Generation of code with compile time errors is currently "
+ "not supported with the CPS IR."
+ });
return false;
}
return true;
}
- jsAst.Expression rewriteAsync(FunctionElement element,
- jsAst.Expression code) {
+ jsAst.Expression rewriteAsync(
+ FunctionElement element, jsAst.Expression code) {
AsyncRewriterBase rewriter = null;
jsAst.Name name = namer.methodPropertyName(element);
switch (element.asyncMarker) {
case AsyncMarker.ASYNC:
- rewriter = new AsyncRewriter(
- reporter,
- element,
- asyncHelper:
- emitter.staticFunctionAccess(helpers.asyncHelper),
- wrapBody:
- emitter.staticFunctionAccess(helpers.wrapBody),
- newCompleter: emitter.staticFunctionAccess(
- helpers.syncCompleterConstructor),
+ rewriter = new AsyncRewriter(reporter, element,
+ asyncHelper: emitter.staticFunctionAccess(helpers.asyncHelper),
+ wrapBody: emitter.staticFunctionAccess(helpers.wrapBody),
+ newCompleter:
+ emitter.staticFunctionAccess(helpers.syncCompleterConstructor),
safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
bodyName: namer.deriveAsyncBodyName(name));
break;
case AsyncMarker.SYNC_STAR:
- rewriter = new SyncStarRewriter(
- reporter,
- element,
- endOfIteration: emitter.staticFunctionAccess(
- helpers.endOfIteration),
- newIterable: emitter.staticFunctionAccess(
- helpers.syncStarIterableConstructor),
- yieldStarExpression: emitter.staticFunctionAccess(
- helpers.yieldStar),
- uncaughtErrorExpression: emitter.staticFunctionAccess(
- helpers.syncStarUncaughtError),
+ rewriter = new SyncStarRewriter(reporter, element,
+ endOfIteration:
+ emitter.staticFunctionAccess(helpers.endOfIteration),
+ newIterable: emitter
+ .staticFunctionAccess(helpers.syncStarIterableConstructor),
+ yieldStarExpression:
+ emitter.staticFunctionAccess(helpers.yieldStar),
+ uncaughtErrorExpression:
+ emitter.staticFunctionAccess(helpers.syncStarUncaughtError),
safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
bodyName: namer.deriveAsyncBodyName(name));
- break;
+ break;
case AsyncMarker.ASYNC_STAR:
- rewriter = new AsyncStarRewriter(
- reporter,
- element,
- asyncStarHelper: emitter.staticFunctionAccess(
- helpers.asyncStarHelper),
- streamOfController: emitter.staticFunctionAccess(
- helpers.streamOfController),
- wrapBody:
- emitter.staticFunctionAccess(helpers.wrapBody),
- newController: emitter.staticFunctionAccess(
- helpers.asyncStarControllerConstructor),
+ rewriter = new AsyncStarRewriter(reporter, element,
+ asyncStarHelper:
+ emitter.staticFunctionAccess(helpers.asyncStarHelper),
+ streamOfController:
+ emitter.staticFunctionAccess(helpers.streamOfController),
+ wrapBody: emitter.staticFunctionAccess(helpers.wrapBody),
+ newController: emitter
+ .staticFunctionAccess(helpers.asyncStarControllerConstructor),
safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
- yieldExpression: emitter.staticFunctionAccess(
- helpers.yieldSingle),
- yieldStarExpression: emitter.staticFunctionAccess(
- helpers.yieldStar),
+ yieldExpression: emitter.staticFunctionAccess(helpers.yieldSingle),
+ yieldStarExpression:
+ emitter.staticFunctionAccess(helpers.yieldStar),
bodyName: namer.deriveAsyncBodyName(name));
break;
default:
@@ -2522,7 +2443,7 @@ class JavaScriptBackend extends Backend {
/// The locations of js patch-files relative to the sdk-descriptors.
static const _patchLocations = const <String, String>{
"async": "_internal/js_runtime/lib/async_patch.dart",
- "collection": "_internal/js_runtime/lib/collection_patch.dart",
+ "collection": "_internal/js_runtime/lib/collection_patch.dart",
"convert": "_internal/js_runtime/lib/convert_patch.dart",
"core": "_internal/js_runtime/lib/core_patch.dart",
"developer": "_internal/js_runtime/lib/developer_patch.dart",
@@ -2544,11 +2465,9 @@ class JavaScriptBackend extends Backend {
@override
ImpactStrategy createImpactStrategy(
{bool supportDeferredLoad: true,
- bool supportDumpInfo: true,
- bool supportSerialization: true}) {
- return new JavaScriptImpactStrategy(
- resolution,
- compiler.dumpInfoTask,
+ bool supportDumpInfo: true,
+ bool supportSerialization: true}) {
+ return new JavaScriptImpactStrategy(resolution, compiler.dumpInfoTask,
supportDeferredLoad: supportDeferredLoad,
supportDumpInfo: supportDumpInfo,
supportSerialization: supportSerialization);
@@ -2758,8 +2677,8 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
}
if (hasTypeLiteral) {
- transformed.registerTypeUse(new TypeUse.instantiation(
- backend.compiler.coreTypes.typeType));
+ transformed.registerTypeUse(
+ new TypeUse.instantiation(backend.compiler.coreTypes.typeType));
registerBackendImpact(transformed, impacts.typeLiteral);
}
@@ -2769,8 +2688,8 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
if (mapLiteralUse.isConstant) {
registerBackendImpact(transformed, impacts.constantMapLiteral);
} else {
- transformed.registerTypeUse(
- new TypeUse.instantiation(mapLiteralUse.type));
+ transformed
+ .registerTypeUse(new TypeUse.instantiation(mapLiteralUse.type));
}
registerRequiredType(mapLiteralUse.type);
}
@@ -2778,8 +2697,8 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
for (ListLiteralUse listLiteralUse in worldImpact.listLiterals) {
// TODO(johnniwinther): Use the [isConstant] and [isEmpty] property when
// factory constructors are registered directly.
- transformed.registerTypeUse(
- new TypeUse.instantiation(listLiteralUse.type));
+ transformed
+ .registerTypeUse(new TypeUse.instantiation(listLiteralUse.type));
registerRequiredType(listLiteralUse.type);
}
@@ -2796,7 +2715,8 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
LocalFunctionElement closure = staticUse.element;
if (closure.type.containsTypeVariables) {
backend.compiler.enqueuer.resolution.universe
- .closuresWithFreeTypeVariables.add(closure);
+ .closuresWithFreeTypeVariables
+ .add(closure);
registerBackendImpact(transformed, impacts.computeSignature);
}
}
@@ -2828,8 +2748,8 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
return transformed;
}
- void registerBackendImpact(TransformedWorldImpact worldImpact,
- BackendImpact backendImpact) {
+ void registerBackendImpact(
+ TransformedWorldImpact worldImpact, BackendImpact backendImpact) {
for (Element staticUse in backendImpact.staticUses) {
assert(staticUse != null);
backend.registerBackendUse(staticUse);
@@ -2839,14 +2759,12 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
}
for (InterfaceType instantiatedType in backendImpact.instantiatedTypes) {
backend.registerBackendUse(instantiatedType.element);
- worldImpact.registerTypeUse(
- new TypeUse.instantiation(instantiatedType));
+ worldImpact.registerTypeUse(new TypeUse.instantiation(instantiatedType));
}
for (ClassElement cls in backendImpact.instantiatedClasses) {
cls.ensureResolved(backend.resolution);
backend.registerBackendUse(cls);
- worldImpact.registerTypeUse(
- new TypeUse.instantiation(cls.rawType));
+ worldImpact.registerTypeUse(new TypeUse.instantiation(cls.rawType));
}
for (BackendImpact otherImpact in backendImpact.otherImpacts) {
registerBackendImpact(worldImpact, otherImpact);
@@ -2888,8 +2806,8 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
if (type.isTypeVariable) {
registerBackendImpact(transformed, impacts.typeVariableTypeCheck);
if (inCheckedMode) {
- registerBackendImpact(transformed,
- impacts.typeVariableCheckedModeTypeCheck);
+ registerBackendImpact(
+ transformed, impacts.typeVariableCheckedModeTypeCheck);
}
}
}
@@ -2963,18 +2881,17 @@ class JavaScriptImpactTransformer extends ImpactTransformer {
backend.addCompileTimeConstantForEmission(constant);
}
- for (Pair<DartType, DartType> check in
- impact.typeVariableBoundsSubtypeChecks) {
+ for (Pair<DartType, DartType> check
+ in impact.typeVariableBoundsSubtypeChecks) {
backend.registerTypeVariableBoundsSubtypeCheck(check.a, check.b);
}
-
for (StaticUse staticUse in impact.staticUses) {
if (staticUse.kind == StaticUseKind.CLOSURE) {
LocalFunctionElement closure = staticUse.element;
if (backend.methodNeedsRti(closure)) {
- registerBackendImpact(transformed, impacts.computeSignature);
- }
+ registerBackendImpact(transformed, impacts.computeSignature);
+ }
}
}
@@ -3029,17 +2946,14 @@ class JavaScriptImpactStrategy extends ImpactStrategy {
final bool supportDumpInfo;
final bool supportSerialization;
- JavaScriptImpactStrategy(this.resolution,
- this.dumpInfoTask,
- {this.supportDeferredLoad,
- this.supportDumpInfo,
- this.supportSerialization});
+ JavaScriptImpactStrategy(this.resolution, this.dumpInfoTask,
+ {this.supportDeferredLoad,
+ this.supportDumpInfo,
+ this.supportSerialization});
@override
- void visitImpact(Element element,
- WorldImpact impact,
- WorldImpactVisitor visitor,
- ImpactUseCase impactUse) {
+ void visitImpact(Element element, WorldImpact impact,
+ WorldImpactVisitor visitor, ImpactUseCase impactUse) {
// TODO(johnniwinther): Compute the application strategy once for each use.
if (impactUse == ResolutionEnqueuer.IMPACT_USE) {
if (supportDeferredLoad || supportSerialization) {
@@ -3061,8 +2975,7 @@ class JavaScriptImpactStrategy extends ImpactStrategy {
@override
void onImpactUsed(ImpactUseCase impactUse) {
- if (impactUse == DeferredLoadTask.IMPACT_USE &&
- !supportSerialization) {
+ if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) {
// TODO(johnniwinther): Allow emptying when serialization has been
// performed.
resolution.emptyCache();
« no previous file with comments | « pkg/compiler/lib/src/js/rewrite_async.dart ('k') | pkg/compiler/lib/src/js_backend/backend_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698