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

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

Issue 2990223002: Reformat untouched files. (Closed)
Patch Set: Created 3 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 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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 isIntercepted = _interceptorData.isInterceptedMethod(element); 1114 isIntercepted = _interceptorData.isInterceptedMethod(element);
1115 } 1115 }
1116 int requiredParameterCount = 0; 1116 int requiredParameterCount = 0;
1117 js.Expression optionalParameterDefaultValues = new js.LiteralNull(); 1117 js.Expression optionalParameterDefaultValues = new js.LiteralNull();
1118 if (method.canBeApplied) { 1118 if (method.canBeApplied) {
1119 requiredParameterCount = method.requiredParameterCount; 1119 requiredParameterCount = method.requiredParameterCount;
1120 optionalParameterDefaultValues = 1120 optionalParameterDefaultValues =
1121 _encodeOptionalParameterDefaultValues(method); 1121 _encodeOptionalParameterDefaultValues(method);
1122 } 1122 }
1123 1123
1124 return js.js.statement( 1124 return js.js.statement('''
1125 '''
1126 installTearOff(#container, #getterName, #isStatic, #isIntercepted, 1125 installTearOff(#container, #getterName, #isStatic, #isIntercepted,
1127 #requiredParameterCount, #optionalParameterDefaultValues, 1126 #requiredParameterCount, #optionalParameterDefaultValues,
1128 #callNames, #funsOrNames, #funType)''', 1127 #callNames, #funsOrNames, #funType)''', {
1129 { 1128 "container": container,
1130 "container": container, 1129 "getterName": js.quoteName(method.tearOffName),
1131 "getterName": js.quoteName(method.tearOffName), 1130 // 'Truthy' values are ok for `isStatic` and `isIntercepted`.
1132 // 'Truthy' values are ok for `isStatic` and `isIntercepted`. 1131 "isStatic": js.number(method.isStatic ? 1 : 0),
1133 "isStatic": js.number(method.isStatic ? 1 : 0), 1132 "isIntercepted": js.number(isIntercepted ? 1 : 0),
1134 "isIntercepted": js.number(isIntercepted ? 1 : 0), 1133 "requiredParameterCount": js.number(requiredParameterCount),
1135 "requiredParameterCount": js.number(requiredParameterCount), 1134 "optionalParameterDefaultValues": optionalParameterDefaultValues,
1136 "optionalParameterDefaultValues": optionalParameterDefaultValues, 1135 "callNames": callNameArray,
1137 "callNames": callNameArray, 1136 "funsOrNames": funsOrNamesArray,
1138 "funsOrNames": funsOrNamesArray, 1137 "funType": method.functionType,
1139 "funType": method.functionType, 1138 });
1140 });
1141 } 1139 }
1142 1140
1143 /// Wraps the statement in a named function to that it shows up as a unit in 1141 /// Wraps the statement in a named function to that it shows up as a unit in
1144 /// profiles. 1142 /// profiles.
1145 // TODO(sra): Should this be conditional? 1143 // TODO(sra): Should this be conditional?
1146 js.Statement wrapPhase(String name, List<js.Statement> statements) { 1144 js.Statement wrapPhase(String name, List<js.Statement> statements) {
1147 js.Block block = new js.Block(statements); 1145 js.Block block = new js.Block(statements);
1148 if (statements.isEmpty) return block; 1146 if (statements.isEmpty) return block;
1149 return js.js.statement('(function #(){#})();', [name, block]); 1147 return js.js.statement('(function #(){#})();', [name, block]);
1150 } 1148 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 1294
1297 js.Expression isHunkInitializedFunction = js.js( 1295 js.Expression isHunkInitializedFunction = js.js(
1298 "function(hash) { return !!#deferredInitialized[hash]; }", { 1296 "function(hash) { return !!#deferredInitialized[hash]; }", {
1299 'deferredInitialized': generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED) 1297 'deferredInitialized': generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED)
1300 }); 1298 });
1301 globals.add(new js.Property( 1299 globals.add(new js.Property(
1302 js.string(IS_HUNK_INITIALIZED), isHunkInitializedFunction)); 1300 js.string(IS_HUNK_INITIALIZED), isHunkInitializedFunction));
1303 1301
1304 /// See [emitEmbeddedGlobalsForDeferredLoading] for the format of the 1302 /// See [emitEmbeddedGlobalsForDeferredLoading] for the format of the
1305 /// deferred hunk. 1303 /// deferred hunk.
1306 js.Expression initializeLoadedHunkFunction = js.js( 1304 js.Expression initializeLoadedHunkFunction = js.js("""
1307 """
1308 function(hash) { 1305 function(hash) {
1309 initializeDeferredHunk($deferredGlobal[hash]); 1306 initializeDeferredHunk($deferredGlobal[hash]);
1310 #deferredInitialized[hash] = true; 1307 #deferredInitialized[hash] = true;
1311 }""", 1308 }""", {
1312 { 1309 'deferredInitialized': generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED)
1313 'deferredInitialized': 1310 });
1314 generateEmbeddedGlobalAccess(DEFERRED_INITIALIZED)
1315 });
1316 1311
1317 globals.add(new js.Property( 1312 globals.add(new js.Property(
1318 js.string(INITIALIZE_LOADED_HUNK), initializeLoadedHunkFunction)); 1313 js.string(INITIALIZE_LOADED_HUNK), initializeLoadedHunkFunction));
1319 1314
1320 return globals; 1315 return globals;
1321 } 1316 }
1322 1317
1323 /// Emits the [MANGLED_GLOBAL_NAMES] embedded global. 1318 /// Emits the [MANGLED_GLOBAL_NAMES] embedded global.
1324 /// 1319 ///
1325 /// This global maps minified names for selected classes (some important 1320 /// This global maps minified names for selected classes (some important
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 /// This function is the static equivalent of 1493 /// This function is the static equivalent of
1499 /// [NativeGenerator.buildNativeInfoHandler]. 1494 /// [NativeGenerator.buildNativeInfoHandler].
1500 js.Statement emitNativeSupport(Fragment fragment) { 1495 js.Statement emitNativeSupport(Fragment fragment) {
1501 List<js.Statement> statements = <js.Statement>[]; 1496 List<js.Statement> statements = <js.Statement>[];
1502 1497
1503 // The isolate-affinity tag must only be initialized once per program. 1498 // The isolate-affinity tag must only be initialized once per program.
1504 if (fragment.isMainFragment && 1499 if (fragment.isMainFragment &&
1505 NativeGenerator 1500 NativeGenerator
1506 .needsIsolateAffinityTagInitialization(_closedWorld.backendUsage)) { 1501 .needsIsolateAffinityTagInitialization(_closedWorld.backendUsage)) {
1507 statements.add(NativeGenerator.generateIsolateAffinityTagInitialization( 1502 statements.add(NativeGenerator.generateIsolateAffinityTagInitialization(
1508 _closedWorld.backendUsage, 1503 _closedWorld.backendUsage, generateEmbeddedGlobalAccess, js.js("""
1509 generateEmbeddedGlobalAccess,
1510 js.js(
1511 """
1512 // On V8, the 'intern' function converts a string to a symbol, which 1504 // On V8, the 'intern' function converts a string to a symbol, which
1513 // makes property access much faster. 1505 // makes property access much faster.
1514 function (s) { 1506 function (s) {
1515 var o = {}; 1507 var o = {};
1516 o[s] = 1; 1508 o[s] = 1;
1517 return Object.keys(convertToFastObject(o))[0]; 1509 return Object.keys(convertToFastObject(o))[0];
1518 }""", 1510 }""", [])));
1519 [])));
1520 } 1511 }
1521 1512
1522 Map<String, js.Expression> interceptorsByTag = <String, js.Expression>{}; 1513 Map<String, js.Expression> interceptorsByTag = <String, js.Expression>{};
1523 Map<String, js.Expression> leafTags = <String, js.Expression>{}; 1514 Map<String, js.Expression> leafTags = <String, js.Expression>{};
1524 List<js.Statement> subclassAssignments = <js.Statement>[]; 1515 List<js.Statement> subclassAssignments = <js.Statement>[];
1525 1516
1526 for (Library library in fragment.libraries) { 1517 for (Library library in fragment.libraries) {
1527 for (Class cls in library.classes) { 1518 for (Class cls in library.classes) {
1528 if (cls.nativeLeafTags != null) { 1519 if (cls.nativeLeafTags != null) {
1529 for (String tag in cls.nativeLeafTags) { 1520 for (String tag in cls.nativeLeafTags) {
(...skipping 23 matching lines...) Expand all
1553 } 1544 }
1554 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);", 1545 statements.add(js.js.statement("setOrUpdateInterceptorsByTag(#);",
1555 js.objectLiteral(interceptorsByTag))); 1546 js.objectLiteral(interceptorsByTag)));
1556 statements.add( 1547 statements.add(
1557 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags))); 1548 js.js.statement("setOrUpdateLeafTags(#);", js.objectLiteral(leafTags)));
1558 statements.addAll(subclassAssignments); 1549 statements.addAll(subclassAssignments);
1559 1550
1560 return wrapPhase('nativeSupport', statements); 1551 return wrapPhase('nativeSupport', statements);
1561 } 1552 }
1562 } 1553 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/native_generator.dart ('k') | tests/compiler/dart2js/analyze_only_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698