OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 14 matching lines...) Expand all Loading... |
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 #if V8_TARGET_ARCH_X64 | 30 #if V8_TARGET_ARCH_X64 |
31 | 31 |
32 #include "x64/lithium-codegen-x64.h" | 32 #include "x64/lithium-codegen-x64.h" |
33 #include "code-stubs.h" | 33 #include "code-stubs.h" |
34 #include "stub-cache.h" | 34 #include "stub-cache.h" |
| 35 #include "hydrogen-osr.h" |
35 | 36 |
36 namespace v8 { | 37 namespace v8 { |
37 namespace internal { | 38 namespace internal { |
38 | 39 |
39 | 40 |
40 // When invoking builtins, we need to record the safepoint in the middle of | 41 // When invoking builtins, we need to record the safepoint in the middle of |
41 // the invoke instruction sequence generated by the macro assembler. | 42 // the invoke instruction sequence generated by the macro assembler. |
42 class SafepointGenerator V8_FINAL : public CallWrapper { | 43 class SafepointGenerator V8_FINAL : public CallWrapper { |
43 public: | 44 public: |
44 SafepointGenerator(LCodeGen* codegen, | 45 SafepointGenerator(LCodeGen* codegen, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 251 } |
251 | 252 |
252 // Trace the call. | 253 // Trace the call. |
253 if (FLAG_trace && info()->IsOptimizing()) { | 254 if (FLAG_trace && info()->IsOptimizing()) { |
254 __ CallRuntime(Runtime::kTraceEnter, 0); | 255 __ CallRuntime(Runtime::kTraceEnter, 0); |
255 } | 256 } |
256 return !is_aborted(); | 257 return !is_aborted(); |
257 } | 258 } |
258 | 259 |
259 | 260 |
| 261 void LCodeGen::GenerateOsrPrologue() { |
| 262 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
| 263 // are none, at the OSR entrypoint instruction. |
| 264 if (osr_pc_offset_ >= 0) return; |
| 265 |
| 266 osr_pc_offset_ = masm()->pc_offset(); |
| 267 |
| 268 // Adjust the frame size, subsuming the unoptimized frame into the |
| 269 // optimized frame. |
| 270 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
| 271 ASSERT(slots >= 0); |
| 272 __ subq(rsp, Immediate(slots * kPointerSize)); |
| 273 } |
| 274 |
| 275 |
260 bool LCodeGen::GenerateBody() { | 276 bool LCodeGen::GenerateBody() { |
261 ASSERT(is_generating()); | 277 ASSERT(is_generating()); |
262 bool emit_instructions = true; | 278 bool emit_instructions = true; |
263 for (current_instruction_ = 0; | 279 for (current_instruction_ = 0; |
264 !is_aborted() && current_instruction_ < instructions_->length(); | 280 !is_aborted() && current_instruction_ < instructions_->length(); |
265 current_instruction_++) { | 281 current_instruction_++) { |
266 LInstruction* instr = instructions_->at(current_instruction_); | 282 LInstruction* instr = instructions_->at(current_instruction_); |
267 | 283 |
268 // Don't emit code for basic blocks with a replacement. | 284 // Don't emit code for basic blocks with a replacement. |
269 if (instr->IsLabel()) { | 285 if (instr->IsLabel()) { |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 988 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
973 break; | 989 break; |
974 } | 990 } |
975 default: | 991 default: |
976 UNREACHABLE(); | 992 UNREACHABLE(); |
977 } | 993 } |
978 } | 994 } |
979 | 995 |
980 | 996 |
981 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 997 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
982 // Record the address of the first unknown OSR value as the place to enter. | 998 GenerateOsrPrologue(); |
983 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
984 } | 999 } |
985 | 1000 |
986 | 1001 |
987 void LCodeGen::DoModI(LModI* instr) { | 1002 void LCodeGen::DoModI(LModI* instr) { |
988 HMod* hmod = instr->hydrogen(); | 1003 HMod* hmod = instr->hydrogen(); |
989 HValue* left = hmod->left(); | 1004 HValue* left = hmod->left(); |
990 HValue* right = hmod->right(); | 1005 HValue* right = hmod->right(); |
991 if (hmod->HasPowerOf2Divisor()) { | 1006 if (hmod->HasPowerOf2Divisor()) { |
992 // TODO(svenpanne) We should really do the strength reduction on the | 1007 // TODO(svenpanne) We should really do the strength reduction on the |
993 // Hydrogen level. | 1008 // Hydrogen level. |
(...skipping 4456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5450 // This is a pseudo-instruction that ensures that the environment here is | 5465 // This is a pseudo-instruction that ensures that the environment here is |
5451 // properly registered for deoptimization and records the assembler's PC | 5466 // properly registered for deoptimization and records the assembler's PC |
5452 // offset. | 5467 // offset. |
5453 LEnvironment* environment = instr->environment(); | 5468 LEnvironment* environment = instr->environment(); |
5454 | 5469 |
5455 // If the environment were already registered, we would have no way of | 5470 // If the environment were already registered, we would have no way of |
5456 // backpatching it with the spill slot operands. | 5471 // backpatching it with the spill slot operands. |
5457 ASSERT(!environment->HasBeenRegistered()); | 5472 ASSERT(!environment->HasBeenRegistered()); |
5458 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 5473 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
5459 | 5474 |
5460 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 5475 GenerateOsrPrologue(); |
5461 // code, but if there were none, record the entrypoint here. | |
5462 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
5463 } | 5476 } |
5464 | 5477 |
5465 | 5478 |
5466 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 5479 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
5467 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 5480 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
5468 DeoptimizeIf(equal, instr->environment()); | 5481 DeoptimizeIf(equal, instr->environment()); |
5469 | 5482 |
5470 Register null_value = rdi; | 5483 Register null_value = rdi; |
5471 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 5484 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
5472 __ cmpq(rax, null_value); | 5485 __ cmpq(rax, null_value); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5550 FixedArray::kHeaderSize - kPointerSize)); | 5563 FixedArray::kHeaderSize - kPointerSize)); |
5551 __ bind(&done); | 5564 __ bind(&done); |
5552 } | 5565 } |
5553 | 5566 |
5554 | 5567 |
5555 #undef __ | 5568 #undef __ |
5556 | 5569 |
5557 } } // namespace v8::internal | 5570 } } // namespace v8::internal |
5558 | 5571 |
5559 #endif // V8_TARGET_ARCH_X64 | 5572 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |