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

Unified Diff: runtime/vm/intermediate_language_x64.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/intermediate_language_x64.cc
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc
index f84bb4c18a33bc4efc7e9d5f011cdd8135e9fc75..6a5723a8f6c5b91b426c934e153edcdb9734a803 100644
--- a/runtime/vm/intermediate_language_x64.cc
+++ b/runtime/vm/intermediate_language_x64.cc
@@ -24,6 +24,7 @@ namespace dart {
DECLARE_FLAG(int, optimization_counter_threshold);
DECLARE_FLAG(bool, propagate_ic_data);
DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
+DECLARE_FLAG(bool, use_osr);
// Generic summary for call instructions that have all arguments pushed
// on the stack and return the result in a fixed register RAX.
@@ -2107,6 +2108,13 @@ class CheckStackOverflowSlowPath : public SlowPathCode {
instruction_->deopt_id(),
kStackOverflowRuntimeEntry,
instruction_->locs());
+
+ if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->is_loop()) {
+ // In unoptimized code, record loop stack checks as possible OSR entries.
+ compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry,
+ instruction_->deopt_id(),
+ 0); // No token position.
+ }
compiler->pending_deoptimization_env_ = NULL;
compiler->RestoreLiveRegisters(instruction_->locs());
__ jmp(exit_label());
@@ -2126,6 +2134,14 @@ void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ movq(temp, Immediate(Isolate::Current()->stack_limit_address()));
__ cmpq(RSP, Address(temp, 0));
__ j(BELOW_EQUAL, slow_path->entry_label());
+ if (FLAG_use_osr && !compiler->is_optimizing() && is_loop()) {
+ // In unoptimized code check the usage counter to trigger OSR at loop
+ // stack checks.
+ __ LoadObject(temp, compiler->parsed_function().function());
+ __ cmpq(FieldAddress(temp, Function::usage_counter_offset()),
+ Immediate(2 * FLAG_optimization_counter_threshold));
+ __ j(GREATER_EQUAL, slow_path->entry_label());
+ }
__ Bind(slow_path->exit_label());
}

Powered by Google App Engine
This is Rietveld 408576698