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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 687 |
688 ASSERT(0 == output_offset); | 688 ASSERT(0 == output_offset); |
689 | 689 |
690 uint32_t pc = reinterpret_cast<uint32_t>( | 690 uint32_t pc = reinterpret_cast<uint32_t>( |
691 construct_stub->instruction_start() + | 691 construct_stub->instruction_start() + |
692 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); | 692 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); |
693 output_frame->SetPc(pc); | 693 output_frame->SetPc(pc); |
694 } | 694 } |
695 | 695 |
696 | 696 |
| 697 void Deoptimizer::DoComputeSetterStubFrame(TranslationIterator* iterator, |
| 698 int frame_index) { |
| 699 JSFunction* setter = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 700 // The receiver and the implicit return value are expected in registers by the |
| 701 // StoreIC, so they don't belong to the output stack frame. This means that we |
| 702 // have to use a height of 0. |
| 703 unsigned height = 0; |
| 704 unsigned height_in_bytes = height * kPointerSize; |
| 705 if (FLAG_trace_deopt) { |
| 706 PrintF(" translating setter stub => height=%u\n", height_in_bytes); |
| 707 } |
| 708 |
| 709 // We need 1 stack entry for the return address + 4 stack entries from |
| 710 // StackFrame::INTERNAL (FP, context, frame type, code object, see |
| 711 // MacroAssembler::EnterFrame) + 1 stack entry from setter stub (implicit |
| 712 // return value, see StoreStubCompiler::CompileStoreViaSetter). |
| 713 unsigned fixed_frame_size = (1 + 4 + 1) * kPointerSize; |
| 714 unsigned output_frame_size = height_in_bytes + fixed_frame_size; |
| 715 |
| 716 // Allocate and store the output frame description. |
| 717 FrameDescription* output_frame = |
| 718 new(output_frame_size) FrameDescription(output_frame_size, setter); |
| 719 output_frame->SetFrameType(StackFrame::INTERNAL); |
| 720 |
| 721 // A frame for a setter stub can not be the topmost or bottommost one. |
| 722 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); |
| 723 ASSERT(output_[frame_index] == NULL); |
| 724 output_[frame_index] = output_frame; |
| 725 |
| 726 // The top address of the frame is computed from the previous frame's top and |
| 727 // this frame's size. |
| 728 intptr_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; |
| 729 output_frame->SetTop(top_address); |
| 730 |
| 731 unsigned output_offset = output_frame_size; |
| 732 |
| 733 // Read caller's PC from the previous frame. |
| 734 output_offset -= kPointerSize; |
| 735 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); |
| 736 output_frame->SetFrameSlot(output_offset, callers_pc); |
| 737 if (FLAG_trace_deopt) { |
| 738 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
| 739 " ; caller's pc\n", |
| 740 top_address + output_offset, output_offset, callers_pc); |
| 741 } |
| 742 |
| 743 // Read caller's FP from the previous frame, and set this frame's FP. |
| 744 output_offset -= kPointerSize; |
| 745 intptr_t value = output_[frame_index - 1]->GetFp(); |
| 746 output_frame->SetFrameSlot(output_offset, value); |
| 747 intptr_t fp_value = top_address + output_offset; |
| 748 output_frame->SetFp(fp_value); |
| 749 if (FLAG_trace_deopt) { |
| 750 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
| 751 " ; caller's fp\n", |
| 752 fp_value, output_offset, value); |
| 753 } |
| 754 |
| 755 // The context can be gotten from the previous frame. |
| 756 output_offset -= kPointerSize; |
| 757 value = output_[frame_index - 1]->GetContext(); |
| 758 output_frame->SetFrameSlot(output_offset, value); |
| 759 if (FLAG_trace_deopt) { |
| 760 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
| 761 " ; context\n", |
| 762 top_address + output_offset, output_offset, value); |
| 763 } |
| 764 |
| 765 // A marker value is used in place of the function. |
| 766 output_offset -= kPointerSize; |
| 767 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL)); |
| 768 output_frame->SetFrameSlot(output_offset, value); |
| 769 if (FLAG_trace_deopt) { |
| 770 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
| 771 " ; function (setter sentinel)\n", |
| 772 top_address + output_offset, output_offset, value); |
| 773 } |
| 774 |
| 775 // Get Code object from setter stub. |
| 776 output_offset -= kPointerSize; |
| 777 Code* setter_stub = |
| 778 isolate_->builtins()->builtin(Builtins::kStoreIC_Setter_ForDeopt); |
| 779 value = reinterpret_cast<intptr_t>(setter_stub); |
| 780 output_frame->SetFrameSlot(output_offset, value); |
| 781 if (FLAG_trace_deopt) { |
| 782 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
| 783 " ; code object\n", |
| 784 top_address + output_offset, output_offset, value); |
| 785 } |
| 786 |
| 787 // Skip receiver. |
| 788 Translation::Opcode opcode = |
| 789 static_cast<Translation::Opcode>(iterator->Next()); |
| 790 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); |
| 791 |
| 792 // The implicit return value was part of the artificial setter stub |
| 793 // environment. |
| 794 output_offset -= kPointerSize; |
| 795 DoTranslateCommand(iterator, frame_index, output_offset); |
| 796 |
| 797 ASSERT(0 == output_offset); |
| 798 |
| 799 intptr_t pc = reinterpret_cast<intptr_t>( |
| 800 setter_stub->instruction_start() + |
| 801 isolate_->heap()->setter_stub_deopt_pc_offset()->value()); |
| 802 output_frame->SetPc(pc); |
| 803 } |
| 804 |
| 805 |
697 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 806 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
698 int frame_index) { | 807 int frame_index) { |
699 BailoutId node_id = BailoutId(iterator->Next()); | 808 BailoutId node_id = BailoutId(iterator->Next()); |
700 JSFunction* function; | 809 JSFunction* function; |
701 if (frame_index != 0) { | 810 if (frame_index != 0) { |
702 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 811 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
703 } else { | 812 } else { |
704 int closure_id = iterator->Next(); | 813 int closure_id = iterator->Next(); |
705 USE(closure_id); | 814 USE(closure_id); |
706 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 815 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 } | 1203 } |
1095 __ bind(&done); | 1204 __ bind(&done); |
1096 } | 1205 } |
1097 | 1206 |
1098 #undef __ | 1207 #undef __ |
1099 | 1208 |
1100 | 1209 |
1101 } } // namespace v8::internal | 1210 } } // namespace v8::internal |
1102 | 1211 |
1103 #endif // V8_TARGET_ARCH_IA32 | 1212 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |