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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/setup_program_builder.dart

Issue 2814453005: Merge CommonElements and BackendHelpers! (Closed)
Patch Set: comments and re-merge, take two Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.full_emitter; 5 part of dart2js.js_emitter.full_emitter;
6 6
7 // TODO(ahe): Share these with js_helper.dart. 7 // TODO(ahe): Share these with js_helper.dart.
8 const FUNCTION_INDEX = 0; 8 const FUNCTION_INDEX = 0;
9 const NAME_INDEX = 1; 9 const NAME_INDEX = 1;
10 const CALL_NAME_INDEX = 2; 10 const CALL_NAME_INDEX = 2;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 'initializeEmptyInstance': initializeEmptyInstanceAccess, 119 'initializeEmptyInstance': initializeEmptyInstanceAccess,
120 'allClasses': allClassesAccess, 120 'allClasses': allClassesAccess,
121 'debugFastObjects': DEBUG_FAST_OBJECTS, 121 'debugFastObjects': DEBUG_FAST_OBJECTS,
122 'isTreeShakingDisabled': backend.mirrorsData.isTreeShakingDisabled, 122 'isTreeShakingDisabled': backend.mirrorsData.isTreeShakingDisabled,
123 'precompiled': precompiledAccess, 123 'precompiled': precompiledAccess,
124 'finishedClassesAccess': finishedClassesAccess, 124 'finishedClassesAccess': finishedClassesAccess,
125 'needsMixinSupport': emitter.needsMixinSupport, 125 'needsMixinSupport': emitter.needsMixinSupport,
126 'needsNativeSupport': program.needsNativeSupport, 126 'needsNativeSupport': program.needsNativeSupport,
127 'enabledJsInterop': backend.jsInteropAnalysis.enabledJsInterop, 127 'enabledJsInterop': backend.jsInteropAnalysis.enabledJsInterop,
128 'jsInteropBoostrap': backend.jsInteropAnalysis.buildJsInteropBootstrap(), 128 'jsInteropBoostrap': backend.jsInteropAnalysis.buildJsInteropBootstrap(),
129 'isInterceptorClass': namer.operatorIs(backend.helpers.jsInterceptorClass), 129 'isInterceptorClass':
130 namer.operatorIs(compiler.commonElements.jsInterceptorClass),
130 'isObject': namer.operatorIs(compiler.commonElements.objectClass), 131 'isObject': namer.operatorIs(compiler.commonElements.objectClass),
131 'specProperty': js.string(namer.nativeSpecProperty), 132 'specProperty': js.string(namer.nativeSpecProperty),
132 'trivialNsmHandlers': emitter.buildTrivialNsmHandlers(), 133 'trivialNsmHandlers': emitter.buildTrivialNsmHandlers(),
133 'hasRetainedMetadata': backend.mirrorsData.hasRetainedMetadata, 134 'hasRetainedMetadata': backend.mirrorsData.hasRetainedMetadata,
134 'types': typesAccess, 135 'types': typesAccess,
135 'objectClassName': js.quoteName(namer.runtimeTypeName( 136 'objectClassName': js.quoteName(namer.runtimeTypeName(
136 // ignore: UNNECESSARY_CAST 137 // ignore: UNNECESSARY_CAST
137 compiler.commonElements.objectClass as Entity)), 138 compiler.commonElements.objectClass as Entity)),
138 'needsStructuredMemberInfo': emitter.needsStructuredMemberInfo, 139 'needsStructuredMemberInfo': emitter.needsStructuredMemberInfo,
139 'usesMangledNames': compiler.commonElements.mirrorsLibrary != null || 140 'usesMangledNames': compiler.commonElements.mirrorsLibrary != null ||
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 prototype.#deferredAction(); 435 prototype.#deferredAction();
435 } 436 }
436 } 437 }
437 438
438 #trivialNsmHandlers; 439 #trivialNsmHandlers;
439 440
440 var properties = Object.keys(processedClasses.pending); 441 var properties = Object.keys(processedClasses.pending);
441 for (var i = 0; i < properties.length; i++) finishClass(properties[i]); 442 for (var i = 0; i < properties.length; i++) finishClass(properties[i]);
442 } 443 }
443 444
444 // Generic handler for deferred class setup. The handler updates the 445 // Generic handler for deferred class setup. The handler updates the
445 // prototype that it is installed on (it traverses the prototype chain 446 // prototype that it is installed on (it traverses the prototype chain
446 // of [this] to find itself) and then removes itself. It recurses by 447 // of [this] to find itself) and then removes itself. It recurses by
447 // calling deferred handling again, which terminates on Object due to 448 // calling deferred handling again, which terminates on Object due to
448 // the final handler. 449 // the final handler.
449 function finishAddStubsHelper() { 450 function finishAddStubsHelper() {
450 var prototype = this; 451 var prototype = this;
451 // Find the actual prototype that this handler is installed on. 452 // Find the actual prototype that this handler is installed on.
452 while (!prototype.hasOwnProperty(#deferredActionString)) { 453 while (!prototype.hasOwnProperty(#deferredActionString)) {
453 prototype = prototype.__proto__; 454 prototype = prototype.__proto__;
454 } 455 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 var mangledNames = isStatic ? #mangledGlobalNames : #mangledNames; 728 var mangledNames = isStatic ? #mangledGlobalNames : #mangledNames;
728 var unmangledName = ${readString("array", "unmangledNameIndex")}; 729 var unmangledName = ${readString("array", "unmangledNameIndex")};
729 // The function is either a getter, a setter, or a method. 730 // The function is either a getter, a setter, or a method.
730 // If it is a method, it might also have a tear-off closure. 731 // If it is a method, it might also have a tear-off closure.
731 // The unmangledName is the same as the getter-name. 732 // The unmangledName is the same as the getter-name.
732 var reflectionName = unmangledName; 733 var reflectionName = unmangledName;
733 if (getterStubName) mangledNames[getterStubName] = reflectionName; 734 if (getterStubName) mangledNames[getterStubName] = reflectionName;
734 if (isSetter) { 735 if (isSetter) {
735 reflectionName += "="; 736 reflectionName += "=";
736 } else if (!isGetter) { 737 } else if (!isGetter) {
737 reflectionName += ":" + 738 reflectionName += ":" +
738 (requiredParameterCount + optionalParameterCount); 739 (requiredParameterCount + optionalParameterCount);
739 } 740 }
740 mangledNames[name] = reflectionName; 741 mangledNames[name] = reflectionName;
741 funcs[0].$reflectionNameField = reflectionName; 742 funcs[0].$reflectionNameField = reflectionName;
742 funcs[0].$metadataIndexField = unmangledNameIndex + 1; 743 funcs[0].$metadataIndexField = unmangledNameIndex + 1;
743 // The following line installs the [${JsGetName.CALL_CATCH_ALL}] 744 // The following line installs the [${JsGetName.CALL_CATCH_ALL}]
744 // property for closures. 745 // property for closures.
745 if (optionalParameterCount) prototype[unmangledName + "*"] = funcs[0]; 746 if (optionalParameterCount) prototype[unmangledName + "*"] = funcs[0];
746 } 747 }
747 } 748 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 (function() { 843 (function() {
843 var result = $array[$index]; 844 var result = $array[$index];
844 if ($check) { 845 if ($check) {
845 throw new Error( 846 throw new Error(
846 name + ": expected value of type \'$type\' at index " + ($index) + 847 name + ": expected value of type \'$type\' at index " + ($index) +
847 " but got " + (typeof result)); 848 " but got " + (typeof result));
848 } 849 }
849 return result; 850 return result;
850 })()'''; 851 })()''';
851 } 852 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698