| Index: pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart
|
| diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart
|
| index ae053a198240ea4c5c64582a17befe21e4e12937..932d105402d1c6fc2f93b900e39deae9c24e8291 100644
|
| --- a/pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart
|
| +++ b/pkg/compiler/lib/src/js_emitter/old_emitter/reflection_data_parser.dart
|
| @@ -55,24 +55,25 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
|
|
| jsAst.Statement processClassData = js.statement('''{
|
| function processClassData(cls, descriptor, processedClasses) {
|
| - var newDesc = {};
|
| + descriptor = convertToSlowObject(descriptor); // Use a slow object.
|
| var previousProperty;
|
| - for (var property in descriptor) {
|
| - if (!hasOwnProperty.call(descriptor, property)) continue;
|
| - var firstChar = property.substring(0, 1);
|
| + var properties = Object.keys(descriptor);
|
| + for (var i = 0; i < properties.length; i++) {
|
| + var property = properties[i];
|
| + var firstChar = property.charCodeAt(0);
|
| if (property === "static") {
|
| - processStatics(#embeddedStatics[cls] = descriptor[property],
|
| + processStatics(#embeddedStatics[cls] = descriptor.static,
|
| processedClasses);
|
| - } else if (firstChar === "+") {
|
| + } else if (firstChar === 43) { // 43 is "+".
|
| mangledNames[previousProperty] = property.substring(1);
|
| var flag = descriptor[property];
|
| if (flag > 0)
|
| descriptor[previousProperty].$reflectableField = flag;
|
| - } else if (firstChar === "*") {
|
| - newDesc[previousProperty].$defaultValuesField = descriptor[property];
|
| - var optionalMethods = newDesc.$methodsWithOptionalArgumentsField;
|
| + } else if (firstChar === 42) { // 42 is "*"
|
| + descriptor[previousProperty].$defaultValuesField = descriptor[property];
|
| + var optionalMethods = descriptor.$methodsWithOptionalArgumentsField;
|
| if (!optionalMethods) {
|
| - newDesc.$methodsWithOptionalArgumentsField = optionalMethods={}
|
| + descriptor.$methodsWithOptionalArgumentsField = optionalMethods={}
|
| }
|
| optionalMethods[property] = previousProperty;
|
| } else {
|
| @@ -81,9 +82,9 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| elem != null &&
|
| elem.constructor === Array &&
|
| property !== "<>") {
|
| - addStubs(newDesc, elem, property, false, descriptor, []);
|
| + addStubs(descriptor, elem, property, false, []);
|
| } else {
|
| - newDesc[previousProperty = property] = elem;
|
| + previousProperty = property;
|
| }
|
| }
|
| }
|
| @@ -94,7 +95,7 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| * 'Super;field1,field2'
|
| * from the CLASS_DESCRIPTOR_PROPERTY property on the descriptor.
|
| */
|
| - var classData = newDesc["${namer.classDescriptorProperty}"],
|
| + var classData = descriptor["${namer.classDescriptorProperty}"],
|
| split, supr, fields = classData;
|
|
|
| if (#hasRetainedMetadata)
|
| @@ -112,7 +113,7 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| supr = split[0];
|
| var functionSignature = split[1];
|
| if (functionSignature)
|
| - newDesc.${namer.operatorSignature} = function(s) {
|
| + descriptor.${namer.operatorSignature} = function(s) {
|
| return function() {
|
| return #metadata[s];
|
| };
|
| @@ -124,7 +125,7 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| processedClasses.combinedConstructorFunction += defineClass(cls, fields);
|
| processedClasses.constructorsList.push(cls);
|
| }
|
| - processedClasses.collected[cls] = [globalObject, newDesc];
|
| + processedClasses.collected[cls] = [globalObject, descriptor];
|
| classes.push(cls);
|
| }
|
| }''', {'embeddedStatics': staticsAccess,
|
| @@ -135,20 +136,21 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| // TODO(zarah): Remove empty else branches in output when if(#hole) is false.
|
| jsAst.Statement processStatics = js.statement('''
|
| function processStatics(descriptor, processedClasses) {
|
| - for (var property in descriptor) {
|
| - if (!hasOwnProperty.call(descriptor, property)) continue;
|
| + var properties = Object.keys(descriptor);
|
| + for (var i = 0; i < properties.length; i++) {
|
| + var property = properties[i];
|
| if (property === "${namer.classDescriptorProperty}") continue;
|
| var element = descriptor[property];
|
| - var firstChar = property.substring(0, 1);
|
| + var firstChar = property.charCodeAt(0);
|
| var previousProperty;
|
| - if (firstChar === "+") {
|
| + if (firstChar === 43) { // 43 is "+".
|
| mangledGlobalNames[previousProperty] = property.substring(1);
|
| var flag = descriptor[property];
|
| if (flag > 0)
|
| descriptor[previousProperty].$reflectableField = flag;
|
| if (element && element.length)
|
| #typeInformation[previousProperty] = element;
|
| - } else if (firstChar === "*") {
|
| + } else if (firstChar === 42) { // 42 is "*"
|
| globalObject[previousProperty].$defaultValuesField = element;
|
| var optionalMethods = descriptor.$methodsWithOptionalArgumentsField;
|
| if (!optionalMethods) {
|
| @@ -161,8 +163,7 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| #globalFunctions[property] = element;
|
| } else if (element.constructor === Array) {
|
| if (#needsStructuredMemberInfo) {
|
| - addStubs(globalObject, element, property,
|
| - true, descriptor, functions);
|
| + addStubs(globalObject, element, property, true, functions);
|
| }
|
| } else {
|
| // We will not enter this case if no classes are defined.
|
| @@ -184,8 +185,7 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| * [array].
|
| */
|
| jsAst.Statement addStubs = js.statement('''
|
| - function addStubs(descriptor, array, name, isStatic,
|
| - originalDescriptor, functions) {
|
| + function addStubs(descriptor, array, name, isStatic, functions) {
|
| var index = $FUNCTION_INDEX, alias = array[index], f;
|
| if (typeof alias == "string") {
|
| f = array[++index];
|
| @@ -193,8 +193,7 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| f = alias;
|
| alias = name;
|
| }
|
| - var funcs = [originalDescriptor[name] = descriptor[name] =
|
| - descriptor[alias] = f];
|
| + var funcs = [descriptor[name] = descriptor[alias] = f];
|
| f.\$stubName = name;
|
| functions.push(name);
|
| for (; index < array.length; index += 2) {
|
| @@ -203,14 +202,15 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| f.\$stubName = ${readString("array", "index + 2")};
|
| funcs.push(f);
|
| if (f.\$stubName) {
|
| - originalDescriptor[f.\$stubName] = descriptor[f.\$stubName] = f;
|
| + descriptor[f.\$stubName] = f;
|
| functions.push(f.\$stubName);
|
| }
|
| }
|
| + index++;
|
| for (var i = 0; i < funcs.length; index++, i++) {
|
| - funcs[i].\$callName = ${readString("array", "index + 1")};
|
| + funcs[i].\$callName = ${readString("array", "index")};
|
| }
|
| - var getterStubName = ${readString("array", "++index")};
|
| + var getterStubName = ${readString("array", "index")};
|
| array = array.slice(++index);
|
| var requiredParameterInfo = ${readInt("array", "0")};
|
| var requiredParameterCount = requiredParameterInfo >> 1;
|
| @@ -231,7 +231,7 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| f.\$getterStub = true;
|
| // Used to create an isolate using spawnFunction.
|
| if (isStatic) #globalFunctions[name] = f;
|
| - originalDescriptor[getterStubName] = descriptor[getterStubName] = f;
|
| + descriptor[getterStubName] = f;
|
| funcs.push(f);
|
| if (getterStubName) functions.push(getterStubName);
|
| f.\$stubName = getterStubName;
|
| @@ -297,9 +297,9 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
| var mangledGlobalNames = #mangledGlobalNames;
|
| var hasOwnProperty = Object.prototype.hasOwnProperty;
|
| var length = reflectionData.length;
|
| - var processedClasses = Object.create(null);
|
| - processedClasses.collected = Object.create(null);
|
| - processedClasses.pending = Object.create(null);
|
| + var processedClasses = map();
|
| + processedClasses.collected = map();
|
| + processedClasses.pending = map();
|
| if (#notInCspMode) {
|
| processedClasses.constructorsList = [];
|
| // For every class processed [processedClasses.combinedConstructorFunction]
|
| @@ -407,7 +407,8 @@ jsAst.Expression getReflectionDataParser(OldEmitter oldEmitter,
|
|
|
| #trivialNsmHandlers;
|
|
|
| - for (var cls in processedClasses.pending) finishClass(cls);
|
| + var properties = Object.keys(processedClasses.pending);
|
| + for (var i = 0; i < properties.length; i++) finishClass(properties[i]);
|
| }
|
| }''', {'allClasses': allClassesAccess,
|
| 'debugFastObjects': DEBUG_FAST_OBJECTS,
|
|
|