OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 output_frame->SetPc(reinterpret_cast<intptr_t>( | 528 output_frame->SetPc(reinterpret_cast<intptr_t>( |
529 trampoline->instruction_start())); | 529 trampoline->instruction_start())); |
530 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); | 530 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); |
531 Code* notify_failure = | 531 Code* notify_failure = |
532 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); | 532 isolate_->builtins()->builtin(Builtins::kNotifyStubFailure); |
533 output_frame->SetContinuation( | 533 output_frame->SetContinuation( |
534 reinterpret_cast<intptr_t>(notify_failure->entry())); | 534 reinterpret_cast<intptr_t>(notify_failure->entry())); |
535 } | 535 } |
536 | 536 |
537 | 537 |
538 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | |
539 int frame_index) { | |
540 Builtins* builtins = isolate_->builtins(); | |
541 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | |
542 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | |
543 unsigned height = iterator->Next(); | |
544 unsigned height_in_bytes = height * kPointerSize; | |
545 if (trace_) { | |
546 PrintF(" translating construct stub => height=%d\n", height_in_bytes); | |
547 } | |
548 | |
549 unsigned fixed_frame_size = 7 * kPointerSize; | |
550 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | |
551 | |
552 // Allocate and store the output frame description. | |
553 FrameDescription* output_frame = | |
554 new(output_frame_size) FrameDescription(output_frame_size, function); | |
555 output_frame->SetFrameType(StackFrame::CONSTRUCT); | |
556 | |
557 // Construct stub can not be topmost or bottommost. | |
558 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | |
559 ASSERT(output_[frame_index] == NULL); | |
560 output_[frame_index] = output_frame; | |
561 | |
562 // The top address of the frame is computed from the previous | |
563 // frame's top and this frame's size. | |
564 intptr_t top_address; | |
565 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | |
566 output_frame->SetTop(top_address); | |
567 | |
568 // Compute the incoming parameter translation. | |
569 int parameter_count = height; | |
570 unsigned output_offset = output_frame_size; | |
571 for (int i = 0; i < parameter_count; ++i) { | |
572 output_offset -= kPointerSize; | |
573 DoTranslateCommand(iterator, frame_index, output_offset); | |
574 } | |
575 | |
576 // Read caller's PC from the previous frame. | |
577 output_offset -= kPointerSize; | |
578 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); | |
579 output_frame->SetFrameSlot(output_offset, callers_pc); | |
580 if (trace_) { | |
581 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | |
582 V8PRIxPTR " ; caller's pc\n", | |
583 top_address + output_offset, output_offset, callers_pc); | |
584 } | |
585 | |
586 // Read caller's FP from the previous frame, and set this frame's FP. | |
587 output_offset -= kPointerSize; | |
588 intptr_t value = output_[frame_index - 1]->GetFp(); | |
589 output_frame->SetFrameSlot(output_offset, value); | |
590 intptr_t fp_value = top_address + output_offset; | |
591 output_frame->SetFp(fp_value); | |
592 if (trace_) { | |
593 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | |
594 V8PRIxPTR " ; caller's fp\n", | |
595 fp_value, output_offset, value); | |
596 } | |
597 | |
598 // The context can be gotten from the previous frame. | |
599 output_offset -= kPointerSize; | |
600 value = output_[frame_index - 1]->GetContext(); | |
601 output_frame->SetFrameSlot(output_offset, value); | |
602 if (trace_) { | |
603 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | |
604 V8PRIxPTR " ; context\n", | |
605 top_address + output_offset, output_offset, value); | |
606 } | |
607 | |
608 // A marker value is used in place of the function. | |
609 output_offset -= kPointerSize; | |
610 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::CONSTRUCT)); | |
611 output_frame->SetFrameSlot(output_offset, value); | |
612 if (trace_) { | |
613 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | |
614 V8PRIxPTR " ; function (construct sentinel)\n", | |
615 top_address + output_offset, output_offset, value); | |
616 } | |
617 | |
618 // The output frame reflects a JSConstructStubGeneric frame. | |
619 output_offset -= kPointerSize; | |
620 value = reinterpret_cast<intptr_t>(construct_stub); | |
621 output_frame->SetFrameSlot(output_offset, value); | |
622 if (trace_) { | |
623 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | |
624 V8PRIxPTR " ; code object\n", | |
625 top_address + output_offset, output_offset, value); | |
626 } | |
627 | |
628 // Number of incoming arguments. | |
629 output_offset -= kPointerSize; | |
630 value = reinterpret_cast<intptr_t>(Smi::FromInt(height - 1)); | |
631 output_frame->SetFrameSlot(output_offset, value); | |
632 if (trace_) { | |
633 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | |
634 V8PRIxPTR " ; argc (%d)\n", | |
635 top_address + output_offset, output_offset, value, height - 1); | |
636 } | |
637 | |
638 // The newly allocated object was passed as receiver in the artificial | |
639 // constructor stub environment created by HEnvironment::CopyForInlining(). | |
640 output_offset -= kPointerSize; | |
641 value = output_frame->GetFrameSlot(output_frame_size - kPointerSize); | |
642 output_frame->SetFrameSlot(output_offset, value); | |
643 if (trace_) { | |
644 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | |
645 V8PRIxPTR " ; allocated receiver\n", | |
646 top_address + output_offset, output_offset, value); | |
647 } | |
648 | |
649 ASSERT(0 == output_offset); | |
650 | |
651 intptr_t pc = reinterpret_cast<intptr_t>( | |
652 construct_stub->instruction_start() + | |
653 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); | |
654 output_frame->SetPc(pc); | |
655 } | |
656 | |
657 | |
658 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 538 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
659 int frame_index) { | 539 int frame_index) { |
660 BailoutId node_id = BailoutId(iterator->Next()); | 540 BailoutId node_id = BailoutId(iterator->Next()); |
661 JSFunction* function; | 541 JSFunction* function; |
662 if (frame_index != 0) { | 542 if (frame_index != 0) { |
663 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 543 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
664 } else { | 544 } else { |
665 int closure_id = iterator->Next(); | 545 int closure_id = iterator->Next(); |
666 USE(closure_id); | 546 USE(closure_id); |
667 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 547 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 } | 947 } |
1068 __ bind(&done); | 948 __ bind(&done); |
1069 } | 949 } |
1070 | 950 |
1071 #undef __ | 951 #undef __ |
1072 | 952 |
1073 | 953 |
1074 } } // namespace v8::internal | 954 } } // namespace v8::internal |
1075 | 955 |
1076 #endif // V8_TARGET_ARCH_X64 | 956 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |