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 7027d5e9531983627267e1f3f79df25a53ab8fde..d60686d15bb13a48de406f13b7cd3600a80300b6 100644 |
--- a/pkg/compiler/lib/src/js_backend/backend.dart |
+++ b/pkg/compiler/lib/src/js_backend/backend.dart |
@@ -478,7 +478,8 @@ class JavaScriptBackend { |
bool useNewSourceInfo: false, |
bool useKernel: false}) |
: _rti = new _RuntimeTypes(compiler), |
- annotations = new OptimizerHintsForTests(compiler), |
+ annotations = new OptimizerHintsForTests( |
Siggi Cherem (dart-lang)
2017/05/02 20:04:22
ditto
Johnni Winther
2017/05/03 08:05:59
Done.
|
+ compiler.elementEnvironment, compiler.commonElements), |
this.sourceInformationStrategy = createSourceInformationStrategy( |
generateSourceMap: generateSourceMap, |
useMultiSourceInfo: useMultiSourceInfo, |
@@ -1179,36 +1180,38 @@ class JavaScriptBackend { |
} |
/// Process backend specific annotations. |
+ // TODO(johnniwinther): Merge this with [AnnotationProcessor] and use |
+ // [ElementEnvironment.getMemberMetadata] in [AnnotationProcessor]. |
void processAnnotations( |
- MemberElement element, ClosedWorldRefiner closedWorldRefiner) { |
- if (element.isMalformed) { |
+ MemberEntity element, ClosedWorldRefiner closedWorldRefiner) { |
+ if (element is MemberElement && element.isMalformed) { |
// Elements that are marked as malformed during parsing or resolution |
// might be registered here. These should just be ignored. |
return; |
} |
if (element.isFunction || element.isConstructor) { |
- MethodElement method = element.implementation; |
- if (annotations.noInline(method)) { |
- inlineCache.markAsNonInlinable(method); |
+ if (annotations.noInline(element)) { |
+ inlineCache.markAsNonInlinable(element); |
} |
} |
if (element.isField) return; |
- MethodElement method = element; |
+ FunctionEntity method = element; |
- LibraryElement library = method.library; |
- if (!library.isPlatformLibrary && !canLibraryUseNative(library)) return; |
+ LibraryEntity library = method.library; |
+ if (library.canonicalUri.scheme != 'dart' && |
+ !canLibraryUseNative(library)) { |
+ return; |
+ } |
bool hasNoInline = false; |
bool hasForceInline = false; |
bool hasNoThrows = false; |
bool hasNoSideEffects = false; |
- for (MetadataAnnotation metadata in method.implementation.metadata) { |
- metadata.ensureResolved(resolution); |
- ConstantValue constantValue = |
- compiler.constants.getConstantValue(metadata.constant); |
+ for (ConstantValue constantValue |
+ in compiler.elementEnvironment.getMemberMetadata(method)) { |
if (!constantValue.isConstructedObject) continue; |
ObjectConstantValue value = constantValue; |
- ClassElement cls = value.type.element; |
+ ClassEntity cls = value.type.element; |
if (cls == commonElements.forceInlineClass) { |
hasForceInline = true; |
if (VERBOSE_OPTIMIZER_HINTS) { |
@@ -1225,8 +1228,15 @@ class JavaScriptBackend { |
inlineCache.markAsNonInlinable(method); |
} else if (cls == commonElements.noThrowsClass) { |
hasNoThrows = true; |
- if (!Elements.isStaticOrTopLevelFunction(method) && |
- !method.isFactoryConstructor) { |
+ bool isValid = true; |
+ if (method.isTopLevel) { |
+ isValid = true; |
+ } else if (method.isStatic) { |
+ isValid = true; |
+ } else if (method is ConstructorEntity && method.isFactoryConstructor) { |
+ isValid = true; |
+ } |
+ if (!isValid) { |
reporter.internalError( |
method, |
"@NoThrows() is currently limited to top-level" |