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

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

Issue 841993003: dart2js: Only emit constructors of the native class interceptors that are used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added documentation. Created 5 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/native_emitter.dart
diff --git a/pkg/compiler/lib/src/js_backend/native_emitter.dart b/pkg/compiler/lib/src/js_backend/native_emitter.dart
index 60f11553430e71639cbfa93dd9780a1d1020a973..535aa12c2086c27db9471931ff478da850228a99 100644
--- a/pkg/compiler/lib/src/js_backend/native_emitter.dart
+++ b/pkg/compiler/lib/src/js_backend/native_emitter.dart
@@ -232,10 +232,27 @@ class NativeEmitter {
for (ClassElement classElement in classes) {
if (!classElement.isNative) continue;
if (neededClasses.contains(classElement)) {
+ ClassBuilder builder = builders[classElement];
+
+ // In CSP mode [emitClassConstructor] and [emitClassGettersSetters] emit
+ // code outside the classBuilder. They are called here to avoid emitting
+ // code for unneeded classes.
+ //
+ // Having the calls here (instead of in the classBuilder) is safe:
ahe 2015/01/15 08:49:51 I'm not sure this comment adds value long term. Wh
zarah 2015/01/15 15:10:19 Done.
+ //
+ // [emitClassConstructor] only affects the generation of constructors
ahe 2015/01/15 08:49:51 Shouldn't this be part of emitClassConstructor's d
floitsch 2015/01/15 14:37:20 Probably both.
zarah 2015/01/15 15:10:19 Added documentation of the function as well.
+ // in CSP mode.
+ //
+ // [emitClassGettersSetters] does not affect whether or not a class is
ahe 2015/01/15 08:49:51 Ditto.
floitsch 2015/01/15 14:37:20 No. this comment should be here. It explains why w
zarah 2015/01/15 15:10:19 Added documentation of the function as well.
+ // needed. If getters/setters are emitted, the class has fields and
+ // is therefore non-trivial.
+ emitterTask.oldEmitter.classEmitter.emitClassConstructor(
+ classElement, builder);
+ emitterTask.oldEmitter.classEmitter.emitClassGettersSetters(
+ classElement, builder);
// Define interceptor class for [classElement].
emitterTask.oldEmitter.classEmitter.emitClassBuilderWithReflectionData(
- backend.namer.getNameOfClass(classElement),
- classElement, builders[classElement],
+ backend.namer.getNameOfClass(classElement), classElement, builder,
emitterTask.oldEmitter.getElementDescriptor(classElement));
emitterTask.oldEmitter.needsClassSupport = true;
}
@@ -301,13 +318,10 @@ class NativeEmitter {
}
builder.superName = superName;
- emitterTask.oldEmitter.classEmitter.emitClassConstructor(
- classElement, builder);
bool hasFields = emitterTask.oldEmitter.classEmitter.emitFields(
classElement, builder, classIsNative: true);
int propertyCount = builder.properties.length;
- emitterTask.oldEmitter.classEmitter.emitClassGettersSetters(
- classElement, builder);
+
emitterTask.oldEmitter.classEmitter.emitInstanceMembers(
classElement, builder);
emitterTask.oldEmitter.typeTestEmitter.emitIsTests(classElement, builder);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698