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 : public CallWrapper { | 40 class SafepointGenerator : 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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 1073 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
1058 break; | 1074 break; |
1059 } | 1075 } |
1060 default: | 1076 default: |
1061 UNREACHABLE(); | 1077 UNREACHABLE(); |
1062 } | 1078 } |
1063 } | 1079 } |
1064 | 1080 |
1065 | 1081 |
1066 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 1082 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
1067 // Record the address of the first unknown OSR value as the place to enter. | 1083 GenerateOsrPrologue(); |
1068 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
1069 } | 1084 } |
1070 | 1085 |
1071 | 1086 |
1072 void LCodeGen::DoModI(LModI* instr) { | 1087 void LCodeGen::DoModI(LModI* instr) { |
1073 HMod* hmod = instr->hydrogen(); | 1088 HMod* hmod = instr->hydrogen(); |
1074 HValue* left = hmod->left(); | 1089 HValue* left = hmod->left(); |
1075 HValue* right = hmod->right(); | 1090 HValue* right = hmod->right(); |
1076 if (hmod->HasPowerOf2Divisor()) { | 1091 if (hmod->HasPowerOf2Divisor()) { |
1077 // TODO(svenpanne) We should really do the strength reduction on the | 1092 // TODO(svenpanne) We should really do the strength reduction on the |
1078 // Hydrogen level. | 1093 // Hydrogen level. |
(...skipping 4660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5739 // This is a pseudo-instruction that ensures that the environment here is | 5754 // This is a pseudo-instruction that ensures that the environment here is |
5740 // properly registered for deoptimization and records the assembler's PC | 5755 // properly registered for deoptimization and records the assembler's PC |
5741 // offset. | 5756 // offset. |
5742 LEnvironment* environment = instr->environment(); | 5757 LEnvironment* environment = instr->environment(); |
5743 | 5758 |
5744 // If the environment were already registered, we would have no way of | 5759 // If the environment were already registered, we would have no way of |
5745 // backpatching it with the spill slot operands. | 5760 // backpatching it with the spill slot operands. |
5746 ASSERT(!environment->HasBeenRegistered()); | 5761 ASSERT(!environment->HasBeenRegistered()); |
5747 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 5762 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
5748 | 5763 |
5749 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 5764 GenerateOsrPrologue(); |
5750 // code, but if there were none, record the entrypoint here. | |
5751 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
5752 } | 5765 } |
5753 | 5766 |
5754 | 5767 |
5755 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 5768 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
5756 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 5769 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
5757 __ cmp(r0, ip); | 5770 __ cmp(r0, ip); |
5758 DeoptimizeIf(eq, instr->environment()); | 5771 DeoptimizeIf(eq, instr->environment()); |
5759 | 5772 |
5760 Register null_value = r5; | 5773 Register null_value = r5; |
5761 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 5774 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5842 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5855 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
5843 __ ldr(result, FieldMemOperand(scratch, | 5856 __ ldr(result, FieldMemOperand(scratch, |
5844 FixedArray::kHeaderSize - kPointerSize)); | 5857 FixedArray::kHeaderSize - kPointerSize)); |
5845 __ bind(&done); | 5858 __ bind(&done); |
5846 } | 5859 } |
5847 | 5860 |
5848 | 5861 |
5849 #undef __ | 5862 #undef __ |
5850 | 5863 |
5851 } } // namespace v8::internal | 5864 } } // namespace v8::internal |
OLD | NEW |