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 #include "vm/compiler.h" | 5 #include "vm/compiler.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 | 8 |
9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
481 | 481 |
482 // Perform register allocation on the SSA graph. | 482 // Perform register allocation on the SSA graph. |
483 FlowGraphAllocator allocator(*flow_graph); | 483 FlowGraphAllocator allocator(*flow_graph); |
484 allocator.AllocateRegisters(); | 484 allocator.AllocateRegisters(); |
485 | 485 |
486 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { | 486 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { |
487 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); | 487 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 Assembler assembler; | 491 bool assembled = false; |
492 FlowGraphCompiler graph_compiler(&assembler, | 492 while (!assembled) { |
493 *flow_graph, | 493 LongJump* assembler_old_base = isolate->long_jump_base(); |
494 optimized); | 494 LongJump assembler_jump; |
495 { | 495 isolate->set_long_jump_base(&assembler_jump); |
496 TimerScope timer(FLAG_compiler_stats, | 496 if (setjmp(*bailout_jump.Set()) == 0) { |
497 &CompilerStats::graphcompiler_timer, | 497 Assembler assembler(function.needs_far_branches()); |
regis
2013/07/31 18:01:12
I think that the property of requiring far branche
zra
2013/07/31 20:10:52
That makes sense to me. I've moved the flag to the
| |
498 isolate); | 498 FlowGraphCompiler graph_compiler(&assembler, |
499 graph_compiler.CompileGraph(); | 499 *flow_graph, |
500 } | 500 optimized); |
501 { | 501 { |
502 TimerScope timer(FLAG_compiler_stats, | 502 TimerScope timer(FLAG_compiler_stats, |
503 &CompilerStats::codefinalizer_timer, | 503 &CompilerStats::graphcompiler_timer, |
504 isolate); | 504 isolate); |
505 const Code& code = Code::Handle( | 505 graph_compiler.CompileGraph(); |
506 Code::FinalizeCode(function, &assembler, optimized)); | 506 assembled = true; |
507 code.set_is_optimized(optimized); | 507 } |
508 graph_compiler.FinalizePcDescriptors(code); | 508 { |
509 graph_compiler.FinalizeDeoptInfo(code); | 509 TimerScope timer(FLAG_compiler_stats, |
510 graph_compiler.FinalizeStackmaps(code); | 510 &CompilerStats::codefinalizer_timer, |
511 graph_compiler.FinalizeVarDescriptors(code); | 511 isolate); |
512 graph_compiler.FinalizeExceptionHandlers(code); | 512 const Code& code = Code::Handle( |
513 graph_compiler.FinalizeComments(code); | 513 Code::FinalizeCode(function, &assembler, optimized)); |
514 graph_compiler.FinalizeStaticCallTargetsTable(code); | 514 code.set_is_optimized(optimized); |
515 graph_compiler.FinalizePcDescriptors(code); | |
516 graph_compiler.FinalizeDeoptInfo(code); | |
517 graph_compiler.FinalizeStackmaps(code); | |
518 graph_compiler.FinalizeVarDescriptors(code); | |
519 graph_compiler.FinalizeExceptionHandlers(code); | |
520 graph_compiler.FinalizeComments(code); | |
521 graph_compiler.FinalizeStaticCallTargetsTable(code); | |
515 | 522 |
516 if (optimized) { | 523 if (optimized) { |
517 if (osr_id == Isolate::kNoDeoptId) { | 524 if (osr_id == Isolate::kNoDeoptId) { |
518 CodePatcher::PatchEntry(Code::Handle(function.CurrentCode())); | 525 CodePatcher::PatchEntry(Code::Handle(function.CurrentCode())); |
519 if (FLAG_trace_compiler) { | 526 if (FLAG_trace_compiler) { |
520 OS::Print("--> patching entry %#"Px"\n", | 527 OS::Print("--> patching entry %#"Px"\n", |
521 Code::Handle(function.unoptimized_code()).EntryPoint()); | 528 Code::Handle(function.unoptimized_code()).EntryPoint()); |
529 } | |
530 } | |
531 function.SetCode(code); | |
532 | |
533 for (intptr_t i = 0; i < guarded_fields.length(); i++) { | |
534 const Field& field = *guarded_fields[i]; | |
535 field.RegisterDependentCode(code); | |
536 } | |
537 } else { | |
538 function.set_unoptimized_code(code); | |
539 function.SetCode(code); | |
540 ASSERT(CodePatcher::CodeIsPatchable(code)); | |
522 } | 541 } |
523 } | 542 } |
524 function.SetCode(code); | 543 is_compiled = true; |
544 } else { | |
545 isolate->object_store()->clear_sticky_error(); | |
525 | 546 |
526 for (intptr_t i = 0; i < guarded_fields.length(); i++) { | 547 ASSERT(!function.needs_far_branches()); |
527 const Field& field = *guarded_fields[i]; | 548 function.set_needs_far_branches(true); |
528 field.RegisterDependentCode(code); | 549 is_compiled = false; |
529 } | |
530 } else { | |
531 function.set_unoptimized_code(code); | |
532 function.SetCode(code); | |
533 ASSERT(CodePatcher::CodeIsPatchable(code)); | |
534 } | 550 } |
551 isolate->set_long_jump_base(assembler_old_base); | |
552 isolate->set_deopt_id(prev_deopt_id); | |
535 } | 553 } |
536 is_compiled = true; | |
537 } else { | 554 } else { |
538 // We bailed out. | 555 // We bailed out. |
539 Error& bailout_error = Error::Handle( | 556 Error& bailout_error = Error::Handle( |
540 isolate->object_store()->sticky_error()); | 557 isolate->object_store()->sticky_error()); |
541 isolate->object_store()->clear_sticky_error(); | 558 isolate->object_store()->clear_sticky_error(); |
542 if (FLAG_trace_bailout) { | 559 if (FLAG_trace_bailout) { |
543 OS::Print("%s\n", bailout_error.ToErrorCString()); | 560 OS::Print("%s\n", bailout_error.ToErrorCString()); |
544 } | 561 } |
545 // We only bail out from generating ssa code. | 562 // We only bail out from generating ssa code. |
546 ASSERT(optimized); | 563 ASSERT(optimized); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
881 Object::Handle(isolate->object_store()->sticky_error()); | 898 Object::Handle(isolate->object_store()->sticky_error()); |
882 isolate->object_store()->clear_sticky_error(); | 899 isolate->object_store()->clear_sticky_error(); |
883 isolate->set_long_jump_base(base); | 900 isolate->set_long_jump_base(base); |
884 return result.raw(); | 901 return result.raw(); |
885 } | 902 } |
886 UNREACHABLE(); | 903 UNREACHABLE(); |
887 return Object::null(); | 904 return Object::null(); |
888 } | 905 } |
889 | 906 |
890 } // namespace dart | 907 } // namespace dart |
OLD | NEW |