| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
| 8 | 8 |
| 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
| 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 canBeInlinedInsideLoop[element] = false; | 156 canBeInlinedInsideLoop[element] = false; |
| 157 } else { | 157 } else { |
| 158 canBeInlined[element] = false; | 158 canBeInlined[element] = false; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 class JavaScriptBackend extends Backend { | 164 class JavaScriptBackend extends Backend { |
| 165 SsaBuilderTask builder; | 165 SsaBuilderTask builder; |
| 166 SsaFromIrBuilderTask fromIrBuilder; |
| 166 SsaOptimizerTask optimizer; | 167 SsaOptimizerTask optimizer; |
| 167 SsaCodeGeneratorTask generator; | 168 SsaCodeGeneratorTask generator; |
| 168 CodeEmitterTask emitter; | 169 CodeEmitterTask emitter; |
| 169 | 170 |
| 170 /** | 171 /** |
| 171 * The generated code as a js AST for compiled methods. | 172 * The generated code as a js AST for compiled methods. |
| 172 */ | 173 */ |
| 173 Map<Element, jsAst.Expression> get generatedCode { | 174 Map<Element, jsAst.Expression> get generatedCode { |
| 174 return compiler.enqueuer.codegen.generatedCode; | 175 return compiler.enqueuer.codegen.generatedCode; |
| 175 } | 176 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 413 |
| 413 JavaScriptBackend(Compiler compiler, bool generateSourceMap) | 414 JavaScriptBackend(Compiler compiler, bool generateSourceMap) |
| 414 : namer = determineNamer(compiler), | 415 : namer = determineNamer(compiler), |
| 415 oneShotInterceptors = new Map<String, Selector>(), | 416 oneShotInterceptors = new Map<String, Selector>(), |
| 416 interceptedElements = new Map<String, Set<Element>>(), | 417 interceptedElements = new Map<String, Set<Element>>(), |
| 417 rti = new RuntimeTypes(compiler), | 418 rti = new RuntimeTypes(compiler), |
| 418 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), | 419 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), |
| 419 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { | 420 super(compiler, JAVA_SCRIPT_CONSTANT_SYSTEM) { |
| 420 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap); | 421 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap); |
| 421 builder = new SsaBuilderTask(this); | 422 builder = new SsaBuilderTask(this); |
| 423 fromIrBuilder = new SsaFromIrBuilderTask(compiler); |
| 422 optimizer = new SsaOptimizerTask(this); | 424 optimizer = new SsaOptimizerTask(this); |
| 423 generator = new SsaCodeGeneratorTask(this); | 425 generator = new SsaCodeGeneratorTask(this); |
| 424 typeVariableHandler = new TypeVariableHandler(this); | 426 typeVariableHandler = new TypeVariableHandler(this); |
| 425 customElementsAnalysis = new CustomElementsAnalysis(this); | 427 customElementsAnalysis = new CustomElementsAnalysis(this); |
| 426 } | 428 } |
| 427 | 429 |
| 428 static Namer determineNamer(Compiler compiler) { | 430 static Namer determineNamer(Compiler compiler) { |
| 429 return compiler.enableMinification ? | 431 return compiler.enableMinification ? |
| 430 new MinifyNamer(compiler) : | 432 new MinifyNamer(compiler) : |
| 431 new Namer(compiler); | 433 new Namer(compiler); |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 // the checked setter. | 1255 // the checked setter. |
| 1254 if (Elements.isStaticOrTopLevel(element)) return; | 1256 if (Elements.isStaticOrTopLevel(element)) return; |
| 1255 } else { | 1257 } else { |
| 1256 // If the constant-handler was not able to produce a result we have to | 1258 // If the constant-handler was not able to produce a result we have to |
| 1257 // go through the builder (below) to generate the lazy initializer for | 1259 // go through the builder (below) to generate the lazy initializer for |
| 1258 // the static variable. | 1260 // the static variable. |
| 1259 // We also need to register the use of the cyclic-error helper. | 1261 // We also need to register the use of the cyclic-error helper. |
| 1260 compiler.enqueuer.codegen.registerStaticUse(getCyclicThrowHelper()); | 1262 compiler.enqueuer.codegen.registerStaticUse(getCyclicThrowHelper()); |
| 1261 } | 1263 } |
| 1262 } | 1264 } |
| 1263 | 1265 HGraph graph = compiler.irBuilder.hasIr(element) |
| 1264 HGraph graph = builder.build(work); | 1266 ? fromIrBuilder.build(work) |
| 1267 : builder.build(work); |
| 1265 optimizer.optimize(work, graph); | 1268 optimizer.optimize(work, graph); |
| 1266 jsAst.Expression code = generator.generateCode(work, graph); | 1269 jsAst.Expression code = generator.generateCode(work, graph); |
| 1267 generatedCode[element] = code; | 1270 generatedCode[element] = code; |
| 1268 } | 1271 } |
| 1269 | 1272 |
| 1270 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { | 1273 native.NativeEnqueuer nativeResolutionEnqueuer(Enqueuer world) { |
| 1271 return new native.NativeResolutionEnqueuer(world, compiler); | 1274 return new native.NativeResolutionEnqueuer(world, compiler); |
| 1272 } | 1275 } |
| 1273 | 1276 |
| 1274 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { | 1277 native.NativeEnqueuer nativeCodegenEnqueuer(Enqueuer world) { |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1979 copy(constant.values); | 1982 copy(constant.values); |
| 1980 copy(constant.protoValue); | 1983 copy(constant.protoValue); |
| 1981 copy(constant); | 1984 copy(constant); |
| 1982 } | 1985 } |
| 1983 | 1986 |
| 1984 void visitConstructed(ConstructedConstant constant) { | 1987 void visitConstructed(ConstructedConstant constant) { |
| 1985 copy(constant.fields); | 1988 copy(constant.fields); |
| 1986 copy(constant); | 1989 copy(constant); |
| 1987 } | 1990 } |
| 1988 } | 1991 } |
| OLD | NEW |