Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 18111006: Collect edge count profiling data and reorder basic blocks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function, 250 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function,
251 TargetEntryInstr* normal_entry, 251 TargetEntryInstr* normal_entry,
252 intptr_t osr_id) 252 intptr_t osr_id)
253 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), 253 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex),
254 parsed_function_(parsed_function), 254 parsed_function_(parsed_function),
255 normal_entry_(normal_entry), 255 normal_entry_(normal_entry),
256 catch_entries_(), 256 catch_entries_(),
257 initial_definitions_(), 257 initial_definitions_(),
258 osr_id_(osr_id), 258 osr_id_(osr_id),
259 entry_count_(0),
259 spill_slot_count_(0), 260 spill_slot_count_(0),
260 fixed_slot_count_(0) { 261 fixed_slot_count_(0) {
261 } 262 }
262 263
263 264
264 ConstantInstr* GraphEntryInstr::constant_null() { 265 ConstantInstr* GraphEntryInstr::constant_null() {
265 ASSERT(initial_definitions_.length() > 0); 266 ASSERT(initial_definitions_.length() > 0);
266 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) { 267 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) {
267 ConstantInstr* defn = initial_definitions_[i]->AsConstant(); 268 ConstantInstr* defn = initial_definitions_[i]->AsConstant();
268 if (defn != NULL && defn->value().IsNull()) return defn; 269 if (defn != NULL && defn->value().IsNull()) return defn;
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 } 788 }
788 789
789 // 6. Assign postorder number and add the block entry to the list. 790 // 6. Assign postorder number and add the block entry to the list.
790 set_postorder_number(postorder->length()); 791 set_postorder_number(postorder->length());
791 postorder->Add(this); 792 postorder->Add(this);
792 } 793 }
793 794
794 795
795 bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder, 796 bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder,
796 GraphEntryInstr* graph_entry, 797 GraphEntryInstr* graph_entry,
798 Instruction* parent,
797 intptr_t osr_id, 799 intptr_t osr_id,
798 BitVector* block_marks) { 800 BitVector* block_marks) {
799 // Search for the instruction with the OSR id. Use a depth first search 801 // Search for the instruction with the OSR id. Use a depth first search
800 // because basic blocks have not been discovered yet. Prune unreachable 802 // because basic blocks have not been discovered yet. Prune unreachable
801 // blocks by replacing the normal entry with a jump to the block 803 // blocks by replacing the normal entry with a jump to the block
802 // containing the OSR entry point. 804 // containing the OSR entry point.
803 805
804 // Do not visit blocks more than once. 806 // Do not visit blocks more than once.
805 if (block_marks->Contains(block_id())) return false; 807 if (block_marks->Contains(block_id())) return false;
806 block_marks->Add(block_id()); 808 block_marks->Add(block_id());
807 809
808 // Search this block for the OSR id. 810 // Search this block for the OSR id.
809 Instruction* instr = this; 811 Instruction* instr = this;
810 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) { 812 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) {
811 instr = it.Current(); 813 instr = it.Current();
812 if (instr->GetDeoptId() == osr_id) { 814 if (instr->GetDeoptId() == osr_id) {
813 // Sanity check that we found a stack check instruction. 815 // Sanity check that we found a stack check instruction.
814 ASSERT(instr->IsCheckStackOverflow()); 816 ASSERT(instr->IsCheckStackOverflow());
815 // Loop stack check checks are always in join blocks so that they can 817 // Loop stack check checks are always in join blocks so that they can
816 // be the target of a goto. 818 // be the target of a goto.
817 ASSERT(IsJoinEntry()); 819 ASSERT(IsJoinEntry());
818 // The instruction should be the first instruction in the block so 820 // The instruction should be the first instruction in the block so
819 // we can simply jump to the beginning of the block. 821 // we can simply jump to the beginning of the block.
820 ASSERT(instr->previous() == this); 822 ASSERT(instr->previous() == this);
821 823
822 GotoInstr* goto_join = new GotoInstr(AsJoinEntry()); 824 GotoInstr* goto_join = new GotoInstr(AsJoinEntry());
823 goto_join->deopt_id_ = deopt_id_; 825 goto_join->deopt_id_ = parent->deopt_id_;
824 graph_entry->normal_entry()->LinkTo(goto_join); 826 graph_entry->normal_entry()->LinkTo(goto_join);
825 return true; 827 return true;
826 } 828 }
827 } 829 }
828 830
829 // Recursively search the successors. 831 // Recursively search the successors.
830 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) { 832 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) {
831 if (instr->SuccessorAt(i)->PruneUnreachable(builder, 833 if (instr->SuccessorAt(i)->PruneUnreachable(builder,
832 graph_entry, 834 graph_entry,
835 instr,
833 osr_id, 836 osr_id,
834 block_marks)) { 837 block_marks)) {
835 return true; 838 return true;
836 } 839 }
837 } 840 }
838 return false; 841 return false;
839 } 842 }
840 843
841 844
842 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { 845 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const {
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 } 1541 }
1539 } 1542 }
1540 1543
1541 1544
1542 LocationSummary* TargetEntryInstr::MakeLocationSummary() const { 1545 LocationSummary* TargetEntryInstr::MakeLocationSummary() const {
1543 UNREACHABLE(); 1546 UNREACHABLE();
1544 return NULL; 1547 return NULL;
1545 } 1548 }
1546 1549
1547 1550
1548 void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1549 __ Bind(compiler->GetJumpLabel(this));
1550 if (!compiler->is_optimizing()) {
1551 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
1552 deopt_id_,
1553 Scanner::kDummyTokenIndex);
1554 }
1555 if (HasParallelMove()) {
1556 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
1557 }
1558 }
1559
1560
1561 LocationSummary* CatchBlockEntryInstr::MakeLocationSummary() const { 1551 LocationSummary* CatchBlockEntryInstr::MakeLocationSummary() const {
1562 UNREACHABLE(); 1552 UNREACHABLE();
1563 return NULL; 1553 return NULL;
1564 } 1554 }
1565 1555
1566 1556
1567 void CatchBlockEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1557 void CatchBlockEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1568 __ Bind(compiler->GetJumpLabel(this)); 1558 __ Bind(compiler->GetJumpLabel(this));
1569 compiler->AddExceptionHandler(catch_try_index(), 1559 compiler->AddExceptionHandler(catch_try_index(),
1570 try_index(), 1560 try_index(),
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2574 default: 2564 default:
2575 UNREACHABLE(); 2565 UNREACHABLE();
2576 } 2566 }
2577 return kPowRuntimeEntry; 2567 return kPowRuntimeEntry;
2578 } 2568 }
2579 2569
2580 2570
2581 #undef __ 2571 #undef __
2582 2572
2583 } // namespace dart 2573 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698