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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart

Issue 1220793012: Revert "Fix runtimeType.toString for tear-offs." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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) 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 library dart2js.new_js_emitter.model_emitter; 5 library dart2js.new_js_emitter.model_emitter;
6 6
7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue;
8 import '../../dart2jslib.dart' show Compiler; 8 import '../../dart2jslib.dart' show Compiler;
9 import '../../elements/elements.dart' show ClassElement, FunctionElement; 9 import '../../elements/elements.dart' show ClassElement, FunctionElement;
10 import '../../js/js.dart' as js; 10 import '../../js/js.dart' as js;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 final NativeEmitter nativeEmitter; 81 final NativeEmitter nativeEmitter;
82 82
83 JavaScriptBackend get backend => compiler.backend; 83 JavaScriptBackend get backend => compiler.backend;
84 84
85 /// For deferred loading we communicate the initializers via this global var. 85 /// For deferred loading we communicate the initializers via this global var.
86 static const String deferredInitializersGlobal = 86 static const String deferredInitializersGlobal =
87 r"$__dart_deferred_initializers__"; 87 r"$__dart_deferred_initializers__";
88 88
89 static const String deferredExtension = "part.js"; 89 static const String deferredExtension = "part.js";
90 90
91 static const String typeNameProperty = r"builtin$cls";
92
91 ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter) 93 ModelEmitter(Compiler compiler, Namer namer, this.nativeEmitter)
92 : this.compiler = compiler, 94 : this.compiler = compiler,
93 this.namer = namer { 95 this.namer = namer {
94 96
95 this.constantEmitter = new ConstantEmitter( 97 this.constantEmitter = new ConstantEmitter(
96 compiler, namer, this.generateConstantReference, 98 compiler, namer, this.generateConstantReference,
97 constantListGenerator); 99 constantListGenerator);
98 } 100 }
99 101
100 js.Expression constantListGenerator(js.Expression array) { 102 js.Expression constantListGenerator(js.Expression array) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 471 }
470 472
471 static final String readMetadataTypeName = "readMetadataType"; 473 static final String readMetadataTypeName = "readMetadataType";
472 474
473 js.Statement get readMetadataTypeFunction { 475 js.Statement get readMetadataTypeFunction {
474 // Types are non-evaluated and must be compiled at first use. 476 // Types are non-evaluated and must be compiled at first use.
475 // Compiled strings are guaranteed not to be strings, and it's thus safe 477 // Compiled strings are guaranteed not to be strings, and it's thus safe
476 // to use a type-test to determine if a type has already been compiled. 478 // to use a type-test to determine if a type has already been compiled.
477 return js.js.statement('''function $readMetadataTypeName(index) { 479 return js.js.statement('''function $readMetadataTypeName(index) {
478 var type = #typesAccess[index]; 480 var type = #typesAccess[index];
479 if (typeof type == "string") { 481 if (typeof type == 'string') {
480 type = expressionCompile(type); 482 type = expressionCompile(type);
481 #typesAccess[index] = type; 483 #typesAccess[index] = type;
482 } 484 }
483 return type; 485 return type;
484 }''', {"typesAccess": generateEmbeddedGlobalAccess(TYPES)}); 486 }''', {"typesAccess": generateEmbeddedGlobalAccess(TYPES)});
485 } 487 }
486 488
487 js.Template get templateForReadType { 489 js.Template get templateForReadType {
488 // TODO(floitsch): make sure that no local variable shadows the access to 490 // TODO(floitsch): make sure that no local variable shadows the access to
489 // the readMetadataType function. 491 // the readMetadataType function.
490 return js.js.expressionTemplateFor('$readMetadataTypeName(#)'); 492 return js.js.expressionTemplateFor('$readMetadataTypeName(#)');
491 } 493 }
492 494
493 static final String readMetadataName = "readLazyMetadata"; 495 static final String readMetadataName = "readLazyMetadata";
494 static final String lazyMetadataName = "lazy_$METADATA"; 496 static final String lazyMetadataName = "lazy_$METADATA";
495 497
496 js.Statement get readMetadataFunction { 498 js.Statement get readMetadataFunction {
497 // Types are non-evaluated and must be compiled at first use. 499 // Types are non-evaluated and must be compiled at first use.
498 // Compiled strings are guaranteed not to be strings, and it's thus safe 500 // Compiled strings are guaranteed not to be strings, and it's thus safe
499 // to use a type-test to determine if a type has already been compiled. 501 // to use a type-test to determine if a type has already been compiled.
500 return js.js.statement('''function $readMetadataName(index) { 502 return js.js.statement('''function $readMetadataName(index) {
501 var lazyMetadata = #lazyMetadataAccess[index]; 503 var lazyMetadata = #lazyMetadataAccess[index];
502 if (typeof lazyMetadata == "string") { 504 if (typeof lazyMetadata == 'string') {
503 #metadataAccess[index] = expressionCompile(lazyMetadata); 505 #metadataAccess[index] = expressionCompile(lazyMetadata);
504 #lazyMetadataAccess[index] = null; 506 #lazyMetadataAccess[index] = null;
505 } 507 }
506 return #metadataAccess[index]; 508 return #metadataAccess[index];
507 }''', { 509 }''', {
508 "lazyMetadataAccess": generateEmbeddedGlobalAccess(lazyMetadataName), 510 "lazyMetadataAccess": generateEmbeddedGlobalAccess(lazyMetadataName),
509 "metadataAccess": generateEmbeddedGlobalAccess(METADATA) 511 "metadataAccess": generateEmbeddedGlobalAccess(METADATA)
510 }); 512 });
511 } 513 }
512 514
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // We assume that all constants are in the same holder. 1011 // We assume that all constants are in the same holder.
1010 var holder = holders[constants[0]]; 1012 var holder = holders[constants[0]];
1011 for (var i = 1; i < constants.length; i += 2) { 1013 for (var i = 1; i < constants.length; i += 2) {
1012 var name = constants[i]; 1014 var name = constants[i];
1013 var initializer = constants[i + 1]; 1015 var initializer = constants[i + 1];
1014 setupConstant(name, holder, initializer); 1016 setupConstant(name, holder, initializer);
1015 } 1017 }
1016 } 1018 }
1017 1019
1018 function setupStatic(name, holder, descriptor, typesOffset) { 1020 function setupStatic(name, holder, descriptor, typesOffset) {
1019 if (typeof descriptor == "string") { 1021 if (typeof descriptor == 'string') {
1020 holder[name] = function() { 1022 holder[name] = function() {
1021 if (descriptor == null) { 1023 if (descriptor == null) {
1022 // Already compiled. This happens when we have calls to the static as 1024 // Already compiled. This happens when we have calls to the static as
1023 // arguments to the static: `foo(foo(499))`; 1025 // arguments to the static: `foo(foo(499))`;
1024 return holder[name].apply(this, arguments); 1026 return holder[name].apply(this, arguments);
1025 } 1027 }
1026 var method = compile(name, descriptor); 1028 var method = compile(name, descriptor);
1027 holder[name] = method; 1029 holder[name] = method;
1028 descriptor = null; // GC the descriptor. 1030 descriptor = null; // GC the descriptor.
1029 return method.apply(this, arguments); 1031 return method.apply(this, arguments);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 } else { 1178 } else {
1177 constructor = descriptor[2]; 1179 constructor = descriptor[2];
1178 functionsIndex = 3; 1180 functionsIndex = 3;
1179 } 1181 }
1180 1182
1181 for (var i = functionsIndex; i < descriptor.length; i += 2) { 1183 for (var i = functionsIndex; i < descriptor.length; i += 2) {
1182 parseFunctionDescriptor(prototype, descriptor[i], descriptor[i + 1], 1184 parseFunctionDescriptor(prototype, descriptor[i], descriptor[i + 1],
1183 typesOffset); 1185 typesOffset);
1184 } 1186 }
1185 1187
1186 if (typeof constructor.name != "string") { 1188 constructor.$typeNameProperty = name; // Needed for RTI.
1187 // IE does not store the name, but allows to modify the property.
1188 constructor.name = name;
1189 }
1190 constructor.prototype = prototype; 1189 constructor.prototype = prototype;
1191 prototype[#operatorIsPrefix + name] = constructor; 1190 prototype[#operatorIsPrefix + name] = constructor;
1192 prototype.constructor = constructor; 1191 prototype.constructor = constructor;
1193 return constructor; 1192 return constructor;
1194 } 1193 }
1195 1194
1196 function fillPrototypeWithMixedIn(mixinName, mixinHolderIndex, prototype) { 1195 function fillPrototypeWithMixedIn(mixinName, mixinHolderIndex, prototype) {
1197 var mixin = holders[mixinHolderIndex][mixinName].ensureResolved(); 1196 var mixin = holders[mixinHolderIndex][mixinName].ensureResolved();
1198 var mixinPrototype = mixin.prototype; 1197 var mixinPrototype = mixin.prototype;
1199 1198
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 1276
1278 var end = Date.now(); 1277 var end = Date.now();
1279 // print('Setup: ' + (end - start) + ' ms.'); 1278 // print('Setup: ' + (end - start) + ' ms.');
1280 1279
1281 #invokeMain; // Start main. 1280 #invokeMain; // Start main.
1282 1281
1283 })(Date.now(), #code) 1282 })(Date.now(), #code)
1284 }"""; 1283 }""";
1285 1284
1286 } 1285 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/new_emitter/emitter.dart ('k') | pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698