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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of js_backend; 5 part of js_backend;
6 6
7 class NativeEmitter { 7 class NativeEmitter {
8 8
9 final Map<Element, ClassBuilder> cachedBuilders; 9 final Map<Element, ClassBuilder> cachedBuilders;
10 10
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 // Emit the native class interceptors that were actually used. 231 // Emit the native class interceptors that were actually used.
232 for (ClassElement classElement in classes) { 232 for (ClassElement classElement in classes) {
233 if (!classElement.isNative) continue; 233 if (!classElement.isNative) continue;
234 if (neededClasses.contains(classElement)) { 234 if (neededClasses.contains(classElement)) {
235 // Define interceptor class for [classElement]. 235 // Define interceptor class for [classElement].
236 emitterTask.oldEmitter.classEmitter.emitClassBuilderWithReflectionData( 236 emitterTask.oldEmitter.classEmitter.emitClassBuilderWithReflectionData(
237 backend.namer.getNameOfClass(classElement), 237 backend.namer.getNameOfClass(classElement),
238 classElement, builders[classElement], 238 classElement, builders[classElement],
239 emitterTask.oldEmitter.getElementDescriptor(classElement)); 239 emitterTask.oldEmitter.getElementDescriptor(classElement));
240 emitterTask.oldEmitter.classEmitter.emitClassConstructor(
floitsch 2015/01/13 18:40:57 Requires lots of comments, and verification. As f
zarah 2015/01/15 08:10:01 I agree with your observations. Updated the CL des
241 classElement, builders[classElement]);
242 emitterTask.oldEmitter.classEmitter.emitClassGettersSetters(
243 classElement, builders[classElement]);
240 emitterTask.oldEmitter.needsClassSupport = true; 244 emitterTask.oldEmitter.needsClassSupport = true;
241 } 245 }
242 } 246 }
243 } 247 }
244 248
245 /** 249 /**
246 * Computes the native classes that are extended (subclassed) by non-native 250 * Computes the native classes that are extended (subclassed) by non-native
247 * classes and the set non-mative classes that extend them. (A List is used 251 * classes and the set non-mative classes that extend them. (A List is used
248 * instead of a Set for out stability). 252 * instead of a Set for out stability).
249 */ 253 */
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (compiler.hasIncrementalSupport) { 298 if (compiler.hasIncrementalSupport) {
295 builder = cachedBuilders[classElement]; 299 builder = cachedBuilders[classElement];
296 if (builder != null) return builder; 300 if (builder != null) return builder;
297 builder = new ClassBuilder(classElement, backend.namer); 301 builder = new ClassBuilder(classElement, backend.namer);
298 cachedBuilders[classElement] = builder; 302 cachedBuilders[classElement] = builder;
299 } else { 303 } else {
300 builder = new ClassBuilder(classElement, backend.namer); 304 builder = new ClassBuilder(classElement, backend.namer);
301 } 305 }
302 builder.superName = superName; 306 builder.superName = superName;
303 307
304 emitterTask.oldEmitter.classEmitter.emitClassConstructor(
305 classElement, builder);
306 bool hasFields = emitterTask.oldEmitter.classEmitter.emitFields( 308 bool hasFields = emitterTask.oldEmitter.classEmitter.emitFields(
307 classElement, builder, classIsNative: true); 309 classElement, builder, classIsNative: true);
308 int propertyCount = builder.properties.length; 310 int propertyCount = builder.properties.length;
309 emitterTask.oldEmitter.classEmitter.emitClassGettersSetters( 311
310 classElement, builder);
311 emitterTask.oldEmitter.classEmitter.emitInstanceMembers( 312 emitterTask.oldEmitter.classEmitter.emitInstanceMembers(
312 classElement, builder); 313 classElement, builder);
313 emitterTask.oldEmitter.typeTestEmitter.emitIsTests(classElement, builder); 314 emitterTask.oldEmitter.typeTestEmitter.emitIsTests(classElement, builder);
314 315
315 if (!hasFields && 316 if (!hasFields &&
316 builder.properties.length == propertyCount && 317 builder.properties.length == propertyCount &&
317 superclass is! MixinApplicationElement) { 318 superclass is! MixinApplicationElement) {
318 builder.isTrivial = true; 319 builder.isTrivial = true;
319 } 320 }
320 321
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 targetOutput.add(';'); 471 targetOutput.add(';');
471 } 472 }
472 targetOutput.addBuffer(jsAst.prettyPrint( 473 targetOutput.addBuffer(jsAst.prettyPrint(
473 new jsAst.ExpressionStatement(init), compiler)); 474 new jsAst.ExpressionStatement(init), compiler));
474 targetOutput.add('\n'); 475 targetOutput.add('\n');
475 } 476 }
476 477
477 targetOutput.add('\n'); 478 targetOutput.add('\n');
478 } 479 }
479 } 480 }
OLDNEW
« 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