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

Side by Side Diff: runtime/vm/intermediate_language_ia32.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.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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, use_osr);
26 27
27 // Generic summary for call instructions that have all arguments pushed 28 // Generic summary for call instructions that have all arguments pushed
28 // on the stack and return the result in a fixed register EAX. 29 // on the stack and return the result in a fixed register EAX.
29 LocationSummary* Instruction::MakeCallSummary() { 30 LocationSummary* Instruction::MakeCallSummary() {
30 LocationSummary* result = new LocationSummary(0, 0, LocationSummary::kCall); 31 LocationSummary* result = new LocationSummary(0, 0, LocationSummary::kCall);
31 result->set_out(Location::RegisterLocation(EAX)); 32 result->set_out(Location::RegisterLocation(EAX));
32 return result; 33 return result;
33 } 34 }
34 35
35 36
(...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 __ Bind(entry_label()); 2116 __ Bind(entry_label());
2116 compiler->SaveLiveRegisters(instruction_->locs()); 2117 compiler->SaveLiveRegisters(instruction_->locs());
2117 // pending_deoptimization_env_ is needed to generate a runtime call that 2118 // pending_deoptimization_env_ is needed to generate a runtime call that
2118 // may throw an exception. 2119 // may throw an exception.
2119 ASSERT(compiler->pending_deoptimization_env_ == NULL); 2120 ASSERT(compiler->pending_deoptimization_env_ == NULL);
2120 compiler->pending_deoptimization_env_ = instruction_->env(); 2121 compiler->pending_deoptimization_env_ = instruction_->env();
2121 compiler->GenerateCallRuntime(instruction_->token_pos(), 2122 compiler->GenerateCallRuntime(instruction_->token_pos(),
2122 instruction_->deopt_id(), 2123 instruction_->deopt_id(),
2123 kStackOverflowRuntimeEntry, 2124 kStackOverflowRuntimeEntry,
2124 instruction_->locs()); 2125 instruction_->locs());
2126
2127 if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) {
2128 // In unoptimized code, record loop stack checks as possible OSR entries.
2129 compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry,
2130 instruction_->deopt_id(),
2131 0); // No token position.
2132 }
2125 compiler->pending_deoptimization_env_ = NULL; 2133 compiler->pending_deoptimization_env_ = NULL;
2126 compiler->RestoreLiveRegisters(instruction_->locs()); 2134 compiler->RestoreLiveRegisters(instruction_->locs());
2127 __ jmp(exit_label()); 2135 __ jmp(exit_label());
2128 } 2136 }
2129 2137
2130 private: 2138 private:
2131 CheckStackOverflowInstr* instruction_; 2139 CheckStackOverflowInstr* instruction_;
2132 }; 2140 };
2133 2141
2134 2142
2135 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2143 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2136 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); 2144 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this);
2137 compiler->AddSlowPathCode(slow_path); 2145 compiler->AddSlowPathCode(slow_path);
2138 2146
2139 __ cmpl(ESP, 2147 __ cmpl(ESP,
2140 Address::Absolute(Isolate::Current()->stack_limit_address())); 2148 Address::Absolute(Isolate::Current()->stack_limit_address()));
2141 __ j(BELOW_EQUAL, slow_path->entry_label()); 2149 __ j(BELOW_EQUAL, slow_path->entry_label());
2150 if (FLAG_use_osr && !compiler->is_optimizing() && in_loop()) {
2151 // In unoptimized code check the usage counter to trigger OSR at loop
2152 // stack checks.
2153 __ LoadObject(EDI, compiler->parsed_function().function());
2154 __ cmpl(FieldAddress(EDI, Function::usage_counter_offset()),
2155 Immediate(2 * FLAG_optimization_counter_threshold));
2156 __ j(GREATER_EQUAL, slow_path->entry_label());
2157 }
2142 __ Bind(slow_path->exit_label()); 2158 __ Bind(slow_path->exit_label());
2143 } 2159 }
2144 2160
2145 2161
2146 static void EmitSmiShiftLeft(FlowGraphCompiler* compiler, 2162 static void EmitSmiShiftLeft(FlowGraphCompiler* compiler,
2147 BinarySmiOpInstr* shift_left) { 2163 BinarySmiOpInstr* shift_left) {
2148 const bool is_truncating = shift_left->is_truncating(); 2164 const bool is_truncating = shift_left->is_truncating();
2149 const LocationSummary& locs = *shift_left->locs(); 2165 const LocationSummary& locs = *shift_left->locs();
2150 Register left = locs.in(0).reg(); 2166 Register left = locs.in(0).reg();
2151 Register result = locs.out().reg(); 2167 Register result = locs.out().reg();
(...skipping 2591 matching lines...) Expand 10 before | Expand all | Expand 10 after
4743 PcDescriptors::kOther, 4759 PcDescriptors::kOther,
4744 locs()); 4760 locs());
4745 __ Drop(2); // Discard type arguments and receiver. 4761 __ Drop(2); // Discard type arguments and receiver.
4746 } 4762 }
4747 4763
4748 } // namespace dart 4764 } // namespace dart
4749 4765
4750 #undef __ 4766 #undef __
4751 4767
4752 #endif // defined TARGET_ARCH_IA32 4768 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698