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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart

Issue 2875313002: Access BackendUsage through ClosedWorld (Closed)
Patch Set: Created 3 years, 7 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.startup_emitter.model_emitter; 5 part of dart2js.js_emitter.startup_emitter.model_emitter;
6 6
7 /// The name of the property that stores the tear-off getter on a static 7 /// The name of the property that stores the tear-off getter on a static
8 /// function. 8 /// function.
9 /// 9 ///
10 /// This property is only used when isolates are used. 10 /// This property is only used when isolates are used.
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 * loaded dynamically when a deferred library is loaded. 480 * loaded dynamically when a deferred library is loaded.
481 * 481 *
482 * This class is stateless and can be reused for different fragments. 482 * This class is stateless and can be reused for different fragments.
483 */ 483 */
484 class FragmentEmitter { 484 class FragmentEmitter {
485 final Compiler compiler; 485 final Compiler compiler;
486 final Namer namer; 486 final Namer namer;
487 final JavaScriptBackend backend; 487 final JavaScriptBackend backend;
488 final ConstantEmitter constantEmitter; 488 final ConstantEmitter constantEmitter;
489 final ModelEmitter modelEmitter; 489 final ModelEmitter modelEmitter;
490 final InterceptorData _interceptorData; 490 final ClosedWorld _closedWorld;
491 491
492 FragmentEmitter(this.compiler, this.namer, this.backend, this.constantEmitter, 492 FragmentEmitter(this.compiler, this.namer, this.backend, this.constantEmitter,
493 this.modelEmitter, this._interceptorData); 493 this.modelEmitter, this._closedWorld);
494
495 InterceptorData get _interceptorData => _closedWorld.interceptorData;
494 496
495 js.Expression generateEmbeddedGlobalAccess(String global) => 497 js.Expression generateEmbeddedGlobalAccess(String global) =>
496 modelEmitter.generateEmbeddedGlobalAccess(global); 498 modelEmitter.generateEmbeddedGlobalAccess(global);
497 499
498 js.Expression generateConstantReference(ConstantValue value) => 500 js.Expression generateConstantReference(ConstantValue value) =>
499 modelEmitter.generateConstantReference(value); 501 modelEmitter.generateConstantReference(value);
500 502
501 js.Expression classReference(Class cls) { 503 js.Expression classReference(Class cls) {
502 return js.js('#.#', [cls.holder.name, cls.name]); 504 return js.js('#.#', [cls.holder.name, cls.name]);
503 } 505 }
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 /// JavaScript object literals that contain all the information directly. 1505 /// JavaScript object literals that contain all the information directly.
1504 /// This means that the output size is bigger, but that the startup is faster. 1506 /// This means that the output size is bigger, but that the startup is faster.
1505 /// 1507 ///
1506 /// This function is the static equivalent of 1508 /// This function is the static equivalent of
1507 /// [NativeGenerator.buildNativeInfoHandler]. 1509 /// [NativeGenerator.buildNativeInfoHandler].
1508 js.Statement emitNativeSupport(Fragment fragment) { 1510 js.Statement emitNativeSupport(Fragment fragment) {
1509 List<js.Statement> statements = <js.Statement>[]; 1511 List<js.Statement> statements = <js.Statement>[];
1510 1512
1511 // The isolate-affinity tag must only be initialized once per program. 1513 // The isolate-affinity tag must only be initialized once per program.
1512 if (fragment.isMainFragment && 1514 if (fragment.isMainFragment &&
1513 NativeGenerator.needsIsolateAffinityTagInitialization(backend)) { 1515 NativeGenerator
1516 .needsIsolateAffinityTagInitialization(_closedWorld.backendUsage)) {
1514 statements.add(NativeGenerator.generateIsolateAffinityTagInitialization( 1517 statements.add(NativeGenerator.generateIsolateAffinityTagInitialization(
1515 backend, 1518 _closedWorld.backendUsage,
1516 generateEmbeddedGlobalAccess, 1519 generateEmbeddedGlobalAccess,
1517 js.js( 1520 js.js(
1518 """ 1521 """
1519 // On V8, the 'intern' function converts a string to a symbol, which 1522 // On V8, the 'intern' function converts a string to a symbol, which
1520 // makes property access much faster. 1523 // makes property access much faster.
1521 function (s) { 1524 function (s) {
1522 var o = {}; 1525 var o = {};
1523 o[s] = 1; 1526 o[s] = 1;
1524 return Object.keys(convertToFastObject(o))[0]; 1527 return Object.keys(convertToFastObject(o))[0];
1525 }""", 1528 }""",
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 } 1563 }
1561 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", 1564 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);",
1562 js.objectLiteral(interceptorsByTag))); 1565 js.objectLiteral(interceptorsByTag)));
1563 statements.add( 1566 statements.add(
1564 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); 1567 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags)));
1565 statements.addAll(subclassAssignments); 1568 statements.addAll(subclassAssignments);
1566 1569
1567 return wrapPhase('nativeSupport', statements); 1570 return wrapPhase('nativeSupport', statements);
1568 } 1571 }
1569 } 1572 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698