Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart |
diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart |
index 21e7b5ca20fb720a8661c077e3daa58b0f9b5429..0c1c3d40acfd11cb0c93fbc969b5f621c21723d2 100644 |
--- a/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart |
+++ b/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart |
@@ -2627,6 +2627,8 @@ class CodeEmitterTask extends CompilerTask { |
for (Element element in Elements.sortedByPosition(staticNonFinalFields)) { |
// [:interceptedNames:] is handled in [emitInterceptedNames]. |
if (element == backend.interceptedNames) continue; |
+ // `mapTypeToInterceptor` is handled in [emitMapTypeToInterceptor]. |
+ if (element == backend.mapTypeToInterceptor) continue; |
compiler.withCurrentElement(element, () { |
Constant initialValue = handler.getInitialValueFor(element); |
jsAst.Expression init = |
@@ -3040,9 +3042,8 @@ if (typeof document !== "undefined" && document.readyState !== "complete") { |
else if (cls == backend.jsStringClass) hasString = true; |
else { |
// TODO(sra): The set of classes includes classes mixed-in to |
- // interceptor classes. |
- // assert(cls == compiler.objectClass || cls.isNative()); |
- if (cls.isNative()) hasNative = true; |
+ // interceptor classes and user extensions of native classes. |
+ if (Elements.isNativeOrExtendsNative(cls)) hasNative = true; |
} |
} |
if (hasDouble) { |
@@ -3216,9 +3217,13 @@ if (typeof document !== "undefined" && document.readyState !== "complete") { |
for (ClassElement element in sortedClasses) { |
if (rtiNeededClasses.contains(element)) { |
regularClasses.add(element); |
- } else if (element.isNative()) { |
- // For now, native classes cannot be deferred. |
+ } else if (Elements.isNativeOrExtendsNative(element)) { |
+ // For now, native classes and related classes cannot be deferred. |
nativeClasses.add(element); |
+ if (!element.isNative()) { |
+ assert(!isDeferred(element)); |
+ regularClasses.add(element); |
+ } |
} else if (isDeferred(element)) { |
deferredClasses.add(element); |
} else { |
@@ -3482,6 +3487,36 @@ if (typeof document !== "undefined" && document.readyState !== "complete") { |
buffer.write(N); |
} |
+ /** |
+ * Emit initializer for [mapTypeToInterceptor] data structure used by |
+ * [findInterceptorForType]. |
ahe
2013/08/12 20:47:35
I'd like more documentation here, could you answer
sra1
2013/08/12 23:06:14
This is described where the variable is declared.
|
+ */ |
+ void emitMapTypeToInterceptor(CodeBuffer buffer) { |
+ // TODO(sra): Perhaps inject a constant instead? |
+ // TODO(sra): Filter by subclasses of native types. |
+ List<jsAst.Expression> elements = <jsAst.Expression>[]; |
+ ConstantHandler handler = compiler.constantHandler; |
+ List<Constant> constants = handler.getConstantsForEmission(); |
+ for (Constant constant in constants) { |
+ if (constant is TypeConstant) { |
+ TypeConstant typeConstant = constant; |
+ Element element = typeConstant.representedType.element; |
+ if (element is ClassElement) { |
+ ClassElement classElement = element; |
+ elements.add(backend.emitter.constantReference(constant)); |
+ elements.add(js(namer.isolateAccess(classElement))); |
+ } |
+ } |
+ } |
+ |
+ jsAst.ArrayInitializer array = new jsAst.ArrayInitializer.from(elements); |
+ String name = backend.namer.getName(backend.mapTypeToInterceptor); |
+ jsAst.Expression assignment = js('$isolateProperties.$name = #', array); |
+ |
+ buffer.write(jsAst.prettyPrint(assignment, compiler)); |
+ buffer.write(N); |
+ } |
+ |
void emitInitFunction(CodeBuffer buffer) { |
jsAst.Fun fun = js.fun([], [ |
js('$isolateProperties = {}'), |
@@ -3814,6 +3849,7 @@ if (typeof document !== "undefined" && document.readyState !== "complete") { |
emitStaticNonFinalFieldInitializations(mainBuffer); |
emitOneShotInterceptors(mainBuffer); |
emitInterceptedNames(mainBuffer); |
+ emitMapTypeToInterceptor(mainBuffer); |
emitLazilyInitializedStaticFields(mainBuffer); |
mainBuffer.add(nativeBuffer); |