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, | 697 void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, |
698 int frame_index) { | 698 int frame_index, |
699 JSFunction* setter = JSFunction::cast(ComputeLiteral(iterator->Next())); | 699 bool is_setter_stub_frame) { |
700 // The receiver and the implicit return value are expected in registers by the | 700 JSFunction* accessor = JSFunction::cast(ComputeLiteral(iterator->Next())); |
701 // StoreIC, so they don't belong to the output stack frame. This means that we | 701 // The receiver (and the implicit return value, if any) are expected in |
702 // have to use a height of 0. | 702 // registers by the LoadIC/StoreIC, so they don't belong to the output stack |
| 703 // frame. This means that we have to use a height of 0. |
703 unsigned height = 0; | 704 unsigned height = 0; |
704 unsigned height_in_bytes = height * kPointerSize; | 705 unsigned height_in_bytes = height * kPointerSize; |
| 706 const char* kind = is_setter_stub_frame ? "setter" : "getter"; |
705 if (FLAG_trace_deopt) { | 707 if (FLAG_trace_deopt) { |
706 PrintF(" translating setter stub => height=%u\n", height_in_bytes); | 708 PrintF(" translating %s stub => height=%u\n", kind, height_in_bytes); |
707 } | 709 } |
708 | 710 |
709 // We need 1 stack entry for the return address + 4 stack entries from | 711 // We need 1 stack entry for the return address + 4 stack entries from |
710 // StackFrame::INTERNAL (FP, context, frame type, code object, see | 712 // StackFrame::INTERNAL (FP, context, frame type, code object, see |
711 // MacroAssembler::EnterFrame) + 1 stack entry from setter stub (implicit | 713 // MacroAssembler::EnterFrame). For a setter stub frame we need one additional |
712 // return value, see StoreStubCompiler::CompileStoreViaSetter). | 714 // entry for the implicit return value, see |
713 unsigned fixed_frame_size = (1 + 4 + 1) * kPointerSize; | 715 // StoreStubCompiler::CompileStoreViaSetter. |
| 716 unsigned fixed_frame_entries = 1 + 4 + (is_setter_stub_frame ? 1 : 0); |
| 717 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize; |
714 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | 718 unsigned output_frame_size = height_in_bytes + fixed_frame_size; |
715 | 719 |
716 // Allocate and store the output frame description. | 720 // Allocate and store the output frame description. |
717 FrameDescription* output_frame = | 721 FrameDescription* output_frame = |
718 new(output_frame_size) FrameDescription(output_frame_size, setter); | 722 new(output_frame_size) FrameDescription(output_frame_size, accessor); |
719 output_frame->SetFrameType(StackFrame::INTERNAL); | 723 output_frame->SetFrameType(StackFrame::INTERNAL); |
720 | 724 |
721 // A frame for a setter stub can not be the topmost or bottommost one. | 725 // A frame for an accessor stub can not be the topmost or bottommost one. |
722 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | 726 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); |
723 ASSERT(output_[frame_index] == NULL); | 727 ASSERT(output_[frame_index] == NULL); |
724 output_[frame_index] = output_frame; | 728 output_[frame_index] = output_frame; |
725 | 729 |
726 // The top address of the frame is computed from the previous frame's top and | 730 // The top address of the frame is computed from the previous frame's top and |
727 // this frame's size. | 731 // this frame's size. |
728 intptr_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | 732 intptr_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; |
729 output_frame->SetTop(top_address); | 733 output_frame->SetTop(top_address); |
730 | 734 |
731 unsigned output_offset = output_frame_size; | 735 unsigned output_offset = output_frame_size; |
(...skipping 29 matching lines...) Expand all Loading... |
761 " ; context\n", | 765 " ; context\n", |
762 top_address + output_offset, output_offset, value); | 766 top_address + output_offset, output_offset, value); |
763 } | 767 } |
764 | 768 |
765 // A marker value is used in place of the function. | 769 // A marker value is used in place of the function. |
766 output_offset -= kPointerSize; | 770 output_offset -= kPointerSize; |
767 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL)); | 771 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL)); |
768 output_frame->SetFrameSlot(output_offset, value); | 772 output_frame->SetFrameSlot(output_offset, value); |
769 if (FLAG_trace_deopt) { | 773 if (FLAG_trace_deopt) { |
770 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | 774 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
771 " ; function (setter sentinel)\n", | 775 " ; function (%s sentinel)\n", |
772 top_address + output_offset, output_offset, value); | 776 top_address + output_offset, output_offset, value, kind); |
773 } | 777 } |
774 | 778 |
775 // Get Code object from setter stub. | 779 // Get Code object from accessor stub. |
776 output_offset -= kPointerSize; | 780 output_offset -= kPointerSize; |
777 Code* setter_stub = | 781 Builtins::Name name = is_setter_stub_frame ? |
778 isolate_->builtins()->builtin(Builtins::kStoreIC_Setter_ForDeopt); | 782 Builtins::kStoreIC_Setter_ForDeopt : |
779 value = reinterpret_cast<intptr_t>(setter_stub); | 783 Builtins::kLoadIC_Getter_ForDeopt; |
| 784 Code* accessor_stub = isolate_->builtins()->builtin(name); |
| 785 value = reinterpret_cast<intptr_t>(accessor_stub); |
780 output_frame->SetFrameSlot(output_offset, value); | 786 output_frame->SetFrameSlot(output_offset, value); |
781 if (FLAG_trace_deopt) { | 787 if (FLAG_trace_deopt) { |
782 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | 788 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
783 " ; code object\n", | 789 " ; code object\n", |
784 top_address + output_offset, output_offset, value); | 790 top_address + output_offset, output_offset, value); |
785 } | 791 } |
786 | 792 |
787 // Skip receiver. | 793 // Skip receiver. |
788 Translation::Opcode opcode = | 794 Translation::Opcode opcode = |
789 static_cast<Translation::Opcode>(iterator->Next()); | 795 static_cast<Translation::Opcode>(iterator->Next()); |
790 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); | 796 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); |
791 | 797 |
792 // The implicit return value was part of the artificial setter stub | 798 if (is_setter_stub_frame) { |
793 // environment. | 799 // The implicit return value was part of the artificial setter stub |
794 output_offset -= kPointerSize; | 800 // environment. |
795 DoTranslateCommand(iterator, frame_index, output_offset); | 801 output_offset -= kPointerSize; |
| 802 DoTranslateCommand(iterator, frame_index, output_offset); |
| 803 } |
796 | 804 |
797 ASSERT(0 == output_offset); | 805 ASSERT(0 == output_offset); |
798 | 806 |
| 807 Smi* offset = is_setter_stub_frame ? |
| 808 isolate_->heap()->setter_stub_deopt_pc_offset() : |
| 809 isolate_->heap()->getter_stub_deopt_pc_offset(); |
799 intptr_t pc = reinterpret_cast<intptr_t>( | 810 intptr_t pc = reinterpret_cast<intptr_t>( |
800 setter_stub->instruction_start() + | 811 accessor_stub->instruction_start() + offset->value()); |
801 isolate_->heap()->setter_stub_deopt_pc_offset()->value()); | |
802 output_frame->SetPc(pc); | 812 output_frame->SetPc(pc); |
803 } | 813 } |
804 | 814 |
805 | 815 |
806 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 816 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
807 int frame_index) { | 817 int frame_index) { |
808 BailoutId node_id = BailoutId(iterator->Next()); | 818 BailoutId node_id = BailoutId(iterator->Next()); |
809 JSFunction* function; | 819 JSFunction* function; |
810 if (frame_index != 0) { | 820 if (frame_index != 0) { |
811 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 821 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 } | 1213 } |
1204 __ bind(&done); | 1214 __ bind(&done); |
1205 } | 1215 } |
1206 | 1216 |
1207 #undef __ | 1217 #undef __ |
1208 | 1218 |
1209 | 1219 |
1210 } } // namespace v8::internal | 1220 } } // namespace v8::internal |
1211 | 1221 |
1212 #endif // V8_TARGET_ARCH_IA32 | 1222 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |