| Index: src/x64/deoptimizer-x64.cc
|
| diff --git a/src/x64/deoptimizer-x64.cc b/src/x64/deoptimizer-x64.cc
|
| index a5a171a2a8833feb83a36dbb4aeb4d8d13119f0b..b6ccdca64ca4a112e4bcba0183c2ca7141eed956 100644
|
| --- a/src/x64/deoptimizer-x64.cc
|
| +++ b/src/x64/deoptimizer-x64.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2011 the V8 project authors. All rights reserved.
|
| +// Copyright 2012 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -206,12 +206,13 @@ void Deoptimizer::DoComputeOsrOutputFrame() {
|
| ASSERT(Translation::BEGIN == opcode);
|
| USE(opcode);
|
| int count = iterator.Next();
|
| + iterator.Skip(1); // Drop JS frame count.
|
| ASSERT(count == 1);
|
| USE(count);
|
|
|
| opcode = static_cast<Translation::Opcode>(iterator.Next());
|
| USE(opcode);
|
| - ASSERT(Translation::FRAME == opcode);
|
| + ASSERT(Translation::JS_FRAME == opcode);
|
| unsigned node_id = iterator.Next();
|
| USE(node_id);
|
| ASSERT(node_id == ast_id);
|
| @@ -250,6 +251,7 @@ void Deoptimizer::DoComputeOsrOutputFrame() {
|
| #ifdef DEBUG
|
| output_[0]->SetKind(Code::OPTIMIZED_FUNCTION);
|
| #endif
|
| + output_[0]->SetType(StackFrame::JAVA_SCRIPT);
|
|
|
| // Clear the incoming parameters in the optimized frame to avoid
|
| // confusing the garbage collector.
|
| @@ -338,13 +340,124 @@ void Deoptimizer::DoComputeOsrOutputFrame() {
|
| }
|
|
|
|
|
| -void Deoptimizer::DoComputeFrame(TranslationIterator* iterator,
|
| - int frame_index) {
|
| - // Read the ast node id, function, and frame height for this output frame.
|
| - Translation::Opcode opcode =
|
| - static_cast<Translation::Opcode>(iterator->Next());
|
| - USE(opcode);
|
| - ASSERT(Translation::FRAME == opcode);
|
| +void Deoptimizer::DoComputeArgumentsAdaptorFrame(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 arguments adaptor => height=%d\n", height_in_bytes);
|
| + }
|
| +
|
| + unsigned fixed_frame_size = 5 * kPointerSize;
|
| + unsigned input_frame_size = input_->GetFrameSize();
|
| + 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);
|
| +#ifdef DEBUG
|
| + output_frame->SetKind(Code::BUILTIN);
|
| +#endif
|
| + output_frame->SetType(StackFrame::ARGUMENTS_ADAPTOR);
|
| +
|
| + // Arguments adaptor can not be topmost or bottommost.
|
| + ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
|
| + ASSERT(output_[frame_index] == NULL);
|
| + output_[frame_index] = output_frame;
|
| +
|
| + // The top address for the bottommost output frame can be computed from
|
| + // the input frame pointer and the output frame's height. For all
|
| + // subsequent output frames, it can be computed from the previous one's
|
| + // top address and the current frame's size.
|
| + intptr_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;
|
| + 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);
|
| +
|
| + // Compute caller's PC
|
| + 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) {
|
| + PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
|
| + V8PRIxPTR " ; caller's pc\n",
|
| + top_address + output_offset, output_offset, callers_pc);
|
| + }
|
| +
|
| + // Compute caller'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;
|
| + output_frame->SetFp(fp_value);
|
| + if (FLAG_trace_deopt) {
|
| + PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
|
| + V8PRIxPTR " ; caller's fp\n",
|
| + fp_value, output_offset, value);
|
| + }
|
| +
|
| + // For the bottommost output frame the context can be gotten from the input
|
| + // frame. For all subsequent output frames it can be gotten from the function
|
| + // so long as we don't inline functions that need local contexts.
|
| + output_offset -= kPointerSize;
|
| + input_offset -= kPointerSize;
|
| + intptr_t context = reinterpret_cast<intptr_t>(
|
| + Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
|
| + output_frame->SetFrameSlot(output_offset, context);
|
| + if (FLAG_trace_deopt) {
|
| + PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
|
| + V8PRIxPTR " ; context (adaptor sentinel)\n",
|
| + top_address + output_offset, output_offset, context);
|
| + }
|
| +
|
| + // 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) {
|
| + PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
|
| + V8PRIxPTR " ; function\n",
|
| + top_address + output_offset, output_offset, value);
|
| + }
|
| +
|
| + // Number of incomming arguments.
|
| + output_offset -= kPointerSize;
|
| + input_offset -= kPointerSize;
|
| + value = reinterpret_cast<intptr_t>(Smi::FromInt(height - 1));
|
| + output_frame->SetFrameSlot(output_offset, value);
|
| + if (FLAG_trace_deopt) {
|
| + PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
|
| + V8PRIxPTR " ; argc (%d)\n",
|
| + top_address + output_offset, output_offset, value, height - 1);
|
| + }
|
| +
|
| + ASSERT(0 == output_offset);
|
| +
|
| + Builtins* builtins = isolate_->builtins();
|
| + Code* adaptor_trampoline =
|
| + builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
|
| + intptr_t pc_value = reinterpret_cast<intptr_t>(
|
| + adaptor_trampoline->instruction_start() +
|
| + isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
|
| + output_frame->SetPc(pc_value);
|
| +}
|
| +
|
| +
|
| +void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
|
| + int frame_index) {
|
| int node_id = iterator->Next();
|
| JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
|
| unsigned height = iterator->Next();
|
| @@ -367,6 +480,7 @@ void Deoptimizer::DoComputeFrame(TranslationIterator* iterator,
|
| #ifdef DEBUG
|
| output_frame->SetKind(Code::FUNCTION);
|
| #endif
|
| + output_frame->SetType(StackFrame::JAVA_SCRIPT);
|
|
|
| bool is_bottommost = (0 == frame_index);
|
| bool is_topmost = (output_count_ - 1 == frame_index);
|
|
|