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

Side by Side 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 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/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
11 #include "vm/dart_entry.h" 11 #include "vm/dart_entry.h"
12 #include "vm/flow_graph_compiler.h" 12 #include "vm/flow_graph_compiler.h"
13 #include "vm/locations.h" 13 #include "vm/locations.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/parser.h" 15 #include "vm/parser.h"
16 #include "vm/stack_frame.h" 16 #include "vm/stack_frame.h"
17 #include "vm/stub_code.h" 17 #include "vm/stub_code.h"
18 #include "vm/symbols.h" 18 #include "vm/symbols.h"
19 19
20 #define __ compiler->assembler()-> 20 #define __ compiler->assembler()->
21 21
22 namespace dart { 22 namespace dart {
23 23
24 DECLARE_FLAG(int, optimization_counter_threshold); 24 DECLARE_FLAG(int, optimization_counter_threshold);
25 DECLARE_FLAG(bool, propagate_ic_data); 25 DECLARE_FLAG(bool, propagate_ic_data);
26 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); 26 DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
27 DECLARE_FLAG(bool, use_osr);
27 28
28 // Generic summary for call instructions that have all arguments pushed 29 // Generic summary for call instructions that have all arguments pushed
29 // on the stack and return the result in a fixed register RAX. 30 // on the stack and return the result in a fixed register RAX.
30 LocationSummary* Instruction::MakeCallSummary() { 31 LocationSummary* Instruction::MakeCallSummary() {
31 LocationSummary* result = new LocationSummary(0, 0, LocationSummary::kCall); 32 LocationSummary* result = new LocationSummary(0, 0, LocationSummary::kCall);
32 result->set_out(Location::RegisterLocation(RAX)); 33 result->set_out(Location::RegisterLocation(RAX));
33 return result; 34 return result;
34 } 35 }
35 36
36 37
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 __ Bind(entry_label()); 2101 __ Bind(entry_label());
2101 compiler->SaveLiveRegisters(instruction_->locs()); 2102 compiler->SaveLiveRegisters(instruction_->locs());
2102 // pending_deoptimization_env_ is needed to generate a runtime call that 2103 // pending_deoptimization_env_ is needed to generate a runtime call that
2103 // may throw an exception. 2104 // may throw an exception.
2104 ASSERT(compiler->pending_deoptimization_env_ == NULL); 2105 ASSERT(compiler->pending_deoptimization_env_ == NULL);
2105 compiler->pending_deoptimization_env_ = instruction_->env(); 2106 compiler->pending_deoptimization_env_ = instruction_->env();
2106 compiler->GenerateCallRuntime(instruction_->token_pos(), 2107 compiler->GenerateCallRuntime(instruction_->token_pos(),
2107 instruction_->deopt_id(), 2108 instruction_->deopt_id(),
2108 kStackOverflowRuntimeEntry, 2109 kStackOverflowRuntimeEntry,
2109 instruction_->locs()); 2110 instruction_->locs());
2111
2112 if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->is_loop()) {
2113 // In unoptimized code, record loop stack checks as possible OSR entries.
2114 compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry,
2115 instruction_->deopt_id(),
2116 0); // No token position.
2117 }
2110 compiler->pending_deoptimization_env_ = NULL; 2118 compiler->pending_deoptimization_env_ = NULL;
2111 compiler->RestoreLiveRegisters(instruction_->locs()); 2119 compiler->RestoreLiveRegisters(instruction_->locs());
2112 __ jmp(exit_label()); 2120 __ jmp(exit_label());
2113 } 2121 }
2114 2122
2115 private: 2123 private:
2116 CheckStackOverflowInstr* instruction_; 2124 CheckStackOverflowInstr* instruction_;
2117 }; 2125 };
2118 2126
2119 2127
2120 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2128 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2121 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); 2129 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this);
2122 compiler->AddSlowPathCode(slow_path); 2130 compiler->AddSlowPathCode(slow_path);
2123 2131
2124 Register temp = locs()->temp(0).reg(); 2132 Register temp = locs()->temp(0).reg();
2125 // Generate stack overflow check. 2133 // Generate stack overflow check.
2126 __ movq(temp, Immediate(Isolate::Current()->stack_limit_address())); 2134 __ movq(temp, Immediate(Isolate::Current()->stack_limit_address()));
2127 __ cmpq(RSP, Address(temp, 0)); 2135 __ cmpq(RSP, Address(temp, 0));
2128 __ j(BELOW_EQUAL, slow_path->entry_label()); 2136 __ j(BELOW_EQUAL, slow_path->entry_label());
2137 if (FLAG_use_osr && !compiler->is_optimizing() && is_loop()) {
2138 // In unoptimized code check the usage counter to trigger OSR at loop
2139 // stack checks.
2140 __ LoadObject(temp, compiler->parsed_function().function());
2141 __ cmpq(FieldAddress(temp, Function::usage_counter_offset()),
2142 Immediate(2 * FLAG_optimization_counter_threshold));
2143 __ j(GREATER_EQUAL, slow_path->entry_label());
2144 }
2129 __ Bind(slow_path->exit_label()); 2145 __ Bind(slow_path->exit_label());
2130 } 2146 }
2131 2147
2132 2148
2133 static void Emit53BitOverflowCheck(FlowGraphCompiler* compiler, 2149 static void Emit53BitOverflowCheck(FlowGraphCompiler* compiler,
2134 Label* overflow, 2150 Label* overflow,
2135 Register result) { 2151 Register result) {
2136 if (FLAG_throw_on_javascript_int_overflow) { 2152 if (FLAG_throw_on_javascript_int_overflow) {
2137 ASSERT(overflow != NULL); 2153 ASSERT(overflow != NULL);
2138 __ movq(TMP, result); // result is a tagged Smi. 2154 __ movq(TMP, result); // result is a tagged Smi.
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
4415 PcDescriptors::kOther, 4431 PcDescriptors::kOther,
4416 locs()); 4432 locs());
4417 __ Drop(2); // Discard type arguments and receiver. 4433 __ Drop(2); // Discard type arguments and receiver.
4418 } 4434 }
4419 4435
4420 } // namespace dart 4436 } // namespace dart
4421 4437
4422 #undef __ 4438 #undef __
4423 4439
4424 #endif // defined TARGET_ARCH_X64 4440 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698