OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
6 | 6 |
7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
8 | 8 |
9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
10 #include "vm/cha.h" | 10 #include "vm/cha.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 // We collect intervals while generating code. | 427 // We collect intervals while generating code. |
428 struct IntervalStruct { | 428 struct IntervalStruct { |
429 // 'start' and 'end' are pc-offsets. | 429 // 'start' and 'end' are pc-offsets. |
430 intptr_t start; | 430 intptr_t start; |
431 intptr_t inlining_id; | 431 intptr_t inlining_id; |
432 IntervalStruct(intptr_t s, intptr_t id) : start(s), inlining_id(id) {} | 432 IntervalStruct(intptr_t s, intptr_t id) : start(s), inlining_id(id) {} |
433 void Dump() { | 433 void Dump() { |
434 ISL_Print("start: 0x%" Px " iid: %" Pd " ", start, inlining_id); | 434 THR_Print("start: 0x%" Px " iid: %" Pd " ", start, inlining_id); |
435 } | 435 } |
436 }; | 436 }; |
437 | 437 |
438 | 438 |
439 void FlowGraphCompiler::VisitBlocks() { | 439 void FlowGraphCompiler::VisitBlocks() { |
440 CompactBlocks(); | 440 CompactBlocks(); |
441 const ZoneGrowableArray<BlockEntryInstr*>* loop_headers = NULL; | 441 const ZoneGrowableArray<BlockEntryInstr*>* loop_headers = NULL; |
442 if (Assembler::EmittingComments()) { | 442 if (Assembler::EmittingComments()) { |
443 // 'loop_headers' were cleared, recompute. | 443 // 'loop_headers' were cleared, recompute. |
444 loop_headers = flow_graph().ComputeLoops(); | 444 loop_headers = flow_graph().ComputeLoops(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 ASSERT(is_optimizing() || FrameStateIsSafeToCall()); | 513 ASSERT(is_optimizing() || FrameStateIsSafeToCall()); |
514 #endif | 514 #endif |
515 } | 515 } |
516 | 516 |
517 if (inline_id_to_function_.length() > max_inlining_id + 1) { | 517 if (inline_id_to_function_.length() > max_inlining_id + 1) { |
518 // TODO(srdjan): Some inlined function can disappear, | 518 // TODO(srdjan): Some inlined function can disappear, |
519 // truncate 'inline_id_to_function_'. | 519 // truncate 'inline_id_to_function_'. |
520 } | 520 } |
521 | 521 |
522 if (is_optimizing()) { | 522 if (is_optimizing()) { |
523 LogBlock lb(Thread::Current()); | 523 LogBlock lb; |
524 intervals.Add(IntervalStruct(prev_offset, prev_inlining_id)); | 524 intervals.Add(IntervalStruct(prev_offset, prev_inlining_id)); |
525 inlined_code_intervals_ = | 525 inlined_code_intervals_ = |
526 Array::New(intervals.length() * Code::kInlIntNumEntries, Heap::kOld); | 526 Array::New(intervals.length() * Code::kInlIntNumEntries, Heap::kOld); |
527 Smi& start_h = Smi::Handle(); | 527 Smi& start_h = Smi::Handle(); |
528 Smi& caller_inline_id = Smi::Handle(); | 528 Smi& caller_inline_id = Smi::Handle(); |
529 Smi& inline_id = Smi::Handle(); | 529 Smi& inline_id = Smi::Handle(); |
530 for (intptr_t i = 0; i < intervals.length(); i++) { | 530 for (intptr_t i = 0; i < intervals.length(); i++) { |
531 if (FLAG_trace_inlining_intervals && is_optimizing()) { | 531 if (FLAG_trace_inlining_intervals && is_optimizing()) { |
532 const Function& function = | 532 const Function& function = |
533 *inline_id_to_function_.At(intervals[i].inlining_id); | 533 *inline_id_to_function_.At(intervals[i].inlining_id); |
534 intervals[i].Dump(); | 534 intervals[i].Dump(); |
535 ISL_Print(" parent iid %" Pd " %s\n", | 535 THR_Print(" parent iid %" Pd " %s\n", |
536 caller_inline_id_[intervals[i].inlining_id], | 536 caller_inline_id_[intervals[i].inlining_id], |
537 function.ToQualifiedCString()); | 537 function.ToQualifiedCString()); |
538 } | 538 } |
539 | 539 |
540 const intptr_t id = intervals[i].inlining_id; | 540 const intptr_t id = intervals[i].inlining_id; |
541 start_h = Smi::New(intervals[i].start); | 541 start_h = Smi::New(intervals[i].start); |
542 inline_id = Smi::New(id); | 542 inline_id = Smi::New(id); |
543 caller_inline_id = Smi::New(caller_inline_id_[intervals[i].inlining_id]); | 543 caller_inline_id = Smi::New(caller_inline_id_[intervals[i].inlining_id]); |
544 | 544 |
545 const intptr_t p = i * Code::kInlIntNumEntries; | 545 const intptr_t p = i * Code::kInlIntNumEntries; |
546 inlined_code_intervals_.SetAt(p + Code::kInlIntStart, start_h); | 546 inlined_code_intervals_.SetAt(p + Code::kInlIntStart, start_h); |
547 inlined_code_intervals_.SetAt(p + Code::kInlIntInliningId, inline_id); | 547 inlined_code_intervals_.SetAt(p + Code::kInlIntInliningId, inline_id); |
548 } | 548 } |
549 } | 549 } |
550 set_current_block(NULL); | 550 set_current_block(NULL); |
551 if (FLAG_trace_inlining_intervals && is_optimizing()) { | 551 if (FLAG_trace_inlining_intervals && is_optimizing()) { |
552 LogBlock lb(Isolate::Current()); | 552 LogBlock lb; |
553 ISL_Print("Intervals:\n"); | 553 THR_Print("Intervals:\n"); |
554 for (intptr_t cc = 0; cc < caller_inline_id_.length(); cc++) { | 554 for (intptr_t cc = 0; cc < caller_inline_id_.length(); cc++) { |
555 ISL_Print(" iid: %" Pd " caller iid: %" Pd "\n", | 555 THR_Print(" iid: %" Pd " caller iid: %" Pd "\n", |
556 cc, caller_inline_id_[cc]); | 556 cc, caller_inline_id_[cc]); |
557 } | 557 } |
558 Smi& temp = Smi::Handle(); | 558 Smi& temp = Smi::Handle(); |
559 for (intptr_t i = 0; i < inlined_code_intervals_.Length(); | 559 for (intptr_t i = 0; i < inlined_code_intervals_.Length(); |
560 i += Code::kInlIntNumEntries) { | 560 i += Code::kInlIntNumEntries) { |
561 temp ^= inlined_code_intervals_.At(i + Code::kInlIntStart); | 561 temp ^= inlined_code_intervals_.At(i + Code::kInlIntStart); |
562 ASSERT(!temp.IsNull()); | 562 ASSERT(!temp.IsNull()); |
563 ISL_Print("% " Pd " start: 0x%" Px " ", i, temp.Value()); | 563 THR_Print("% " Pd " start: 0x%" Px " ", i, temp.Value()); |
564 temp ^= inlined_code_intervals_.At(i + Code::kInlIntInliningId); | 564 temp ^= inlined_code_intervals_.At(i + Code::kInlIntInliningId); |
565 ISL_Print("iid: %" Pd " ", temp.Value()); | 565 THR_Print("iid: %" Pd " ", temp.Value()); |
566 } | 566 } |
567 } | 567 } |
568 } | 568 } |
569 | 569 |
570 | 570 |
571 void FlowGraphCompiler::Bailout(const char* reason) { | 571 void FlowGraphCompiler::Bailout(const char* reason) { |
572 const Function& function = parsed_function_.function(); | 572 const Function& function = parsed_function_.function(); |
573 Report::MessageF(Report::kBailout, | 573 Report::MessageF(Report::kBailout, |
574 Script::Handle(function.script()), | 574 Script::Handle(function.script()), |
575 function.token_pos(), | 575 function.token_pos(), |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1832 | 1832 |
1833 | 1833 |
1834 void FlowGraphCompiler::FrameStateClear() { | 1834 void FlowGraphCompiler::FrameStateClear() { |
1835 ASSERT(!is_optimizing()); | 1835 ASSERT(!is_optimizing()); |
1836 frame_state_.TruncateTo(0); | 1836 frame_state_.TruncateTo(0); |
1837 } | 1837 } |
1838 #endif | 1838 #endif |
1839 | 1839 |
1840 | 1840 |
1841 } // namespace dart | 1841 } // namespace dart |
OLD | NEW |