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

Unified Diff: runtime/vm/flow_graph_compiler.cc

Issue 16693006: Initial implementation of on-stack replacement (OSR). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up for review. 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_compiler.cc
diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc
index d56842fe96e9f4b3bf65fee58e13db88fe05e7e1..f2de1379f470cdb118771bffb59febb6901ec91e 100644
--- a/runtime/vm/flow_graph_compiler.cc
+++ b/runtime/vm/flow_graph_compiler.cc
@@ -101,19 +101,25 @@ void FlowGraphCompiler::InitCompiler() {
pc_descriptors_list_ = new DescriptorList(64);
exception_handlers_list_ = new ExceptionHandlerList();
block_info_.Clear();
- bool is_leaf = !parsed_function().function().IsClosureFunction() &&
- is_optimizing();
+ // Conservative detection of leaf routines used to remove the stack check
+ // on function entry.
+ bool is_leaf = !parsed_function().function().IsClosureFunction()
+ && is_optimizing()
+ && !flow_graph().IsCompiledForOsr();
+ // Initialize block info and search optimized (non-OSR) code for calls
+ // indicating a non-leaf routine and calls without IC data indicating
+ // possible reoptimization.
for (int i = 0; i < block_order_.length(); ++i) {
block_info_.Add(new BlockInfo());
- if (is_optimizing()) {
+ if (is_optimizing() && !flow_graph().IsCompiledForOsr()) {
BlockEntryInstr* entry = block_order_[i];
for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
Instruction* current = it.Current();
- const ICData* ic_data = NULL;
if (current->IsBranch()) {
current = current->AsBranch()->comparison();
}
// In optimized code, ICData is always set in the instructions.
+ const ICData* ic_data = NULL;
if (current->IsInstanceCall()) {
ic_data = current->AsInstanceCall()->ic_data();
ASSERT(ic_data != NULL);
@@ -126,10 +132,9 @@ void FlowGraphCompiler::InitCompiler() {
}
if ((ic_data != NULL) && (ic_data->NumberOfChecks() == 0)) {
may_reoptimize_ = true;
- break;
}
if (is_leaf && !current->IsCheckStackOverflow()) {
- // Note that we do no care if the code contains instructions that
+ // Note that we do not care if the code contains instructions that
// can deoptimize.
LocationSummary* locs = current->locs();
if ((locs != NULL) && locs->can_call()) {
@@ -140,11 +145,10 @@ void FlowGraphCompiler::InitCompiler() {
}
}
if (is_leaf) {
- // Remove check stack overflow at entry.
- CheckStackOverflowInstr* check = flow_graph_.graph_entry()->normal_entry()
- ->next()->AsCheckStackOverflow();
- ASSERT(check != NULL);
- check->RemoveFromGraph();
+ // Remove the stack overflow check at function entry.
+ Instruction* first = flow_graph_.graph_entry()->normal_entry()->next();
+ ASSERT(first->IsCheckStackOverflow());
+ if (first->IsCheckStackOverflow()) first->RemoveFromGraph();
}
}
@@ -554,7 +558,9 @@ void FlowGraphCompiler::GenerateInstanceCall(
}
// Emit IC call that will count and thus may need reoptimization at
// function entry.
- ASSERT(!is_optimizing() || may_reoptimize());
+ ASSERT(!is_optimizing()
+ || may_reoptimize()
+ || flow_graph().IsCompiledForOsr());
switch (ic_data.num_args_tested()) {
case 1:
label_address = StubCode::OneArgOptimizedCheckInlineCacheEntryPoint();

Powered by Google App Engine
This is Rietveld 408576698