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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart

Issue 833623003: dart2js: Merge intercepted names map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Refactored. 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 getElementDescriptor(element).properties.addAll(builder.properties); 761 getElementDescriptor(element).properties.addAll(builder.properties);
762 } 762 }
763 } 763 }
764 764
765 void emitStaticNonFinalFieldInitializations(CodeBuffer buffer, 765 void emitStaticNonFinalFieldInitializations(CodeBuffer buffer,
766 OutputUnit outputUnit) { 766 OutputUnit outputUnit) {
767 JavaScriptConstantCompiler handler = backend.constants; 767 JavaScriptConstantCompiler handler = backend.constants;
768 Iterable<VariableElement> staticNonFinalFields = 768 Iterable<VariableElement> staticNonFinalFields =
769 handler.getStaticNonFinalFieldsForEmission(); 769 handler.getStaticNonFinalFieldsForEmission();
770 for (Element element in Elements.sortedByPosition(staticNonFinalFields)) { 770 for (Element element in Elements.sortedByPosition(staticNonFinalFields)) {
771 // [:interceptedNames:] is handled in [emitInterceptedNames].
772 if (element == backend.interceptedNames) continue;
773 // `mapTypeToInterceptor` is handled in [emitMapTypeToInterceptor]. 771 // `mapTypeToInterceptor` is handled in [emitMapTypeToInterceptor].
774 if (element == backend.mapTypeToInterceptor) continue; 772 if (element == backend.mapTypeToInterceptor) continue;
775 compiler.withCurrentElement(element, () { 773 compiler.withCurrentElement(element, () {
776 jsAst.Expression initialValue; 774 jsAst.Expression initialValue;
777 if (outputUnit != 775 if (outputUnit !=
778 compiler.deferredLoadTask.outputUnitForElement(element)) { 776 compiler.deferredLoadTask.outputUnitForElement(element)) {
779 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) { 777 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) {
780 // In the main output-unit we output a stub initializer for deferred 778 // In the main output-unit we output a stub initializer for deferred
781 // variables, such that `isolateProperties` stays a fast object. 779 // variables, such that `isolateProperties` stays a fast object.
782 initialValue = jsAst.number(0); 780 initialValue = jsAst.number(0);
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 var descriptor = Object.create(null); 1405 var descriptor = Object.create(null);
1408 this.addStubs(descriptor, array, name, isStatic, originalDescriptor, []); 1406 this.addStubs(descriptor, array, name, isStatic, originalDescriptor, []);
1409 return descriptor; 1407 return descriptor;
1410 }; 1408 };
1411 }""", 1409 }""",
1412 { 'helper': js('this.#', [namer.incrementalHelperName]), 1410 { 'helper': js('this.#', [namer.incrementalHelperName]),
1413 'schemaChange': buildSchemaChangeFunction(), 1411 'schemaChange': buildSchemaChangeFunction(),
1414 'addMethod': buildIncrementalAddMethod() }), compiler)); 1412 'addMethod': buildIncrementalAddMethod() }), compiler));
1415 } 1413 }
1416 if (isProgramSplit) { 1414 if (isProgramSplit) {
1417 /// We collect all the global state of the, so it can be passed to the 1415 /// We collect all the global state, so it can be passed to the
1418 /// initializer of deferred files. 1416 /// initializer of deferred files.
1419 mainBuffer.write('var ${globalsHolder}$_=${_}Object.create(null)$N'); 1417 mainBuffer.write('var ${globalsHolder}$_=${_}Object.create(null)$N');
1420 } 1418 }
1421 mainBuffer.write('function dart()$_{$n' 1419 mainBuffer.write('function dart()$_{$n'
1422 '${_}${_}this.x$_=${_}0$N' 1420 '${_}${_}this.x$_=${_}0$N'
1423 '${_}${_}delete this.x$N' 1421 '${_}${_}delete this.x$N'
1424 '}$n'); 1422 '}$n');
1425 for (String globalObject in Namer.reservedGlobalObjectNames) { 1423 for (String globalObject in Namer.reservedGlobalObjectNames) {
1426 // The global objects start as so-called "slow objects". For V8, this 1424 // The global objects start as so-called "slow objects". For V8, this
1427 // means that it won't try to make map transitions as we add properties 1425 // means that it won't try to make map transitions as we add properties
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 // which may need getInterceptor (and one-shot interceptor) methods, so 1496 // which may need getInterceptor (and one-shot interceptor) methods, so
1499 // we have to make sure that [emitGetInterceptorMethods] and 1497 // we have to make sure that [emitGetInterceptorMethods] and
1500 // [emitOneShotInterceptors] have been called. 1498 // [emitOneShotInterceptors] have been called.
1501 emitCompileTimeConstants(mainBuffer, mainOutputUnit); 1499 emitCompileTimeConstants(mainBuffer, mainOutputUnit);
1502 1500
1503 emitDeferredBoilerPlate(mainBuffer, deferredLoadHashes); 1501 emitDeferredBoilerPlate(mainBuffer, deferredLoadHashes);
1504 1502
1505 // Static field initializations require the classes and compile-time 1503 // Static field initializations require the classes and compile-time
1506 // constants to be set up. 1504 // constants to be set up.
1507 emitStaticNonFinalFieldInitializations(mainBuffer, mainOutputUnit); 1505 emitStaticNonFinalFieldInitializations(mainBuffer, mainOutputUnit);
1508 interceptorEmitter.emitInterceptedNames(mainBuffer);
1509 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer); 1506 interceptorEmitter.emitMapTypeToInterceptor(mainBuffer);
1510 emitLazilyInitializedStaticFields(mainBuffer); 1507 emitLazilyInitializedStaticFields(mainBuffer);
1511 1508
1512 mainBuffer.writeln(); 1509 mainBuffer.writeln();
1513 mainBuffer.write(nativeBuffer); 1510 mainBuffer.write(nativeBuffer);
1514 1511
1515 metadataEmitter.emitMetadata(mainBuffer); 1512 metadataEmitter.emitMetadata(mainBuffer);
1516 1513
1517 isolateProperties = isolatePropertiesName; 1514 isolateProperties = isolatePropertiesName;
1518 // The following code should not use the short-hand for the 1515 // The following code should not use the short-hand for the
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 2030 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
2034 if (element.isInstanceMember) { 2031 if (element.isInstanceMember) {
2035 cachedClassBuilders.remove(element.enclosingClass); 2032 cachedClassBuilders.remove(element.enclosingClass);
2036 2033
2037 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 2034 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
2038 2035
2039 } 2036 }
2040 } 2037 }
2041 } 2038 }
2042 } 2039 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698