Index: src/ppc/deoptimizer-ppc.cc |
diff --git a/src/arm/deoptimizer-arm.cc b/src/ppc/deoptimizer-ppc.cc |
similarity index 56% |
copy from src/arm/deoptimizer-arm.cc |
copy to src/ppc/deoptimizer-ppc.cc |
index 0455a3ba679a50314836bfa0b9d65be18687ed96..58e9e939f561b3f875ff238b897ace00add2ecac 100644 |
--- a/src/arm/deoptimizer-arm.cc |
+++ b/src/ppc/deoptimizer-ppc.cc |
@@ -1,4 +1,4 @@ |
-// Copyright 2012 the V8 project authors. All rights reserved. |
+// Copyright 2014 the V8 project authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -16,13 +16,18 @@ const int Deoptimizer::table_entry_size_ = 8; |
int Deoptimizer::patch_size() { |
- const int kCallInstructionSizeInWords = 3; |
+#if V8_TARGET_ARCH_PPC64 |
+ const int kCallInstructionSizeInWords = 7; |
+#else |
+ const int kCallInstructionSizeInWords = 4; |
+#endif |
return kCallInstructionSizeInWords * Assembler::kInstrSize; |
} |
void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { |
Address code_start_address = code->instruction_start(); |
+ |
// Invalidate the relocation information, as it will become invalid by the |
// code patching below, and is not needed any more. |
code->InvalidateRelocation(); |
@@ -60,15 +65,13 @@ void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { |
Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); |
// We need calls to have a predictable size in the unoptimized code, but |
// this is optimized code, so we don't have to have a predictable size. |
- int call_size_in_bytes = |
- MacroAssembler::CallSizeNotPredictableCodeSize(isolate, |
- deopt_entry, |
- RelocInfo::NONE32); |
+ int call_size_in_bytes = MacroAssembler::CallSizeNotPredictableCodeSize( |
+ deopt_entry, kRelocInfo_NONEPTR); |
int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; |
DCHECK(call_size_in_bytes % Assembler::kInstrSize == 0); |
DCHECK(call_size_in_bytes <= patch_size()); |
CodePatcher patcher(call_address, call_size_in_words); |
- patcher.masm()->Call(deopt_entry, RelocInfo::NONE32); |
+ patcher.masm()->Call(deopt_entry, kRelocInfo_NONEPTR); |
DCHECK(prev_call_address == NULL || |
call_address >= prev_call_address + patch_size()); |
DCHECK(call_address + patch_size() <= code->instruction_end()); |
@@ -95,7 +98,8 @@ void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
// Fill the frame content from the actual data on the frame. |
for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
- input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); |
+ input_->SetFrameSlot( |
+ i, reinterpret_cast<intptr_t>(Memory::Address_at(tos + i))); |
} |
} |
@@ -106,13 +110,13 @@ void Deoptimizer::SetPlatformCompiledStubRegisters( |
ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); |
intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); |
int params = descriptor->GetHandlerParameterCount(); |
- output_frame->SetRegister(r0.code(), params); |
- output_frame->SetRegister(r1.code(), handler); |
+ output_frame->SetRegister(r3.code(), params); |
+ output_frame->SetRegister(r4.code(), handler); |
} |
void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { |
- for (int i = 0; i < DwVfpRegister::kMaxNumRegisters; ++i) { |
+ for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) { |
double double_value = input_->GetDoubleRegister(i); |
output_frame->SetDoubleRegister(i, double_value); |
} |
@@ -120,7 +124,7 @@ void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { |
bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { |
- // There is no dynamic alignment padding on ARM in the input frame. |
+ // There is no dynamic alignment padding on PPC in the input frame. |
return false; |
} |
@@ -132,199 +136,195 @@ bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { |
void Deoptimizer::EntryGenerator::Generate() { |
GeneratePrologue(); |
- // Save all general purpose registers before messing with them. |
+ // Unlike on ARM we don't save all the registers, just the useful ones. |
+ // For the rest, there are gaps on the stack, so the offsets remain the same. |
const int kNumberOfRegisters = Register::kNumRegisters; |
- // Everything but pc, lr and ip which will be saved but not restored. |
- RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); |
+ RegList restored_regs = kJSCallerSaved | kCalleeSaved; |
+ RegList saved_regs = restored_regs | sp.bit(); |
const int kDoubleRegsSize = |
- kDoubleSize * DwVfpRegister::kMaxNumAllocatableRegisters; |
- |
- // Save all allocatable VFP registers before messing with them. |
- DCHECK(kDoubleRegZero.code() == 14); |
- DCHECK(kScratchDoubleReg.code() == 15); |
- |
- // Check CPU flags for number of registers, setting the Z condition flag. |
- __ CheckFor32DRegs(ip); |
- |
- // Push registers d0-d13, and possibly d16-d31, on the stack. |
- // If d16-d31 are not pushed, decrease the stack pointer instead. |
- __ vstm(db_w, sp, d16, d31, ne); |
- __ sub(sp, sp, Operand(16 * kDoubleSize), LeaveCC, eq); |
- __ vstm(db_w, sp, d0, d13); |
+ kDoubleSize * DoubleRegister::kMaxNumAllocatableRegisters; |
+ |
+ // Save all FPU registers before messing with them. |
+ __ subi(sp, sp, Operand(kDoubleRegsSize)); |
+ for (int i = 0; i < DoubleRegister::kMaxNumAllocatableRegisters; ++i) { |
+ DoubleRegister fpu_reg = DoubleRegister::FromAllocationIndex(i); |
+ int offset = i * kDoubleSize; |
+ __ stfd(fpu_reg, MemOperand(sp, offset)); |
+ } |
- // Push all 16 registers (needed to populate FrameDescription::registers_). |
- // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps |
- // handle this a bit differently. |
- __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); |
+ // Push saved_regs (needed to populate FrameDescription::registers_). |
+ // Leave gaps for other registers. |
+ __ subi(sp, sp, Operand(kNumberOfRegisters * kPointerSize)); |
+ for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { |
+ if ((saved_regs & (1 << i)) != 0) { |
+ __ StoreP(ToRegister(i), MemOperand(sp, kPointerSize * i)); |
+ } |
+ } |
const int kSavedRegistersAreaSize = |
(kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; |
// Get the bailout id from the stack. |
- __ ldr(r2, MemOperand(sp, kSavedRegistersAreaSize)); |
+ __ LoadP(r5, MemOperand(sp, kSavedRegistersAreaSize)); |
- // Get the address of the location in the code object (r3) (return |
+ // Get the address of the location in the code object (r6) (return |
// address for lazy deoptimization) and compute the fp-to-sp delta in |
- // register r4. |
- __ mov(r3, lr); |
+ // register r7. |
+ __ mflr(r6); |
// Correct one word for bailout id. |
- __ add(r4, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
- __ sub(r4, fp, r4); |
+ __ addi(r7, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
+ __ sub(r7, fp, r7); |
// Allocate a new deoptimizer object. |
- // Pass four arguments in r0 to r3 and fifth argument on stack. |
- __ PrepareCallCFunction(6, r5); |
- __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
- __ mov(r1, Operand(type())); // bailout type, |
- // r2: bailout id already loaded. |
- // r3: code address or 0 already loaded. |
- __ str(r4, MemOperand(sp, 0 * kPointerSize)); // Fp-to-sp delta. |
- __ mov(r5, Operand(ExternalReference::isolate_address(isolate()))); |
- __ str(r5, MemOperand(sp, 1 * kPointerSize)); // Isolate. |
+ // Pass six arguments in r3 to r8. |
+ __ PrepareCallCFunction(6, r8); |
+ __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
+ __ li(r4, Operand(type())); // bailout type, |
+ // r5: bailout id already loaded. |
+ // r6: code address or 0 already loaded. |
+ // r7: Fp-to-sp delta. |
+ __ mov(r8, Operand(ExternalReference::isolate_address(isolate()))); |
// Call Deoptimizer::New(). |
{ |
AllowExternalCallThatCantCauseGC scope(masm()); |
__ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6); |
} |
- // Preserve "deoptimizer" object in register r0 and get the input |
- // frame descriptor pointer to r1 (deoptimizer->input_); |
- __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); |
+ // Preserve "deoptimizer" object in register r3 and get the input |
+ // frame descriptor pointer to r4 (deoptimizer->input_); |
+ __ LoadP(r4, MemOperand(r3, Deoptimizer::input_offset())); |
// Copy core registers into FrameDescription::registers_[kNumRegisters]. |
DCHECK(Register::kNumRegisters == kNumberOfRegisters); |
for (int i = 0; i < kNumberOfRegisters; i++) { |
int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
- __ ldr(r2, MemOperand(sp, i * kPointerSize)); |
- __ str(r2, MemOperand(r1, offset)); |
+ __ LoadP(r5, MemOperand(sp, i * kPointerSize)); |
+ __ StoreP(r5, MemOperand(r4, offset)); |
} |
- // Copy VFP registers to |
- // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] |
int double_regs_offset = FrameDescription::double_registers_offset(); |
- for (int i = 0; i < DwVfpRegister::kMaxNumAllocatableRegisters; ++i) { |
+ // Copy VFP registers to |
+ // double_registers_[DoubleRegister::kNumAllocatableRegisters] |
+ for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { |
int dst_offset = i * kDoubleSize + double_regs_offset; |
int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
- __ vldr(d0, sp, src_offset); |
- __ vstr(d0, r1, dst_offset); |
+ __ lfd(d0, MemOperand(sp, src_offset)); |
+ __ stfd(d0, MemOperand(r4, dst_offset)); |
} |
// Remove the bailout id and the saved registers from the stack. |
- __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
+ __ addi(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
- // Compute a pointer to the unwinding limit in register r2; that is |
+ // Compute a pointer to the unwinding limit in register r5; that is |
// the first stack slot not part of the input frame. |
- __ ldr(r2, MemOperand(r1, FrameDescription::frame_size_offset())); |
- __ add(r2, r2, sp); |
+ __ LoadP(r5, MemOperand(r4, FrameDescription::frame_size_offset())); |
+ __ add(r5, r5, sp); |
// Unwind the stack down to - but not including - the unwinding |
// limit and copy the contents of the activation frame to the input |
// frame description. |
- __ add(r3, r1, Operand(FrameDescription::frame_content_offset())); |
+ __ addi(r6, r4, Operand(FrameDescription::frame_content_offset())); |
Label pop_loop; |
Label pop_loop_header; |
__ b(&pop_loop_header); |
__ bind(&pop_loop); |
- __ pop(r4); |
- __ str(r4, MemOperand(r3, 0)); |
- __ add(r3, r3, Operand(sizeof(uint32_t))); |
+ __ pop(r7); |
+ __ StoreP(r7, MemOperand(r6, 0)); |
+ __ addi(r6, r6, Operand(kPointerSize)); |
__ bind(&pop_loop_header); |
- __ cmp(r2, sp); |
- __ b(ne, &pop_loop); |
+ __ cmp(r5, sp); |
+ __ bne(&pop_loop); |
// Compute the output frame in the deoptimizer. |
- __ push(r0); // Preserve deoptimizer object across call. |
- // r0: deoptimizer object; r1: scratch. |
- __ PrepareCallCFunction(1, r1); |
+ __ push(r3); // Preserve deoptimizer object across call. |
+ // r3: deoptimizer object; r4: scratch. |
+ __ PrepareCallCFunction(1, r4); |
// Call Deoptimizer::ComputeOutputFrames(). |
{ |
AllowExternalCallThatCantCauseGC scope(masm()); |
__ CallCFunction( |
ExternalReference::compute_output_frames_function(isolate()), 1); |
} |
- __ pop(r0); // Restore deoptimizer object (class Deoptimizer). |
+ __ pop(r3); // Restore deoptimizer object (class Deoptimizer). |
// Replace the current (input) frame with the output frames. |
- Label outer_push_loop, inner_push_loop, |
- outer_loop_header, inner_loop_header; |
- // Outer loop state: r4 = current "FrameDescription** output_", |
- // r1 = one past the last FrameDescription**. |
- __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); |
- __ ldr(r4, MemOperand(r0, Deoptimizer::output_offset())); // r4 is output_. |
- __ add(r1, r4, Operand(r1, LSL, 2)); |
- __ jmp(&outer_loop_header); |
+ Label outer_push_loop, inner_push_loop, outer_loop_header, inner_loop_header; |
+ // Outer loop state: r7 = current "FrameDescription** output_", |
+ // r4 = one past the last FrameDescription**. |
+ __ lwz(r4, MemOperand(r3, Deoptimizer::output_count_offset())); |
+ __ LoadP(r7, MemOperand(r3, Deoptimizer::output_offset())); // r7 is output_. |
+ __ ShiftLeftImm(r4, r4, Operand(kPointerSizeLog2)); |
+ __ add(r4, r7, r4); |
+ __ b(&outer_loop_header); |
+ |
__ bind(&outer_push_loop); |
- // Inner loop state: r2 = current FrameDescription*, r3 = loop index. |
- __ ldr(r2, MemOperand(r4, 0)); // output_[ix] |
- __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); |
- __ jmp(&inner_loop_header); |
- __ bind(&inner_push_loop); |
- __ sub(r3, r3, Operand(sizeof(uint32_t))); |
- __ add(r6, r2, Operand(r3)); |
- __ ldr(r6, MemOperand(r6, FrameDescription::frame_content_offset())); |
- __ push(r6); |
- __ bind(&inner_loop_header); |
- __ cmp(r3, Operand::Zero()); |
- __ b(ne, &inner_push_loop); // test for gt? |
- __ add(r4, r4, Operand(kPointerSize)); |
- __ bind(&outer_loop_header); |
- __ cmp(r4, r1); |
- __ b(lt, &outer_push_loop); |
+ // Inner loop state: r5 = current FrameDescription*, r6 = loop index. |
+ __ LoadP(r5, MemOperand(r7, 0)); // output_[ix] |
+ __ LoadP(r6, MemOperand(r5, FrameDescription::frame_size_offset())); |
+ __ b(&inner_loop_header); |
- // Check CPU flags for number of registers, setting the Z condition flag. |
- __ CheckFor32DRegs(ip); |
+ __ bind(&inner_push_loop); |
+ __ addi(r6, r6, Operand(-sizeof(intptr_t))); |
+ __ add(r9, r5, r6); |
+ __ LoadP(r9, MemOperand(r9, FrameDescription::frame_content_offset())); |
+ __ push(r9); |
- __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); |
- int src_offset = FrameDescription::double_registers_offset(); |
- for (int i = 0; i < DwVfpRegister::kMaxNumRegisters; ++i) { |
- if (i == kDoubleRegZero.code()) continue; |
- if (i == kScratchDoubleReg.code()) continue; |
+ __ bind(&inner_loop_header); |
+ __ cmpi(r6, Operand::Zero()); |
+ __ bne(&inner_push_loop); // test for gt? |
- const DwVfpRegister reg = DwVfpRegister::from_code(i); |
- __ vldr(reg, r1, src_offset, i < 16 ? al : ne); |
- src_offset += kDoubleSize; |
+ __ addi(r7, r7, Operand(kPointerSize)); |
+ __ bind(&outer_loop_header); |
+ __ cmp(r7, r4); |
+ __ blt(&outer_push_loop); |
+ |
+ __ LoadP(r4, MemOperand(r3, Deoptimizer::input_offset())); |
+ for (int i = 0; i < DoubleRegister::kMaxNumAllocatableRegisters; ++i) { |
+ const DoubleRegister dreg = DoubleRegister::FromAllocationIndex(i); |
+ int src_offset = i * kDoubleSize + double_regs_offset; |
+ __ lfd(dreg, MemOperand(r4, src_offset)); |
} |
// Push state, pc, and continuation from the last output frame. |
- __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); |
- __ push(r6); |
- __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); |
- __ push(r6); |
- __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); |
- __ push(r6); |
- |
- // Push the registers from the last output frame. |
+ __ LoadP(r9, MemOperand(r5, FrameDescription::state_offset())); |
+ __ push(r9); |
+ __ LoadP(r9, MemOperand(r5, FrameDescription::pc_offset())); |
+ __ push(r9); |
+ __ LoadP(r9, MemOperand(r5, FrameDescription::continuation_offset())); |
+ __ push(r9); |
+ |
+ // Restore the registers from the last output frame. |
+ DCHECK(!(ip.bit() & restored_regs)); |
+ __ mr(ip, r5); |
for (int i = kNumberOfRegisters - 1; i >= 0; i--) { |
int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
- __ ldr(r6, MemOperand(r2, offset)); |
- __ push(r6); |
+ if ((restored_regs & (1 << i)) != 0) { |
+ __ LoadP(ToRegister(i), MemOperand(ip, offset)); |
+ } |
} |
- // Restore the registers from the stack. |
- __ ldm(ia_w, sp, restored_regs); // all but pc registers. |
- __ pop(ip); // remove sp |
- __ pop(ip); // remove lr |
- |
__ InitializeRootRegister(); |
- __ pop(ip); // remove pc |
__ pop(ip); // get continuation, leave pc on stack |
- __ pop(lr); |
+ __ pop(r0); |
+ __ mtlr(r0); |
__ Jump(ip); |
__ stop("Unreachable."); |
} |
void Deoptimizer::TableEntryGenerator::GeneratePrologue() { |
+ Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm()); |
+ |
// Create a sequence of deoptimization entries. |
// Note that registers are still live when jumping to an entry. |
Label done; |
for (int i = 0; i < count(); i++) { |
int start = masm()->pc_offset(); |
USE(start); |
- __ mov(ip, Operand(i)); |
+ __ li(ip, Operand(i)); |
__ b(&done); |
DCHECK(masm()->pc_offset() - start == table_entry_size_); |
} |
@@ -344,11 +344,16 @@ void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { |
void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { |
+#if V8_OOL_CONSTANT_POOL |
DCHECK(FLAG_enable_ool_constant_pool); |
SetFrameSlot(offset, value); |
+#else |
+ // No out-of-line constant pool support. |
+ UNREACHABLE(); |
+#endif |
} |
#undef __ |
- |
-} } // namespace v8::internal |
+} |
+} // namespace v8::internal |