| 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 typedef void Recompile(Element element); | 5 typedef void Recompile(Element element); |
| 6 | 6 |
| 7 class ReturnInfo { | 7 class ReturnInfo { |
| 8 HType returnType; | 8 HType returnType; |
| 9 List<Element> compiledFunctions; | 9 List<Element> compiledFunctions; |
| 10 | 10 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 fieldSettersType = new Map<Element, Map<Element, HType>>(), | 320 fieldSettersType = new Map<Element, Map<Element, HType>>(), |
| 321 returnInfo = new Map<Element, ReturnInfo>(), | 321 returnInfo = new Map<Element, ReturnInfo>(), |
| 322 invalidateAfterCodegen = new List<Element>(), | 322 invalidateAfterCodegen = new List<Element>(), |
| 323 super(compiler) { | 323 super(compiler) { |
| 324 builder = new SsaBuilderTask(this); | 324 builder = new SsaBuilderTask(this); |
| 325 optimizer = new SsaOptimizerTask(this); | 325 optimizer = new SsaOptimizerTask(this); |
| 326 generator = new SsaCodeGeneratorTask(this); | 326 generator = new SsaCodeGeneratorTask(this); |
| 327 argumentTypes = new ArgumentTypesRegistry(this); | 327 argumentTypes = new ArgumentTypesRegistry(this); |
| 328 } | 328 } |
| 329 | 329 |
| 330 Element get cyclicThrowHelper() { |
| 331 return compiler.findHelper(const SourceString("throwCyclicInit")); |
| 332 } |
| 333 |
| 330 JavaScriptItemCompilationContext createItemCompilationContext() { | 334 JavaScriptItemCompilationContext createItemCompilationContext() { |
| 331 return new JavaScriptItemCompilationContext(); | 335 return new JavaScriptItemCompilationContext(); |
| 332 } | 336 } |
| 333 | 337 |
| 334 void enqueueHelpers(Enqueuer world) { | 338 void enqueueHelpers(Enqueuer world) { |
| 335 enqueueAllTopLevelFunctions(compiler.jsHelperLibrary, world); | 339 enqueueAllTopLevelFunctions(compiler.jsHelperLibrary, world); |
| 336 enqueueAllTopLevelFunctions(compiler.interceptorsLibrary, world); | 340 enqueueAllTopLevelFunctions(compiler.interceptorsLibrary, world); |
| 337 for (var helper in [const SourceString('Closure'), | 341 for (var helper in [const SourceString('Closure'), |
| 338 const SourceString('ConstantMap'), | 342 const SourceString('ConstantMap'), |
| 339 const SourceString('ConstantProtoMap')]) { | 343 const SourceString('ConstantProtoMap')]) { |
| 340 var e = compiler.findHelper(helper); | 344 var e = compiler.findHelper(helper); |
| 341 if (e !== null) world.registerInstantiatedClass(e); | 345 if (e !== null) world.registerInstantiatedClass(e); |
| 342 } | 346 } |
| 343 } | 347 } |
| 344 | 348 |
| 345 void codegen(WorkItem work) { | 349 void codegen(WorkItem work) { |
| 350 if (work.element.kind.category == ElementCategory.VARIABLE) { |
| 351 Constant initialValue = compiler.constantHandler.compileWorkItem(work); |
| 352 if (initialValue !== null) { |
| 353 return; |
| 354 } else { |
| 355 // If the constant-handler was not able to produce a result we have to |
| 356 // go through the builder (below) to generate the lazy initializer for |
| 357 // the static variable. |
| 358 // We also need to register the use of the cyclic-error helper. |
| 359 compiler.enqueuer.codegen.registerStaticUse(cyclicThrowHelper); |
| 360 } |
| 361 } |
| 362 |
| 346 HGraph graph = builder.build(work); | 363 HGraph graph = builder.build(work); |
| 347 optimizer.optimize(work, graph); | 364 optimizer.optimize(work, graph); |
| 348 if (work.allowSpeculativeOptimization | 365 if (work.allowSpeculativeOptimization |
| 349 && optimizer.trySpeculativeOptimizations(work, graph)) { | 366 && optimizer.trySpeculativeOptimizations(work, graph)) { |
| 350 CodeBuffer codeBuffer = generator.generateBailoutMethod(work, graph); | 367 CodeBuffer codeBuffer = generator.generateBailoutMethod(work, graph); |
| 351 compiler.codegenWorld.addBailoutCode(work, codeBuffer); | 368 compiler.codegenWorld.addBailoutCode(work, codeBuffer); |
| 352 optimizer.prepareForSpeculativeOptimizations(work, graph); | 369 optimizer.prepareForSpeculativeOptimizations(work, graph); |
| 353 optimizer.optimize(work, graph); | 370 optimizer.optimize(work, graph); |
| 354 } | 371 } |
| 355 CodeBuffer codeBuffer = generator.generateMethod(work, graph); | 372 CodeBuffer codeBuffer = generator.generateCode(work, graph); |
| 356 compiler.codegenWorld.addGeneratedCode(work, codeBuffer); | 373 compiler.codegenWorld.addGeneratedCode(work, codeBuffer); |
| 357 invalidateAfterCodegen.forEach( | 374 invalidateAfterCodegen.forEach(compiler.enqueuer.codegen.eagerRecompile); |
| 358 compiler.enqueuer.codegen.eagerRecompile); | |
| 359 invalidateAfterCodegen.clear(); | 375 invalidateAfterCodegen.clear(); |
| 360 } | 376 } |
| 361 | 377 |
| 362 void processNativeClasses(Enqueuer world, | 378 void processNativeClasses(Enqueuer world, |
| 363 Collection<LibraryElement> libraries) { | 379 Collection<LibraryElement> libraries) { |
| 364 native.processNativeClasses(world, emitter, libraries); | 380 native.processNativeClasses(world, emitter, libraries); |
| 365 } | 381 } |
| 366 | 382 |
| 367 void assembleProgram() { | 383 void assembleProgram() { |
| 368 emitter.assembleProgram(); | 384 emitter.assembleProgram(); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 return const SourceString('listSuperTypeCheck'); | 593 return const SourceString('listSuperTypeCheck'); |
| 578 } | 594 } |
| 579 } else if (nativeCheck) { | 595 } else if (nativeCheck) { |
| 580 return const SourceString('callTypeCheck'); | 596 return const SourceString('callTypeCheck'); |
| 581 } else { | 597 } else { |
| 582 return const SourceString('propertyTypeCheck'); | 598 return const SourceString('propertyTypeCheck'); |
| 583 } | 599 } |
| 584 } | 600 } |
| 585 } | 601 } |
| 586 } | 602 } |
| OLD | NEW |