| OLD | NEW |
| 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); | |
| 27 | 26 |
| 28 // Generic summary for call instructions that have all arguments pushed | 27 // Generic summary for call instructions that have all arguments pushed |
| 29 // on the stack and return the result in a fixed register EAX. | 28 // on the stack and return the result in a fixed register EAX. |
| 30 LocationSummary* Instruction::MakeCallSummary() { | 29 LocationSummary* Instruction::MakeCallSummary() { |
| 31 LocationSummary* result = new LocationSummary(0, 0, LocationSummary::kCall); | 30 LocationSummary* result = new LocationSummary(0, 0, LocationSummary::kCall); |
| 32 result->set_out(Location::RegisterLocation(EAX)); | 31 result->set_out(Location::RegisterLocation(EAX)); |
| 33 return result; | 32 return result; |
| 34 } | 33 } |
| 35 | 34 |
| 36 | 35 |
| (...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 __ Bind(entry_label()); | 2109 __ Bind(entry_label()); |
| 2111 compiler->SaveLiveRegisters(instruction_->locs()); | 2110 compiler->SaveLiveRegisters(instruction_->locs()); |
| 2112 // pending_deoptimization_env_ is needed to generate a runtime call that | 2111 // pending_deoptimization_env_ is needed to generate a runtime call that |
| 2113 // may throw an exception. | 2112 // may throw an exception. |
| 2114 ASSERT(compiler->pending_deoptimization_env_ == NULL); | 2113 ASSERT(compiler->pending_deoptimization_env_ == NULL); |
| 2115 compiler->pending_deoptimization_env_ = instruction_->env(); | 2114 compiler->pending_deoptimization_env_ = instruction_->env(); |
| 2116 compiler->GenerateCallRuntime(instruction_->token_pos(), | 2115 compiler->GenerateCallRuntime(instruction_->token_pos(), |
| 2117 instruction_->deopt_id(), | 2116 instruction_->deopt_id(), |
| 2118 kStackOverflowRuntimeEntry, | 2117 kStackOverflowRuntimeEntry, |
| 2119 instruction_->locs()); | 2118 instruction_->locs()); |
| 2120 | |
| 2121 if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) { | |
| 2122 // In unoptimized code, record loop stack checks as possible OSR entries. | |
| 2123 compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry, | |
| 2124 instruction_->deopt_id(), | |
| 2125 0); // No token position. | |
| 2126 } | |
| 2127 compiler->pending_deoptimization_env_ = NULL; | 2119 compiler->pending_deoptimization_env_ = NULL; |
| 2128 compiler->RestoreLiveRegisters(instruction_->locs()); | 2120 compiler->RestoreLiveRegisters(instruction_->locs()); |
| 2129 __ jmp(exit_label()); | 2121 __ jmp(exit_label()); |
| 2130 } | 2122 } |
| 2131 | 2123 |
| 2132 private: | 2124 private: |
| 2133 CheckStackOverflowInstr* instruction_; | 2125 CheckStackOverflowInstr* instruction_; |
| 2134 }; | 2126 }; |
| 2135 | 2127 |
| 2136 | 2128 |
| 2137 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 2129 void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 2138 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); | 2130 CheckStackOverflowSlowPath* slow_path = new CheckStackOverflowSlowPath(this); |
| 2139 compiler->AddSlowPathCode(slow_path); | 2131 compiler->AddSlowPathCode(slow_path); |
| 2140 | 2132 |
| 2141 __ cmpl(ESP, | 2133 __ cmpl(ESP, |
| 2142 Address::Absolute(Isolate::Current()->stack_limit_address())); | 2134 Address::Absolute(Isolate::Current()->stack_limit_address())); |
| 2143 __ j(BELOW_EQUAL, slow_path->entry_label()); | 2135 __ j(BELOW_EQUAL, slow_path->entry_label()); |
| 2144 if (FLAG_use_osr && !compiler->is_optimizing() && in_loop()) { | |
| 2145 // In unoptimized code check the usage counter to trigger OSR at loop | |
| 2146 // stack checks. | |
| 2147 __ LoadObject(EDI, compiler->parsed_function().function()); | |
| 2148 __ cmpl(FieldAddress(EDI, Function::usage_counter_offset()), | |
| 2149 Immediate(2 * FLAG_optimization_counter_threshold)); | |
| 2150 __ j(GREATER_EQUAL, slow_path->entry_label()); | |
| 2151 } | |
| 2152 __ Bind(slow_path->exit_label()); | 2136 __ Bind(slow_path->exit_label()); |
| 2153 } | 2137 } |
| 2154 | 2138 |
| 2155 | 2139 |
| 2156 static void EmitSmiShiftLeft(FlowGraphCompiler* compiler, | 2140 static void EmitSmiShiftLeft(FlowGraphCompiler* compiler, |
| 2157 BinarySmiOpInstr* shift_left) { | 2141 BinarySmiOpInstr* shift_left) { |
| 2158 const bool is_truncating = shift_left->is_truncating(); | 2142 const bool is_truncating = shift_left->is_truncating(); |
| 2159 const LocationSummary& locs = *shift_left->locs(); | 2143 const LocationSummary& locs = *shift_left->locs(); |
| 2160 Register left = locs.in(0).reg(); | 2144 Register left = locs.in(0).reg(); |
| 2161 Register result = locs.out().reg(); | 2145 Register result = locs.out().reg(); |
| (...skipping 2591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4753 PcDescriptors::kOther, | 4737 PcDescriptors::kOther, |
| 4754 locs()); | 4738 locs()); |
| 4755 __ Drop(2); // Discard type arguments and receiver. | 4739 __ Drop(2); // Discard type arguments and receiver. |
| 4756 } | 4740 } |
| 4757 | 4741 |
| 4758 } // namespace dart | 4742 } // namespace dart |
| 4759 | 4743 |
| 4760 #undef __ | 4744 #undef __ |
| 4761 | 4745 |
| 4762 #endif // defined TARGET_ARCH_IA32 | 4746 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |