| 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 : public CallWrapper { | 43 class SafepointGenerator : public CallWrapper { |
| 43 public: | 44 public: |
| 44 SafepointGenerator(LCodeGen* codegen, | 45 SafepointGenerator(LCodeGen* codegen, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 246 } |
| 246 | 247 |
| 247 // Trace the call. | 248 // Trace the call. |
| 248 if (FLAG_trace && info()->IsOptimizing()) { | 249 if (FLAG_trace && info()->IsOptimizing()) { |
| 249 __ CallRuntime(Runtime::kTraceEnter, 0); | 250 __ CallRuntime(Runtime::kTraceEnter, 0); |
| 250 } | 251 } |
| 251 return !is_aborted(); | 252 return !is_aborted(); |
| 252 } | 253 } |
| 253 | 254 |
| 254 | 255 |
| 256 void LCodeGen::GenerateOsrPrologue() { |
| 257 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
| 258 // are none, at the OSR entrypoint instruction. |
| 259 if (osr_pc_offset_ >= 0) return; |
| 260 |
| 261 osr_pc_offset_ = masm()->pc_offset(); |
| 262 |
| 263 // Adjust the frame size, subsuming the unoptimized frame into the |
| 264 // optimized frame. |
| 265 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
| 266 ASSERT(slots >= 0); |
| 267 __ subq(rsp, Immediate(slots * kPointerSize)); |
| 268 } |
| 269 |
| 270 |
| 255 bool LCodeGen::GenerateBody() { | 271 bool LCodeGen::GenerateBody() { |
| 256 ASSERT(is_generating()); | 272 ASSERT(is_generating()); |
| 257 bool emit_instructions = true; | 273 bool emit_instructions = true; |
| 258 for (current_instruction_ = 0; | 274 for (current_instruction_ = 0; |
| 259 !is_aborted() && current_instruction_ < instructions_->length(); | 275 !is_aborted() && current_instruction_ < instructions_->length(); |
| 260 current_instruction_++) { | 276 current_instruction_++) { |
| 261 LInstruction* instr = instructions_->at(current_instruction_); | 277 LInstruction* instr = instructions_->at(current_instruction_); |
| 262 | 278 |
| 263 // Don't emit code for basic blocks with a replacement. | 279 // Don't emit code for basic blocks with a replacement. |
| 264 if (instr->IsLabel()) { | 280 if (instr->IsLabel()) { |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 949 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
| 934 break; | 950 break; |
| 935 } | 951 } |
| 936 default: | 952 default: |
| 937 UNREACHABLE(); | 953 UNREACHABLE(); |
| 938 } | 954 } |
| 939 } | 955 } |
| 940 | 956 |
| 941 | 957 |
| 942 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 958 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
| 943 // Record the address of the first unknown OSR value as the place to enter. | 959 GenerateOsrPrologue(); |
| 944 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
| 945 } | 960 } |
| 946 | 961 |
| 947 | 962 |
| 948 void LCodeGen::DoModI(LModI* instr) { | 963 void LCodeGen::DoModI(LModI* instr) { |
| 949 HMod* hmod = instr->hydrogen(); | 964 HMod* hmod = instr->hydrogen(); |
| 950 HValue* left = hmod->left(); | 965 HValue* left = hmod->left(); |
| 951 HValue* right = hmod->right(); | 966 HValue* right = hmod->right(); |
| 952 if (hmod->HasPowerOf2Divisor()) { | 967 if (hmod->HasPowerOf2Divisor()) { |
| 953 // TODO(svenpanne) We should really do the strength reduction on the | 968 // TODO(svenpanne) We should really do the strength reduction on the |
| 954 // Hydrogen level. | 969 // Hydrogen level. |
| (...skipping 4523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5478 // This is a pseudo-instruction that ensures that the environment here is | 5493 // This is a pseudo-instruction that ensures that the environment here is |
| 5479 // properly registered for deoptimization and records the assembler's PC | 5494 // properly registered for deoptimization and records the assembler's PC |
| 5480 // offset. | 5495 // offset. |
| 5481 LEnvironment* environment = instr->environment(); | 5496 LEnvironment* environment = instr->environment(); |
| 5482 | 5497 |
| 5483 // If the environment were already registered, we would have no way of | 5498 // If the environment were already registered, we would have no way of |
| 5484 // backpatching it with the spill slot operands. | 5499 // backpatching it with the spill slot operands. |
| 5485 ASSERT(!environment->HasBeenRegistered()); | 5500 ASSERT(!environment->HasBeenRegistered()); |
| 5486 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 5501 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
| 5487 | 5502 |
| 5488 // Normally we record the first unknown OSR value as the entrypoint to the OSR | 5503 GenerateOsrPrologue(); |
| 5489 // code, but if there were none, record the entrypoint here. | |
| 5490 if (osr_pc_offset_ == -1) osr_pc_offset_ = masm()->pc_offset(); | |
| 5491 } | 5504 } |
| 5492 | 5505 |
| 5493 | 5506 |
| 5494 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { | 5507 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) { |
| 5495 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 5508 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
| 5496 DeoptimizeIf(equal, instr->environment()); | 5509 DeoptimizeIf(equal, instr->environment()); |
| 5497 | 5510 |
| 5498 Register null_value = rdi; | 5511 Register null_value = rdi; |
| 5499 __ LoadRoot(null_value, Heap::kNullValueRootIndex); | 5512 __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
| 5500 __ cmpq(rax, null_value); | 5513 __ cmpq(rax, null_value); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5578 FixedArray::kHeaderSize - kPointerSize)); | 5591 FixedArray::kHeaderSize - kPointerSize)); |
| 5579 __ bind(&done); | 5592 __ bind(&done); |
| 5580 } | 5593 } |
| 5581 | 5594 |
| 5582 | 5595 |
| 5583 #undef __ | 5596 #undef __ |
| 5584 | 5597 |
| 5585 } } // namespace v8::internal | 5598 } } // namespace v8::internal |
| 5586 | 5599 |
| 5587 #endif // V8_TARGET_ARCH_X64 | 5600 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |