Index: src/mips/deoptimizer-mips.cc |
diff --git a/src/mips/deoptimizer-mips.cc b/src/mips/deoptimizer-mips.cc |
index 9a8cfd0cfdb9acd1106babb2d83cc91507ce223e..cead13f7e3869a98537246260a6cfe5bdd60f332 100644 |
--- a/src/mips/deoptimizer-mips.cc |
+++ b/src/mips/deoptimizer-mips.cc |
@@ -459,13 +459,19 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, |
// v +-------------------------+ +-------------------------| |
// | COMPILED_STUB marker | | STUB_FAILURE marker | |
// +-------------------------+ +-------------------------+ |
- // | | | stub parameter 1 | |
+ // | | | caller args.length_ | |
// | ... | +-------------------------+ |
- // | | | ... | |
+ // | | | caller args.arguments_ | |
// |-------------------------|<-sp +-------------------------+ |
- // | stub parameter n | |
- // parameters in registers +-------------------------+<-sp |
- // and spilled to stack s0-s1 = number of parameters |
+ // | caller args pointer | |
+ // +-------------------------+ |
+ // | caller stack param 1 | |
+ // parameters in registers +-------------------------+ |
+ // and spilled to stack | .... | |
+ // +-------------------------+ |
+ // | caller stack param n | |
+ // +-------------------------+<-sp |
+ // s0-s1 = number of parameters |
// s2 = failure handler address |
// fp = saved frame |
// cp = JSFunction context |
@@ -476,9 +482,15 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, |
CodeStubInterfaceDescriptor* descriptor = |
isolate_->code_stub_interface_descriptor(major_key); |
+ // The output frame must have room for all pushed register parameters |
+ // and the standard stack frame slots. |
int output_frame_size = StandardFrameConstants::kFixedFrameSize + |
kPointerSize * descriptor->register_param_count_; |
+ // Include space for an argument object to the callee and optionally |
+ // the space to pass the argument object to the stub failure handler. |
+ output_frame_size += sizeof(Arguments) + kPointerSize; |
+ |
FrameDescription* output_frame = |
new(output_frame_size) FrameDescription(output_frame_size, 0); |
ASSERT(frame_index == 0); |
@@ -490,12 +502,15 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, |
reinterpret_cast<intptr_t>(notify_failure->entry())); |
Code* trampoline = NULL; |
- StubFailureTrampolineStub().FindCodeInCache(&trampoline, isolate_); |
+ int extra = descriptor->extra_expression_stack_count_; |
+ StubFailureTrampolineStub(extra).FindCodeInCache(&trampoline, isolate_); |
ASSERT(trampoline != NULL); |
output_frame->SetPc(reinterpret_cast<intptr_t>( |
trampoline->instruction_start())); |
unsigned input_frame_size = input_->GetFrameSize(); |
+ intptr_t frame_ptr = input_->GetRegister(fp.code()); |
+ |
// JSFunction continuation |
intptr_t input_frame_offset = input_frame_size - kPointerSize; |
intptr_t output_frame_offset = output_frame_size - kPointerSize; |
@@ -521,21 +536,50 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, |
Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); |
output_frame->SetFrameSlot(output_frame_offset, value); |
+ int caller_arg_count = 0; |
+ if (descriptor->stack_parameter_count_ != NULL) { |
+ caller_arg_count = |
+ input_->GetRegister(descriptor->stack_parameter_count_->code()); |
+ } |
+ |
+ // Build the Arguments object for the caller's parameters and a pointer to it. |
+ output_frame_offset -= kPointerSize; |
+ value = frame_ptr + StandardFrameConstants::kCallerSPOffset + |
+ (caller_arg_count - 1) * kPointerSize; |
+ output_frame->SetFrameSlot(output_frame_offset, value); |
+ |
+ output_frame->SetFrameSlot(output_frame_offset, value); |
+ output_frame_offset -= kPointerSize; |
+ output_frame->SetFrameSlot(output_frame_offset, caller_arg_count); |
+ |
+ value = frame_ptr - (output_frame_size - output_frame_offset) - |
+ StandardFrameConstants::kMarkerOffset; |
+ output_frame_offset -= kPointerSize; |
+ output_frame->SetFrameSlot(output_frame_offset, value); |
+ |
+ // Copy the register parameters to the failure frame. |
for (int i = 0; i < descriptor->register_param_count_; ++i) { |
output_frame_offset -= kPointerSize; |
DoTranslateCommand(iterator, 0, output_frame_offset); |
} |
- value = input_->GetRegister(fp.code()); |
- output_frame->SetRegister(fp.code(), value); |
- output_frame->SetFp(value); |
+ for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) { |
+ double double_value = input_->GetDoubleRegister(i); |
+ output_frame->SetDoubleRegister(i, double_value); |
+ } |
+ |
+ output_frame->SetRegister(fp.code(), frame_ptr); |
+ output_frame->SetFp(frame_ptr); |
ApiFunction function(descriptor->deoptimization_handler_); |
ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); |
intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); |
- output_frame->SetRegister(s0.code(), descriptor->register_param_count_); |
- output_frame->SetRegister(s1.code(), |
- (descriptor->register_param_count_ - 1) * kPointerSize); |
+ int params = descriptor->register_param_count_; |
+ if (descriptor->stack_parameter_count_ != NULL) { |
+ params++; |
+ } |
+ output_frame->SetRegister(s0.code(), params); |
+ output_frame->SetRegister(s1.code(), (params - 1) * kPointerSize); |
output_frame->SetRegister(s2.code(), handler); |
} |
@@ -593,7 +637,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
output_frame->SetFrameSlot(output_offset, value); |
intptr_t fp_value = top_address + output_offset; |
output_frame->SetFp(fp_value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", |
fp_value, output_offset, value); |
} |
@@ -602,7 +646,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = output_[frame_index - 1]->GetContext(); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -611,7 +655,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::CONSTRUCT)); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function (construct sentinel)\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -620,7 +664,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = reinterpret_cast<intptr_t>(construct_stub); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; code object\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -629,7 +673,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1)); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n", |
top_address + output_offset, output_offset, value, height - 1); |
} |
@@ -638,7 +682,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = reinterpret_cast<intptr_t>(function); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; constructor function\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -648,7 +692,7 @@ void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = output_frame->GetFrameSlot(output_frame_size - kPointerSize); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; allocated receiver\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -672,7 +716,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, |
unsigned height = 0; |
unsigned height_in_bytes = height * kPointerSize; |
const char* kind = is_setter_stub_frame ? "setter" : "getter"; |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" translating %s stub => height=%u\n", kind, height_in_bytes); |
} |
@@ -705,7 +749,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
intptr_t value = output_[frame_index - 1]->GetPc(); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
" ; caller's pc\n", |
top_address + output_offset, output_offset, value); |
@@ -717,7 +761,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, |
output_frame->SetFrameSlot(output_offset, value); |
intptr_t fp_value = top_address + output_offset; |
output_frame->SetFp(fp_value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
" ; caller's fp\n", |
fp_value, output_offset, value); |
@@ -727,7 +771,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = output_[frame_index - 1]->GetContext(); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
" ; context\n", |
top_address + output_offset, output_offset, value); |
@@ -737,7 +781,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, |
output_offset -= kPointerSize; |
value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL)); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
" ; function (%s sentinel)\n", |
top_address + output_offset, output_offset, value, kind); |
@@ -751,7 +795,7 @@ void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, |
Code* accessor_stub = isolate_->builtins()->builtin(name); |
value = reinterpret_cast<intptr_t>(accessor_stub); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
" ; code object\n", |
top_address + output_offset, output_offset, value); |
@@ -797,7 +841,7 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
} |
unsigned height = iterator->Next(); |
unsigned height_in_bytes = height * kPointerSize; |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" translating "); |
function->PrintName(); |
PrintF(" => node=%d, height=%d\n", node_id.ToInt(), height_in_bytes); |
@@ -861,7 +905,7 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
value = output_[frame_index - 1]->GetPc(); |
} |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -884,7 +928,7 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
if (is_topmost) { |
output_frame->SetRegister(fp.code(), fp_value); |
} |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", |
fp_value, output_offset, value); |
} |
@@ -902,7 +946,7 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
output_frame->SetFrameSlot(output_offset, value); |
output_frame->SetContext(value); |
if (is_topmost) output_frame->SetRegister(cp.code(), value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -915,7 +959,7 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
// input frame. |
ASSERT(!is_bottommost || input_->GetFrameSlot(input_offset) == value); |
output_frame->SetFrameSlot(output_offset, value); |
- if (FLAG_trace_deopt) { |
+ if (trace_) { |
PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function\n", |
top_address + output_offset, output_offset, value); |
} |
@@ -1076,11 +1120,11 @@ void Deoptimizer::EntryGenerator::Generate() { |
} |
} |
+ int double_regs_offset = FrameDescription::double_registers_offset(); |
if (CpuFeatures::IsSupported(FPU)) { |
CpuFeatures::Scope scope(FPU); |
// Copy FPU registers to |
// double_registers_[DoubleRegister::kNumAllocatableRegisters] |
- int double_regs_offset = FrameDescription::double_registers_offset(); |
for (int i = 0; i < FPURegister::NumAllocatableRegisters(); ++i) { |
int dst_offset = i * kDoubleSize + double_regs_offset; |
int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
@@ -1131,16 +1175,16 @@ void Deoptimizer::EntryGenerator::Generate() { |
// 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: a0 = current "FrameDescription** output_", |
+ // Outer loop state: t0 = current "FrameDescription** output_", |
// a1 = one past the last FrameDescription**. |
__ lw(a1, MemOperand(a0, Deoptimizer::output_count_offset())); |
- __ lw(a0, MemOperand(a0, Deoptimizer::output_offset())); // a0 is output_. |
+ __ lw(t0, MemOperand(a0, Deoptimizer::output_offset())); // t0 is output_. |
__ sll(a1, a1, kPointerSizeLog2); // Count to offset. |
- __ addu(a1, a0, a1); // a1 = one past the last FrameDescription**. |
+ __ addu(a1, t0, a1); // a1 = one past the last FrameDescription**. |
__ jmp(&outer_loop_header); |
__ bind(&outer_push_loop); |
// Inner loop state: a2 = current FrameDescription*, a3 = loop index. |
- __ lw(a2, MemOperand(a0, 0)); // output_[ix] |
+ __ lw(a2, MemOperand(t0, 0)); // output_[ix] |
__ lw(a3, MemOperand(a2, FrameDescription::frame_size_offset())); |
__ jmp(&inner_loop_header); |
__ bind(&inner_push_loop); |
@@ -1151,10 +1195,20 @@ void Deoptimizer::EntryGenerator::Generate() { |
__ bind(&inner_loop_header); |
__ Branch(&inner_push_loop, ne, a3, Operand(zero_reg)); |
- __ Addu(a0, a0, Operand(kPointerSize)); |
+ __ Addu(t0, t0, Operand(kPointerSize)); |
__ bind(&outer_loop_header); |
- __ Branch(&outer_push_loop, lt, a0, Operand(a1)); |
+ __ Branch(&outer_push_loop, lt, t0, Operand(a1)); |
+ |
+ if (CpuFeatures::IsSupported(FPU)) { |
+ CpuFeatures::Scope scope(FPU); |
+ __ lw(a1, MemOperand(a0, Deoptimizer::input_offset())); |
+ for (int i = 0; i < FPURegister::kMaxNumAllocatableRegisters; ++i) { |
+ const FPURegister fpu_reg = FPURegister::FromAllocationIndex(i); |
+ int src_offset = i * kDoubleSize + double_regs_offset; |
+ __ ldc1(fpu_reg, MemOperand(a1, src_offset)); |
+ } |
+ } |
// Push state, pc, and continuation from the last output frame. |
if (type() != OSR) { |