OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "arm/lithium-codegen-arm.h" | 30 #include "arm/lithium-codegen-arm.h" |
31 #include "arm/lithium-gap-resolver-arm.h" | 31 #include "arm/lithium-gap-resolver-arm.h" |
32 #include "code-stubs.h" | 32 #include "code-stubs.h" |
33 #include "stub-cache.h" | 33 #include "stub-cache.h" |
| 34 #include "hydrogen-osr.h" |
34 | 35 |
35 namespace v8 { | 36 namespace v8 { |
36 namespace internal { | 37 namespace internal { |
37 | 38 |
38 | 39 |
39 class SafepointGenerator V8_FINAL : public CallWrapper { | 40 class SafepointGenerator V8_FINAL : public CallWrapper { |
40 public: | 41 public: |
41 SafepointGenerator(LCodeGen* codegen, | 42 SafepointGenerator(LCodeGen* codegen, |
42 LPointerMap* pointers, | 43 LPointerMap* pointers, |
43 Safepoint::DeoptMode mode) | 44 Safepoint::DeoptMode mode) |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } | 247 } |
247 | 248 |
248 // Trace the call. | 249 // Trace the call. |
249 if (FLAG_trace && info()->IsOptimizing()) { | 250 if (FLAG_trace && info()->IsOptimizing()) { |
250 __ CallRuntime(Runtime::kTraceEnter, 0); | 251 __ CallRuntime(Runtime::kTraceEnter, 0); |
251 } | 252 } |
252 return !is_aborted(); | 253 return !is_aborted(); |
253 } | 254 } |
254 | 255 |
255 | 256 |
| 257 void LCodeGen::GenerateOsrPrologue() { |
| 258 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
| 259 // are none, at the OSR entrypoint instruction. |
| 260 if (osr_pc_offset_ >= 0) return; |
| 261 |
| 262 osr_pc_offset_ = masm()->pc_offset(); |
| 263 |
| 264 // Adjust the frame size, subsuming the unoptimized frame into the |
| 265 // optimized frame. |
| 266 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
| 267 ASSERT(slots >= 0); |
| 268 __ sub(sp, sp, Operand(slots * kPointerSize)); |
| 269 } |
| 270 |
| 271 |
256 bool LCodeGen::GenerateBody() { | 272 bool LCodeGen::GenerateBody() { |
257 ASSERT(is_generating()); | 273 ASSERT(is_generating()); |
258 bool emit_instructions = true; | 274 bool emit_instructions = true; |
259 for (current_instruction_ = 0; | 275 for (current_instruction_ = 0; |
260 !is_aborted() && current_instruction_ < instructions_->length(); | 276 !is_aborted() && current_instruction_ < instructions_->length(); |
261 current_instruction_++) { | 277 current_instruction_++) { |
262 LInstruction* instr = instructions_->at(current_instruction_); | 278 LInstruction* instr = instructions_->at(current_instruction_); |
263 | 279 |
264 // Don't emit code for basic blocks with a replacement. | 280 // Don't emit code for basic blocks with a replacement. |
265 if (instr->IsLabel()) { | 281 if (instr->IsLabel()) { |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 1107 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
1092 break; | 1108 break; |
1093 } | 1109 } |
1094 default: | 1110 default: |
1095 UNREACHABLE(); | 1111 UNREACHABLE(); |
1096 } | 1112 } |
1097 } | 1113 } |
1098 | 1114 |
1099 | 1115 |
1100 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 1116 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
1101 // Record the address of the first unknown OSR value as the place to enter. | 1117 GenerateOsrPrologue(); |
1102 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
1103 } | 1118 } |
1104 | 1119 |
1105 | 1120 |
1106 void LCodeGen::DoModI(LModI* instr) { | 1121 void LCodeGen::DoModI(LModI* instr) { |
1107 HMod* hmod = instr->hydrogen(); | 1122 HMod* hmod = instr->hydrogen(); |
1108 HValue* left = hmod->left(); | 1123 HValue* left = hmod->left(); |
1109 HValue* right = hmod->right(); | 1124 HValue* right = hmod->right(); |
1110 if (hmod->HasPowerOf2Divisor()) { | 1125 if (hmod->HasPowerOf2Divisor()) { |
1111 // TODO(svenpanne) We should really do the strength reduction on the | 1126 // TODO(svenpanne) We should really do the strength reduction on the |
1112 // Hydrogen level. | 1127 // Hydrogen level. |
(...skipping 4564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5677 // This is a pseudo-instruction that ensures that the environment here is | 5692 // This is a pseudo-instruction that ensures that the environment here is |
5678 // properly registered for deoptimization and records the assembler's PC | 5693 // properly registered for deoptimization and records the assembler's PC |
5679 // offset. | 5694 // offset. |
5680 LEnvironment* environment = instr->environment(); | 5695 LEnvironment* environment = instr->environment(); |
5681 | 5696 |
5682 // If the environment were already registered, we would have no way of | 5697 // If the environment were already registered, we would have no way of |
5683 // backpatching it with the spill slot operands. | 5698 // backpatching it with the spill slot operands. |
5684 ASSERT(!environment->HasBeenRegistered()); | 5699 ASSERT(!environment->HasBeenRegistered()); |
5685 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 5700 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
5686 | 5701 |
5687 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 5702 GenerateOsrPrologue(); |
5688 // code, but if there were none, record the entrypoint here. | |
5689 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
5690 } | 5703 } |
5691 | 5704 |
5692 | 5705 |
5693 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 5706 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
5694 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 5707 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
5695 __ cmp(r0, ip); | 5708 __ cmp(r0, ip); |
5696 DeoptimizeIf(eq, instr->environment()); | 5709 DeoptimizeIf(eq, instr->environment()); |
5697 | 5710 |
5698 Register null_value = r5; | 5711 Register null_value = r5; |
5699 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 5712 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5780 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5793 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
5781 __ ldr(result, FieldMemOperand(scratch, | 5794 __ ldr(result, FieldMemOperand(scratch, |
5782 FixedArray::kHeaderSize - kPointerSize)); | 5795 FixedArray::kHeaderSize - kPointerSize)); |
5783 __ bind(&done); | 5796 __ bind(&done); |
5784 } | 5797 } |
5785 | 5798 |
5786 | 5799 |
5787 #undef __ | 5800 #undef __ |
5788 | 5801 |
5789 } } // namespace v8::internal | 5802 } } // namespace v8::internal |
OLD | NEW |