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

Side by Side Diff: runtime/vm/intermediate_language_x64.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_ia32.cc ('k') | runtime/vm/object.h » ('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/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 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 __ Bind(entry_label()); 2099 __ Bind(entry_label());
2099 compiler->SaveLiveRegisters(instruction_->locs()); 2100 compiler->SaveLiveRegisters(instruction_->locs());
2100 // pending_deoptimization_env_ is needed to generate a runtime call that 2101 // pending_deoptimization_env_ is needed to generate a runtime call that
2101 // may throw an exception. 2102 // may throw an exception.
2102 ASSERT(compiler->pending_deoptimization_env_ == NULL); 2103 ASSERT(compiler->pending_deoptimization_env_ == NULL);
2103 compiler->pending_deoptimization_env_ = instruction_->env(); 2104 compiler->pending_deoptimization_env_ = instruction_->env();
2104 compiler->GenerateCallRuntime(instruction_->token_pos(), 2105 compiler->GenerateCallRuntime(instruction_->token_pos(),
2105 instruction_->deopt_id(), 2106 instruction_->deopt_id(),
2106 kStackOverflowRuntimeEntry, 2107 kStackOverflowRuntimeEntry,
2107 instruction_->locs()); 2108 instruction_->locs());
2109
2110 if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) {
2111 // In unoptimized code, record loop stack checks as possible OSR entries.
2112 compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry,
2113 instruction_->deopt_id(),
2114 0); // No token position.
2115 }
2108 compiler->pending_deoptimization_env_ = NULL; 2116 compiler->pending_deoptimization_env_ = NULL;
2109 compiler->RestoreLiveRegisters(instruction_->locs()); 2117 compiler->RestoreLiveRegisters(instruction_->locs());
2110 __ jmp(exit_label()); 2118 __ jmp(exit_label());
2111 } 2119 }
2112 2120
2113 private: 2121 private:
2114 CheckStackOverflowInstr* instruction_; 2122 CheckStackOverflowInstr* instruction_;
2115 }; 2123 };
2116 2124
2117 2125
2118 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2126 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2119 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); 2127 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this);
2120 compiler->AddSlowPathCode(slow_path); 2128 compiler->AddSlowPathCode(slow_path);
2121 2129
2122 Register temp = locs()->temp(0).reg(); 2130 Register temp = locs()->temp(0).reg();
2123 // Generate stack overflow check. 2131 // Generate stack overflow check.
2124 __ movq(temp, Immediate(Isolate::Current()->stack_limit_address())); 2132 __ movq(temp, Immediate(Isolate::Current()->stack_limit_address()));
2125 __ cmpq(RSP, Address(temp, 0)); 2133 __ cmpq(RSP, Address(temp, 0));
2126 __ j(BELOW_EQUAL, slow_path->entry_label()); 2134 __ j(BELOW_EQUAL, slow_path->entry_label());
2135 if (FLAG_use_osr && !compiler->is_optimizing() && in_loop()) {
2136 // In unoptimized code check the usage counter to trigger OSR at loop
2137 // stack checks.
2138 __ LoadObject(temp, compiler->parsed_function().function());
2139 __ cmpq(FieldAddress(temp, Function::usage_counter_offset()),
2140 Immediate(2 * FLAG_optimization_counter_threshold));
2141 __ j(GREATER_EQUAL, slow_path->entry_label());
2142 }
2127 __ Bind(slow_path->exit_label()); 2143 __ Bind(slow_path->exit_label());
2128 } 2144 }
2129 2145
2130 2146
2131 static void Emit53BitOverflowCheck(FlowGraphCompiler* compiler, 2147 static void Emit53BitOverflowCheck(FlowGraphCompiler* compiler,
2132 Label* overflow, 2148 Label* overflow,
2133 Register result) { 2149 Register result) {
2134 if (FLAG_throw_on_javascript_int_overflow) { 2150 if (FLAG_throw_on_javascript_int_overflow) {
2135 ASSERT(overflow != NULL); 2151 ASSERT(overflow != NULL);
2136 __ movq(TMP, result); // result is a tagged Smi. 2152 __ movq(TMP, result); // result is a tagged Smi.
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after
4413 PcDescriptors::kOther, 4429 PcDescriptors::kOther,
4414 locs()); 4430 locs());
4415 __ Drop(2); // Discard type arguments and receiver. 4431 __ Drop(2); // Discard type arguments and receiver.
4416 } 4432 }
4417 4433
4418 } // namespace dart 4434 } // namespace dart
4419 4435
4420 #undef __ 4436 #undef __
4421 4437
4422 #endif // defined TARGET_ARCH_X64 4438 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698