Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| index 95ea5d973d6a6062230a42196ffc443c6c052dfd..88095ba3e09c7255defc0b98fbb785c5931cd548 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| @@ -1413,10 +1413,16 @@ class OldEmitter implements Emitter { |
| /// initializer of deferred files. |
| mainBuffer.write('var ${globalsHolder}$_=${_}Object.create(null)$N'); |
| } |
| - mainBuffer.write('function dart()$_{$n' |
| - '${_}${_}this.x$_=${_}0$N' |
| - '${_}${_}delete this.x$N' |
| - '}$n'); |
| + |
| + jsAst.Statement mapFunction = js.statement(''' |
| +// [map] returns an object literal that V8 shouldn not try to optimize with a |
|
ahe
2015/01/07 12:20:16
shouldn't (remove "not").
map doesn't return an "
zarah
2015/01/07 13:45:17
Done.
|
| +// hidden class. This prevents a potential performance problem where V8 tries |
| +// to build a hidden class for an object used as a hashMap. |
| +// It requires fewer characters to declare a variable as a parameter than |
| +// with `var`. |
| + function map(x){x=Object.create(null);x.x=0;delete x.x;return x} |
|
ahe
2015/01/07 12:20:16
Now that this is parsed, I suggest you reformat it
zarah
2015/01/07 13:45:17
Done.
|
| +'''); |
| + mainBuffer.write(jsAst.prettyPrint(mapFunction, compiler)); |
| for (String globalObject in Namer.reservedGlobalObjectNames) { |
| // The global objects start as so-called "slow objects". For V8, this |
| // means that it won't try to make map transitions as we add properties |
| @@ -1427,7 +1433,7 @@ class OldEmitter implements Emitter { |
| if(isProgramSplit) { |
| mainBuffer.write('${globalsHolder}.$globalObject$_=${_}'); |
| } |
| - mainBuffer.write('new dart$N'); |
| + mainBuffer.write('map()$N'); |
| } |
| mainBuffer.write('function ${namer.isolateName}()$_{}\n'); |
| @@ -1477,9 +1483,10 @@ class OldEmitter implements Emitter { |
| compiler)) |
| ..write(n); |
| - mainBuffer..write('$parseReflectionDataName([$n') |
| + mainBuffer..write('var dart = [$n') |
| ..write(libraryBuffer) |
| - ..write('])$N'); |
| + ..write(']$N') |
| + ..write('$parseReflectionDataName(dart)$N'); |
| } |
| interceptorEmitter.emitGetInterceptorMethods(mainBuffer); |
| @@ -1924,9 +1931,10 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) { |
| // to Isolate.$finishIsolateConstructor. |
| outputBuffer |
| ..write('var ${namer.currentIsolate}$_=$_$isolatePropertiesName$N') |
| - ..write('$parseReflectionDataName([$n') |
| + ..write('var dart = [$n ') |
| ..addBuffer(libraryDescriptorBuffer) |
| - ..write('])$N'); |
| + ..write(']$N') |
| + ..write('$parseReflectionDataName(dart)$N'); |
| } |