Chromium Code Reviews| Index: src/ia32/deoptimizer-ia32.cc | 
| diff --git a/src/ia32/deoptimizer-ia32.cc b/src/ia32/deoptimizer-ia32.cc | 
| index 14f26757e9232fc066d279af189e76d2394739af..ace672be5867d103f543145a7c2802798bbb18cf 100644 | 
| --- a/src/ia32/deoptimizer-ia32.cc | 
| +++ b/src/ia32/deoptimizer-ia32.cc | 
| @@ -446,7 +446,6 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 
| } | 
| unsigned fixed_frame_size = ArgumentsAdaptorFrameConstants::kFrameSize; | 
| - unsigned input_frame_size = input_->GetFrameSize(); | 
| unsigned output_frame_size = height_in_bytes + fixed_frame_size; | 
| // Allocate and store the output frame description. | 
| @@ -468,16 +467,13 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 
| // Compute the incoming parameter translation. | 
| int parameter_count = height; | 
| unsigned output_offset = output_frame_size; | 
| - unsigned input_offset = input_frame_size; | 
| for (int i = 0; i < parameter_count; ++i) { | 
| output_offset -= kPointerSize; | 
| DoTranslateCommand(iterator, frame_index, output_offset); | 
| } | 
| - input_offset -= (parameter_count * kPointerSize); | 
| // Read caller's PC from the previous frame. | 
| output_offset -= kPointerSize; | 
| - input_offset -= kPointerSize; | 
| intptr_t callers_pc = output_[frame_index - 1]->GetPc(); | 
| output_frame->SetFrameSlot(output_offset, callers_pc); | 
| if (FLAG_trace_deopt) { | 
| @@ -487,7 +483,6 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 
| // Read caller's FP from the previous frame, and set this frame's FP. | 
| output_offset -= kPointerSize; | 
| - input_offset -= kPointerSize; | 
| intptr_t value = output_[frame_index - 1]->GetFp(); | 
| output_frame->SetFrameSlot(output_offset, value); | 
| intptr_t fp_value = top_address + output_offset; | 
| @@ -499,7 +494,6 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 
| // A marker value is used in place of the context. | 
| output_offset -= kPointerSize; | 
| - input_offset -= kPointerSize; | 
| intptr_t context = reinterpret_cast<intptr_t>( | 
| Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 
| output_frame->SetFrameSlot(output_offset, context); | 
| @@ -510,7 +504,6 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 
| // The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME. | 
| output_offset -= kPointerSize; | 
| - input_offset -= kPointerSize; | 
| value = reinterpret_cast<intptr_t>(function); | 
| output_frame->SetFrameSlot(output_offset, value); | 
| if (FLAG_trace_deopt) { | 
| @@ -520,7 +513,6 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 
| // Number of incoming arguments. | 
| output_offset -= kPointerSize; | 
| - input_offset -= kPointerSize; | 
| value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1)); | 
| output_frame->SetFrameSlot(output_offset, value); | 
| if (FLAG_trace_deopt) { | 
| @@ -540,6 +532,110 @@ void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 
| } | 
| +void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | 
| + int frame_index) { | 
| + JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 
| + unsigned height = iterator->Next(); | 
| + unsigned height_in_bytes = height * kPointerSize; | 
| + if (FLAG_trace_deopt) { | 
| + PrintF(" translating construct stub => height=%d\n", height_in_bytes); | 
| + } | 
| + | 
| + unsigned fixed_frame_size = 6 * kPointerSize; | 
| + unsigned output_frame_size = height_in_bytes + fixed_frame_size; | 
| + | 
| + // Allocate and store the output frame description. | 
| + FrameDescription* output_frame = | 
| + new(output_frame_size) FrameDescription(output_frame_size, function); | 
| + output_frame->SetFrameType(StackFrame::CONSTRUCT); | 
| + | 
| + // Arguments adaptor can not be topmost or bottommost. | 
| 
 
Vyacheslav Egorov (Chromium)
2012/02/13 15:01:39
Comment mentions arguments adaptor.
I wonder if s
 
Michael Starzinger
2012/02/27 14:16:32
Done.
 
 | 
| + ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | 
| + ASSERT(output_[frame_index] == NULL); | 
| + output_[frame_index] = output_frame; | 
| + | 
| + // The top address of the frame is computed from the previous | 
| + // frame's top and this frame's size. | 
| + uint32_t top_address; | 
| + top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | 
| + output_frame->SetTop(top_address); | 
| + | 
| + // Compute the incoming parameter translation. | 
| + int parameter_count = height; | 
| + unsigned output_offset = output_frame_size; | 
| + for (int i = 0; i < parameter_count; ++i) { | 
| + output_offset -= kPointerSize; | 
| + DoTranslateCommand(iterator, frame_index, output_offset); | 
| + } | 
| + | 
| + // Read caller's PC from the previous frame. | 
| + output_offset -= kPointerSize; | 
| + intptr_t callers_pc = output_[frame_index - 1]->GetPc(); | 
| + output_frame->SetFrameSlot(output_offset, callers_pc); | 
| + if (FLAG_trace_deopt) { | 
| + PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n", | 
| + top_address + output_offset, output_offset, callers_pc); | 
| + } | 
| + | 
| + // Read caller's FP from the previous frame, and set this frame's FP. | 
| + output_offset -= kPointerSize; | 
| + intptr_t value = output_[frame_index - 1]->GetFp(); | 
| + output_frame->SetFrameSlot(output_offset, value); | 
| + intptr_t fp_value = top_address + output_offset; | 
| + output_frame->SetFp(fp_value); | 
| + if (FLAG_trace_deopt) { | 
| + PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", | 
| + fp_value, output_offset, value); | 
| + } | 
| + | 
| + // The context can be gotten from the previous frame. | 
| + output_offset -= kPointerSize; | 
| + value = output_[frame_index - 1]->GetContext(); | 
| + output_frame->SetFrameSlot(output_offset, value); | 
| + if (FLAG_trace_deopt) { | 
| + PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n", | 
| + top_address + output_offset, output_offset, value); | 
| + } | 
| + | 
| + // A marker value is used in place of the function. | 
| + output_offset -= kPointerSize; | 
| + value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::CONSTRUCT)); | 
| + output_frame->SetFrameSlot(output_offset, value); | 
| + if (FLAG_trace_deopt) { | 
| + PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function (construct sentinel)\n", | 
| + top_address + output_offset, output_offset, value); | 
| + } | 
| + | 
| + // Number of incoming arguments. | 
| + output_offset -= kPointerSize; | 
| + value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1)); | 
| + output_frame->SetFrameSlot(output_offset, value); | 
| + if (FLAG_trace_deopt) { | 
| + PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n", | 
| + top_address + output_offset, output_offset, value, height - 1); | 
| + } | 
| + | 
| + // The newly allocated object was passed as receiver in the artificial | 
| + // constructor stub environment created by HEnvironment::CopyForInlining(). | 
| + output_offset -= kPointerSize; | 
| + value = output_frame->GetFrameSlot(output_frame_size - kPointerSize); | 
| + output_frame->SetFrameSlot(output_offset, value); | 
| + if (FLAG_trace_deopt) { | 
| + PrintF(" 0x%08x: [top + %d] <- 0x%08x ; allocated receiver\n", | 
| + top_address + output_offset, output_offset, value); | 
| + } | 
| + | 
| + ASSERT(0 == output_offset); | 
| + | 
| + Builtins* builtins = isolate_->builtins(); | 
| + Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | 
| + uint32_t pc = reinterpret_cast<uint32_t>( | 
| + construct_stub->instruction_start() + | 
| + isolate_->heap()->construct_stub_deopt_pc_offset()->value()); | 
| + output_frame->SetPc(pc); | 
| +} | 
| + | 
| + | 
| void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 
| int frame_index) { | 
| int node_id = iterator->Next(); | 
| @@ -651,6 +747,7 @@ void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 
| value = reinterpret_cast<uint32_t>(function->context()); | 
| } | 
| output_frame->SetFrameSlot(output_offset, value); | 
| + output_frame->SetContext(value); | 
| if (is_topmost) output_frame->SetRegister(esi.code(), value); | 
| if (FLAG_trace_deopt) { | 
| PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context\n", |