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

Unified Diff: pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart

Issue 1253443003: dart2js: Support const symbols in the startup emitter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update comment. Created 5 years, 4 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
Index: pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
index 7174c460f4565a065a9dd3cca15ce35fa6412063..7e981fc8796a42d87a92ece02349e8c2fbb3341b 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
@@ -82,6 +82,13 @@ class ProgramBuilder {
/// update field-initializers to point to the ConstantModel.
final Map<ConstantValue, Constant> _constants = <ConstantValue, Constant>{};
+ /// Mapping from names to strings.
+ ///
+ /// This mapping is used to support `const Symbol` expressions.
+ ///
+ /// This map is filled when building classes.
+ final Map<js.Name, String> _symbolsMap = <js.Name, String>{};
+
Set<Class> _unneededNativeClasses;
Program buildProgram({bool storeFunctionTypesInMetadata: false}) {
@@ -162,6 +169,7 @@ class ProgramBuilder {
fragments,
holders,
_buildLoadMap(),
+ _symbolsMap,
_buildTypeToInterceptorMap(),
_task.metadataCollector,
finalizers,
@@ -394,10 +402,17 @@ class ProgramBuilder {
runtimeTypeGenerator.generateTypeVariableReaderStubs(element);
List<StubMethod> noSuchMethodStubs = <StubMethod>[];
+
if (backend.enabledNoSuchMethod && element == _compiler.objectClass) {
Map<js.Name, Selector> selectors =
classStubGenerator.computeSelectorsForNsmHandlers();
selectors.forEach((js.Name name, Selector selector) {
+ // If the program contains `const Symbol` names we have to retain them.
+ String selectorName = selector.name;
+ if (selector.isSetter) selectorName = "$selectorName=";
+ if (backend.symbolsUsed.contains(selectorName)) {
+ _symbolsMap[name] = selectorName;
+ }
noSuchMethodStubs
.add(classStubGenerator.generateStubForNoSuchMethod(name,
selector));
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/model.dart ('k') | pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698