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

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

Issue 2951053003: VM(RegExp): Allow OSR optimization of RegExp :matcher functions. (Closed)
Patch Set: Fix bugs with stack growing and block pruning Created 3 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
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/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/constant_propagator.h" 10 #include "vm/constant_propagator.h"
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) { 1077 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) {
1078 last = it.Current(); 1078 last = it.Current();
1079 } 1079 }
1080 set_last_instruction(last); 1080 set_last_instruction(last);
1081 if (last->IsGoto()) last->AsGoto()->set_block(this); 1081 if (last->IsGoto()) last->AsGoto()->set_block(this);
1082 1082
1083 return true; 1083 return true;
1084 } 1084 }
1085 1085
1086 1086
1087 void GraphEntryInstr::PruneUnreachableForOSR(Zone* zone,
1088 intptr_t max_block_id) {
1089 ASSERT(osr_id_ != Compiler::kNoOSRDeoptId);
1090 BitVector* block_marks = new (zone) BitVector(zone, max_block_id + 1);
1091 bool found = PruneUnreachable(this, /*parent=*/NULL, block_marks);
1092 ASSERT(found);
1093 }
1094
1095
1087 bool BlockEntryInstr::PruneUnreachable(GraphEntryInstr* graph_entry, 1096 bool BlockEntryInstr::PruneUnreachable(GraphEntryInstr* graph_entry,
1088 Instruction* parent, 1097 Instruction* parent,
1089 intptr_t osr_id,
1090 BitVector* block_marks) { 1098 BitVector* block_marks) {
1099 const intptr_t osr_id = graph_entry->osr_id();
1100
1091 // Search for the instruction with the OSR id. Use a depth first search 1101 // Search for the instruction with the OSR id. Use a depth first search
1092 // because basic blocks have not been discovered yet. Prune unreachable 1102 // because basic blocks have not been discovered yet. Prune unreachable
1093 // blocks by replacing the normal entry with a jump to the block 1103 // blocks by replacing the normal entry with a jump to the block
1094 // containing the OSR entry point. 1104 // containing the OSR entry point.
1095 1105
1096 // Do not visit blocks more than once. 1106 // Do not visit blocks more than once.
1097 if (block_marks->Contains(block_id())) return false; 1107 if (block_marks->Contains(block_id())) return false;
1098 block_marks->Add(block_id()); 1108 block_marks->Add(block_id());
1099 1109
1100 // Search this block for the OSR id. 1110 // Search this block for the OSR id.
(...skipping 13 matching lines...) Expand all
1114 GotoInstr* goto_join = 1124 GotoInstr* goto_join =
1115 new GotoInstr(AsJoinEntry(), Thread::Current()->GetNextDeoptId()); 1125 new GotoInstr(AsJoinEntry(), Thread::Current()->GetNextDeoptId());
1116 goto_join->CopyDeoptIdFrom(*parent); 1126 goto_join->CopyDeoptIdFrom(*parent);
1117 graph_entry->normal_entry()->LinkTo(goto_join); 1127 graph_entry->normal_entry()->LinkTo(goto_join);
1118 return true; 1128 return true;
1119 } 1129 }
1120 } 1130 }
1121 1131
1122 // Recursively search the successors. 1132 // Recursively search the successors.
1123 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) { 1133 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) {
1124 if (instr->SuccessorAt(i)->PruneUnreachable(graph_entry, instr, osr_id, 1134 if (instr->SuccessorAt(i)->PruneUnreachable(graph_entry, instr,
1125 block_marks)) { 1135 block_marks)) {
1126 return true; 1136 return true;
1127 } 1137 }
1128 } 1138 }
1129 return false; 1139 return false;
1130 } 1140 }
1131 1141
1132 1142
1133 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const { 1143 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const {
1134 // TODO(fschneider): Make this faster by e.g. storing dominators for each 1144 // TODO(fschneider): Make this faster by e.g. storing dominators for each
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 return NULL; 2069 return NULL;
2060 } 2070 }
2061 if ((constrained_type() != NULL) && 2071 if ((constrained_type() != NULL) &&
2062 Type()->IsEqualTo(value()->definition()->Type())) { 2072 Type()->IsEqualTo(value()->definition()->Type())) {
2063 return value()->definition(); 2073 return value()->definition();
2064 } 2074 }
2065 return this; 2075 return this;
2066 } 2076 }
2067 2077
2068 2078
2079 Instruction* CheckStackOverflowInstr::Canonicalize(FlowGraph* flow_graph) {
2080 switch (kind_) {
2081 case kOsrAndPreemption:
2082 return this;
2083 case kOsrOnly:
2084 // Don't need OSR entries in the optimized code.
2085 return NULL;
2086 }
2087
2088 // Switch above exhausts all possibilities but some compilers can't figure
2089 // it out.
2090 UNREACHABLE();
2091 return this;
2092 }
2093
2094
2069 bool LoadFieldInstr::IsImmutableLengthLoad() const { 2095 bool LoadFieldInstr::IsImmutableLengthLoad() const {
2070 switch (recognized_kind()) { 2096 switch (recognized_kind()) {
2071 case MethodRecognizer::kObjectArrayLength: 2097 case MethodRecognizer::kObjectArrayLength:
2072 case MethodRecognizer::kImmutableArrayLength: 2098 case MethodRecognizer::kImmutableArrayLength:
2073 case MethodRecognizer::kTypedDataLength: 2099 case MethodRecognizer::kTypedDataLength:
2074 case MethodRecognizer::kStringBaseLength: 2100 case MethodRecognizer::kStringBaseLength:
2075 return true; 2101 return true;
2076 default: 2102 default:
2077 return false; 2103 return false;
2078 } 2104 }
(...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after
4359 "native function '%s' (%" Pd " arguments) cannot be found", 4385 "native function '%s' (%" Pd " arguments) cannot be found",
4360 native_name().ToCString(), function().NumParameters()); 4386 native_name().ToCString(), function().NumParameters());
4361 } 4387 }
4362 set_is_auto_scope(auto_setup_scope); 4388 set_is_auto_scope(auto_setup_scope);
4363 set_native_c_function(native_function); 4389 set_native_c_function(native_function);
4364 } 4390 }
4365 4391
4366 #undef __ 4392 #undef __
4367 4393
4368 } // namespace dart 4394 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698