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

Unified Diff: pkg/compiler/lib/src/js_emitter/full_emitter/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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index e47b9f1abbdbc1751a7ba40a782fa58029a99678..faa524458558685d4939bbbc3f80cac70608733d 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -577,22 +577,19 @@ class Emitter extends js_emitter.EmitterBase {
// constructor-functions and getter/setter functions can be stored in the
// library-description table. Setting properties on these can be moved to
// finishClasses.
- return js.statement(
- r"""
+ return js.statement(r"""
#precompiled = function ($collectedClasses$) {
#norename;
var $desc;
#functions;
return #result;
- };""",
- {
- 'norename': new jsAst.Comment("// ::norenaming:: "),
- 'precompiled':
- generateEmbeddedGlobalAccess(embeddedNames.PRECOMPILED),
- 'functions': cspPrecompiledFunctionFor(outputUnit),
- 'result': new jsAst.ArrayInitializer(
- cspPrecompiledConstructorNamesFor(outputUnit))
- });
+ };""", {
+ 'norename': new jsAst.Comment("// ::norenaming:: "),
+ 'precompiled': generateEmbeddedGlobalAccess(embeddedNames.PRECOMPILED),
+ 'functions': cspPrecompiledFunctionFor(outputUnit),
+ 'result': new jsAst.ArrayInitializer(
+ cspPrecompiledConstructorNamesFor(outputUnit))
+ });
} else {
return js.comment("Constructors are generated at runtime.");
}
@@ -671,8 +668,7 @@ class Emitter extends js_emitter.EmitterBase {
needsLazyInitializer = true;
List<jsAst.Expression> laziesInfo =
buildLaziesInfo(lazyFields, isMainFragment);
- return js.statement(
- '''
+ return js.statement('''
(function(lazies) {
for (var i = 0; i < lazies.length; ) {
var fieldName = lazies[i++];
@@ -703,14 +699,13 @@ class Emitter extends js_emitter.EmitterBase {
}
}
})(#laziesInfo)
- ''',
- {
- 'notMinified': !compiler.options.enableMinification,
- 'laziesInfo': new jsAst.ArrayInitializer(laziesInfo),
- 'lazy': js(lazyInitializerName),
- 'isMainFragment': isMainFragment,
- 'isDeferredFragment': !isMainFragment
- });
+ ''', {
+ 'notMinified': !compiler.options.enableMinification,
+ 'laziesInfo': new jsAst.ArrayInitializer(laziesInfo),
+ 'lazy': js(lazyInitializerName),
+ 'isMainFragment': isMainFragment,
+ 'isDeferredFragment': !isMainFragment
+ });
} else {
return js.comment("No lazy statics.");
}
@@ -785,8 +780,7 @@ class Emitter extends js_emitter.EmitterBase {
jsAst.Statement buildMakeConstantList(bool outputContainsConstantList) {
if (outputContainsConstantList) {
- return js.statement(
- r'''
+ return js.statement(r'''
// Functions are stored in the hidden class and not as properties in
// the object. We never actually look at the value, but only want
// to know if the property exists.
@@ -794,8 +788,7 @@ class Emitter extends js_emitter.EmitterBase {
list.immutable$list = Array;
list.fixed$length = Array;
return list;
- }''',
- [namer.isolateName, makeConstListProperty]);
+ }''', [namer.isolateName, makeConstListProperty]);
} else {
return js.comment("Output contains no constant list.");
}
@@ -819,18 +812,14 @@ class Emitter extends js_emitter.EmitterBase {
if (NativeGenerator
.needsIsolateAffinityTagInitialization(_closedWorld.backendUsage)) {
parts.add(NativeGenerator.generateIsolateAffinityTagInitialization(
- _closedWorld.backendUsage,
- generateEmbeddedGlobalAccess,
- js(
- """
+ _closedWorld.backendUsage, generateEmbeddedGlobalAccess, js("""
// On V8, the 'intern' function converts a string to a symbol, which
// makes property access much faster.
function (s) {
var o = {};
o[s] = 1;
return Object.keys(convertToFastObject(o))[0];
- }""",
- [])));
+ }""", [])));
}
parts
@@ -857,8 +846,7 @@ class Emitter extends js_emitter.EmitterBase {
jsAst.Expression laziesAccess =
generateEmbeddedGlobalAccess(embeddedNames.LAZIES);
- return js.statement(
- '''
+ return js.statement('''
function init() {
$isolatePropertiesName = Object.create(null);
#allClasses = map();
@@ -962,22 +950,21 @@ class Emitter extends js_emitter.EmitterBase {
return Isolate;
}
- }''',
- {
- 'allClasses': allClassesAccess,
- 'getTypeFromName': getTypeFromNameAccess,
- 'interceptorsByTag': interceptorsByTagAccess,
- 'leafTags': leafTagsAccess,
- 'finishedClasses': finishedClassesAccess,
- 'needsLazyInitializer': needsLazyInitializer,
- 'lazies': laziesAccess,
- 'cyclicThrow': cyclicThrow,
- 'isolatePropertiesName': namer.isolatePropertiesName,
- 'outputContainsConstantList': outputContainsConstantList,
- 'makeConstListProperty': makeConstListProperty,
- 'functionThatReturnsNullProperty':
- backend.rtiEncoder.getFunctionThatReturnsNullName,
- });
+ }''', {
+ 'allClasses': allClassesAccess,
+ 'getTypeFromName': getTypeFromNameAccess,
+ 'interceptorsByTag': interceptorsByTagAccess,
+ 'leafTags': leafTagsAccess,
+ 'finishedClasses': finishedClassesAccess,
+ 'needsLazyInitializer': needsLazyInitializer,
+ 'lazies': laziesAccess,
+ 'cyclicThrow': cyclicThrow,
+ 'isolatePropertiesName': namer.isolatePropertiesName,
+ 'outputContainsConstantList': outputContainsConstantList,
+ 'makeConstListProperty': makeConstListProperty,
+ 'functionThatReturnsNullProperty':
+ backend.rtiEncoder.getFunctionThatReturnsNullName,
+ });
}
jsAst.Statement buildConvertToFastObjectFunction() {
@@ -996,8 +983,7 @@ class Emitter extends js_emitter.EmitterBase {
}'''));
}
- return js.statement(
- r'''
+ return js.statement(r'''
function convertToFastObject(properties) {
// Create an instance that uses 'properties' as prototype. This should
// make 'properties' a fast object.
@@ -1006,8 +992,7 @@ class Emitter extends js_emitter.EmitterBase {
new MyClass();
#;
return properties;
- }''',
- [debugCode]);
+ }''', [debugCode]);
}
jsAst.Statement buildConvertToSlowObjectFunction() {
@@ -1262,15 +1247,13 @@ class Emitter extends js_emitter.EmitterBase {
'''));
for (String object in Namer.userGlobalObjects) {
- parts.add(js.statement(
- '''
+ parts.add(js.statement('''
if (typeof print === "function") {
print("Size of " + #objectString + ": "
+ String(Object.getOwnPropertyNames(#object).length)
+ ", fast properties " + HasFastProperties(#object));
}
- ''',
- {"object": object, "objectString": js.string(object)}));
+ ''', {"object": object, "objectString": js.string(object)}));
}
}
@@ -1403,8 +1386,7 @@ class Emitter extends js_emitter.EmitterBase {
// Using a named function here produces easier to read stack traces in
// Chrome/V8.
- statements.add(js.statement(
- """
+ statements.add(js.statement("""
(function() {
// No renaming in the top-level function to save the locals for the
// nested context where they will be used more. We have to put the
@@ -1501,48 +1483,44 @@ class Emitter extends js_emitter.EmitterBase {
#main;
})();
- """,
- {
- "disableVariableRenaming": js.comment("/* ::norenaming:: */"),
- "isProgramSplit": isProgramSplit,
- "supportsDirectProtoAccess": buildSupportsDirectProtoAccess(),
- "globalsHolder": globalsHolder,
- "globalObjectSetup": buildGlobalObjectSetup(isProgramSplit),
- "isolateName": namer.isolateName,
- "isolatePropertiesName": js(isolatePropertiesName),
- "initName": initName,
- "functionThatReturnsNull": buildFunctionThatReturnsNull(),
- "mangledNames": buildMangledNames(),
- "setupProgram": buildSetupProgram(
- program, compiler, backend, namer, this, _closedWorld),
- "setupProgramName": setupProgramName,
- "descriptors": descriptorsAst,
- "cspPrecompiledFunctions":
- buildCspPrecompiledFunctionFor(mainOutputUnit),
- "getInterceptorMethods":
- interceptorEmitter.buildGetInterceptorMethods(),
- "oneShotInterceptors": interceptorEmitter.buildOneShotInterceptors(),
- "makeConstantList":
- buildMakeConstantList(program.outputContainsConstantList),
- "compileTimeConstants": buildCompileTimeConstants(
- mainFragment.constants,
- isMainFragment: true),
- "deferredBoilerPlate": buildDeferredBoilerPlate(deferredLoadHashes),
- "staticNonFinalInitializers":
- buildStaticNonFinalFieldInitializations(mainOutputUnit),
- "typeToInterceptorMap":
- interceptorEmitter.buildTypeToInterceptorMap(program),
- "lazyStaticFields": buildLazilyInitializedStaticFields(
- mainFragment.staticLazilyInitializedFields),
- "metadata": buildMetadata(program, mainOutputUnit),
- "convertToFastObject": buildConvertToFastObjectFunction(),
- "convertToSlowObject": buildConvertToSlowObjectFunction(),
- "convertGlobalObjectsToFastObjects":
- buildConvertGlobalObjectToFastObjects(),
- "debugFastObjects": buildDebugFastObjectCode(),
- "init": buildInitFunction(program.outputContainsConstantList),
- "main": buildMain(mainFragment.invokeMain)
- }));
+ """, {
+ "disableVariableRenaming": js.comment("/* ::norenaming:: */"),
+ "isProgramSplit": isProgramSplit,
+ "supportsDirectProtoAccess": buildSupportsDirectProtoAccess(),
+ "globalsHolder": globalsHolder,
+ "globalObjectSetup": buildGlobalObjectSetup(isProgramSplit),
+ "isolateName": namer.isolateName,
+ "isolatePropertiesName": js(isolatePropertiesName),
+ "initName": initName,
+ "functionThatReturnsNull": buildFunctionThatReturnsNull(),
+ "mangledNames": buildMangledNames(),
+ "setupProgram": buildSetupProgram(
+ program, compiler, backend, namer, this, _closedWorld),
+ "setupProgramName": setupProgramName,
+ "descriptors": descriptorsAst,
+ "cspPrecompiledFunctions": buildCspPrecompiledFunctionFor(mainOutputUnit),
+ "getInterceptorMethods": interceptorEmitter.buildGetInterceptorMethods(),
+ "oneShotInterceptors": interceptorEmitter.buildOneShotInterceptors(),
+ "makeConstantList":
+ buildMakeConstantList(program.outputContainsConstantList),
+ "compileTimeConstants": buildCompileTimeConstants(mainFragment.constants,
+ isMainFragment: true),
+ "deferredBoilerPlate": buildDeferredBoilerPlate(deferredLoadHashes),
+ "staticNonFinalInitializers":
+ buildStaticNonFinalFieldInitializations(mainOutputUnit),
+ "typeToInterceptorMap":
+ interceptorEmitter.buildTypeToInterceptorMap(program),
+ "lazyStaticFields": buildLazilyInitializedStaticFields(
+ mainFragment.staticLazilyInitializedFields),
+ "metadata": buildMetadata(program, mainOutputUnit),
+ "convertToFastObject": buildConvertToFastObjectFunction(),
+ "convertToSlowObject": buildConvertToSlowObjectFunction(),
+ "convertGlobalObjectsToFastObjects":
+ buildConvertGlobalObjectToFastObjects(),
+ "debugFastObjects": buildDebugFastObjectCode(),
+ "init": buildInitFunction(program.outputContainsConstantList),
+ "main": buildMain(mainFragment.invokeMain)
+ }));
return new jsAst.Program(statements);
}
@@ -1717,8 +1695,7 @@ class Emitter extends js_emitter.EmitterBase {
Map<OutputUnit, _DeferredOutputUnitHash> deferredLoadHashes) {
List<jsAst.Statement> parts = <jsAst.Statement>[];
- parts.add(js.statement(
- '''
+ parts.add(js.statement('''
{
// Function for checking if a hunk is loaded given its hash.
#isHunkLoaded = function(hunkHash) {
@@ -1736,18 +1713,17 @@ class Emitter extends js_emitter.EmitterBase {
#deferredInitialized[hunkHash] = true;
};
}
- ''',
- {
- "globalsHolder": globalsHolder,
- "isHunkLoaded":
- generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED),
- "isHunkInitialized":
- generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_INITIALIZED),
- "initializeLoadedHunk": generateEmbeddedGlobalAccess(
- embeddedNames.INITIALIZE_LOADED_HUNK),
- "deferredInitialized":
- generateEmbeddedGlobalAccess(embeddedNames.DEFERRED_INITIALIZED)
- }));
+ ''', {
+ "globalsHolder": globalsHolder,
+ "isHunkLoaded":
+ generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_LOADED),
+ "isHunkInitialized":
+ generateEmbeddedGlobalAccess(embeddedNames.IS_HUNK_INITIALIZED),
+ "initializeLoadedHunk":
+ generateEmbeddedGlobalAccess(embeddedNames.INITIALIZE_LOADED_HUNK),
+ "deferredInitialized":
+ generateEmbeddedGlobalAccess(embeddedNames.DEFERRED_INITIALIZED)
+ }));
// Write a javascript mapping from Deferred import load ids (derrived
// from the import prefix.) to a list of lists of uris of hunks to load,

Powered by Google App Engine
This is Rietveld 408576698