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

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

Issue 17233003: Reapply "Initial implementation of on-stack replacement (OSR)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 238
239 const Object& Value::BoundConstant() const { 239 const Object& Value::BoundConstant() const {
240 ASSERT(BindsToConstant()); 240 ASSERT(BindsToConstant());
241 ConstantInstr* constant = definition()->AsConstant(); 241 ConstantInstr* constant = definition()->AsConstant();
242 ASSERT(constant != NULL); 242 ASSERT(constant != NULL);
243 return constant->value(); 243 return constant->value();
244 } 244 }
245 245
246 246
247 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function, 247 GraphEntryInstr::GraphEntryInstr(const ParsedFunction& parsed_function,
248 TargetEntryInstr* normal_entry) 248 TargetEntryInstr* normal_entry,
249 intptr_t osr_id)
249 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex), 250 : BlockEntryInstr(0, CatchClauseNode::kInvalidTryIndex),
250 parsed_function_(parsed_function), 251 parsed_function_(parsed_function),
251 normal_entry_(normal_entry), 252 normal_entry_(normal_entry),
252 catch_entries_(), 253 catch_entries_(),
253 initial_definitions_(), 254 initial_definitions_(),
255 osr_id_(osr_id),
254 spill_slot_count_(0), 256 spill_slot_count_(0),
255 fixed_slot_count_(0) { 257 fixed_slot_count_(0) {
256 } 258 }
257 259
258 260
259 ConstantInstr* GraphEntryInstr::constant_null() { 261 ConstantInstr* GraphEntryInstr::constant_null() {
260 ASSERT(initial_definitions_.length() > 0); 262 ASSERT(initial_definitions_.length() > 0);
261 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) { 263 for (intptr_t i = 0; i < initial_definitions_.length(); ++i) {
262 ConstantInstr* defn = initial_definitions_[i]->AsConstant(); 264 ConstantInstr* defn = initial_definitions_[i]->AsConstant();
263 if (defn != NULL && defn->value().IsNull()) return defn; 265 if (defn != NULL && defn->value().IsNull()) return defn;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 variable_count, 782 variable_count,
781 fixed_parameter_count); 783 fixed_parameter_count);
782 } 784 }
783 785
784 // 6. Assign postorder number and add the block entry to the list. 786 // 6. Assign postorder number and add the block entry to the list.
785 set_postorder_number(postorder->length()); 787 set_postorder_number(postorder->length());
786 postorder->Add(this); 788 postorder->Add(this);
787 } 789 }
788 790
789 791
792 bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder,
793 GraphEntryInstr* graph_entry,
794 intptr_t osr_id,
795 BitVector* block_marks) {
796 // Search for the instruction with the OSR id. Use a depth first search
797 // because basic blocks have not been discovered yet. Prune unreachable
798 // blocks by replacing the normal entry with a jump to the block
799 // containing the OSR entry point.
800
801 // Do not visit blocks more than once.
802 if (block_marks->Contains(block_id())) return false;
803 block_marks->Add(block_id());
804
805 // Search this block for the OSR id.
806 Instruction* instr = this;
807 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) {
808 instr = it.Current();
809 if (instr->GetDeoptId() == osr_id) {
810 // Sanity check that we found a stack check instruction.
811 ASSERT(instr->IsCheckStackOverflow());
812 // Loop stack check checks are always in join blocks so that they can
813 // be the target of a goto.
814 ASSERT(IsJoinEntry());
815 // The instruction should be the first instruction in the block so
816 // we can simply jump to the beginning of the block.
817 ASSERT(instr->previous() == this);
818
819 GotoInstr* goto_join = new GotoInstr(AsJoinEntry());
820 goto_join->deopt_id_ = deopt_id_;
821 graph_entry->normal_entry()->LinkTo(goto_join);
822 return true;
823 }
824 }
825
826 // Recursively search the successors.
827 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) {
828 if (instr->SuccessorAt(i)->PruneUnreachable(builder,
829 graph_entry,
830 osr_id,
831 block_marks)) {
832 return true;
833 }
834 }
835 return false;
836 }
837
838
790 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { 839 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const {
791 // TODO(fschneider): Make this faster by e.g. storing dominators for each 840 // TODO(fschneider): Make this faster by e.g. storing dominators for each
792 // block while computing the dominator tree. 841 // block while computing the dominator tree.
793 ASSERT(other != NULL); 842 ASSERT(other != NULL);
794 BlockEntryInstr* current = other; 843 BlockEntryInstr* current = other;
795 while (current != NULL && current != this) { 844 while (current != NULL && current != this) {
796 current = current->dominator(); 845 current = current->dominator();
797 } 846 }
798 return current == this; 847 return current == this;
799 } 848 }
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 default: 2549 default:
2501 UNREACHABLE(); 2550 UNREACHABLE();
2502 } 2551 }
2503 return kPowRuntimeEntry; 2552 return kPowRuntimeEntry;
2504 } 2553 }
2505 2554
2506 2555
2507 #undef __ 2556 #undef __
2508 2557
2509 } // namespace dart 2558 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698