341
void Deoptimizer::DoComputeFrame(TranslationIterator* iterator,
343
// Read the ast node id, function, and frame height for this output frame.
344
Translation::Opcode opcode =
345
static_cast<Translation::Opcode>(iterator->Next());
347
ASSERT(Translation::FRAME == opcode);
340
void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator,
342
JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
343
unsigned height = iterator->Next();
344
unsigned height_in_bytes = height * kPointerSize;
345
if (FLAG_trace_deopt) {
346
PrintF(" translating arguments adaptor => height=%d\n", height_in_bytes);
349
unsigned fixed_frame_size = ArgumentsAdaptorFrameConstants::kFrameSize;
350
unsigned input_frame_size = input_->GetFrameSize();
351
unsigned output_frame_size = height_in_bytes + fixed_frame_size;
353
// Allocate and store the output frame description.
354
FrameDescription* output_frame =
355
new(output_frame_size) FrameDescription(output_frame_size, function);
356
output_frame->SetFrameType(StackFrame::ARGUMENTS_ADAPTOR);
358
// Arguments adaptor can not be topmost or bottommost.
359
ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
360
ASSERT(output_[frame_index] == NULL);
361
output_[frame_index] = output_frame;
363
// The top address of the frame is computed from the previous
364
// frame's top and this frame's size.
365
intptr_t top_address;
366
top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
367
output_frame->SetTop(top_address);
369
// Compute the incoming parameter translation.
370
int parameter_count = height;
371
unsigned output_offset = output_frame_size;
372
unsigned input_offset = input_frame_size;
373
for (int i = 0; i < parameter_count; ++i) {
374
output_offset -= kPointerSize;
375
DoTranslateCommand(iterator, frame_index, output_offset);
377
input_offset -= (parameter_count * kPointerSize);
379
// Read caller's PC from the previous frame.
380
output_offset -= kPointerSize;
381
input_offset -= kPointerSize;
382
intptr_t callers_pc = output_[frame_index - 1]->GetPc();
383
output_frame->SetFrameSlot(output_offset, callers_pc);
384
if (FLAG_trace_deopt) {
385
PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
386
V8PRIxPTR " ; caller's pc\n",
387
top_address + output_offset, output_offset, callers_pc);
390
// Read caller's FP from the previous frame, and set this frame's FP.
391
output_offset -= kPointerSize;
392
input_offset -= kPointerSize;
393
intptr_t value = output_[frame_index - 1]->GetFp();
394
output_frame->SetFrameSlot(output_offset, value);
395
intptr_t fp_value = top_address + output_offset;
396
output_frame->SetFp(fp_value);
397
if (FLAG_trace_deopt) {
398
PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
399
V8PRIxPTR " ; caller's fp\n",
400
fp_value, output_offset, value);
403
// A marker value is used in place of the context.
404
output_offset -= kPointerSize;
405
input_offset -= kPointerSize;
406
intptr_t context = reinterpret_cast<intptr_t>(
407
Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
408
output_frame->SetFrameSlot(output_offset, context);
409
if (FLAG_trace_deopt) {
410
PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
411
V8PRIxPTR " ; context (adaptor sentinel)\n",
412
top_address + output_offset, output_offset, context);
415
// The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME.
416
output_offset -= kPointerSize;
417
input_offset -= kPointerSize;
418
value = reinterpret_cast<intptr_t>(function);
419
output_frame->SetFrameSlot(output_offset, value);
420
if (FLAG_trace_deopt) {
421
PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
422
V8PRIxPTR " ; function\n",
423
top_address + output_offset, output_offset, value);
426
// Number of incoming arguments.
427
output_offset -= kPointerSize;
428
input_offset -= kPointerSize;
429
value = reinterpret_cast<intptr_t>(Smi::FromInt(height - 1));
430
output_frame->SetFrameSlot(output_offset, value);
431
if (FLAG_trace_deopt) {
432
PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
433
V8PRIxPTR " ; argc (%d)\n",
434
top_address + output_offset, output_offset, value, height - 1);
437
ASSERT(0 == output_offset);
439
Builtins* builtins = isolate_->builtins();
440
Code* adaptor_trampoline =
441
builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
442
intptr_t pc_value = reinterpret_cast<intptr_t>(
443
adaptor_trampoline->instruction_start() +
444
isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
445
output_frame->SetPc(pc_value);
449
void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
348
451
int node_id = iterator->Next();
349
452
JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
350
453
unsigned height = iterator->Next();