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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 node->set_next(data->deoptimizing_code_list_); | 193 node->set_next(data->deoptimizing_code_list_); |
194 data->deoptimizing_code_list_ = node; | 194 data->deoptimizing_code_list_ = node; |
195 | 195 |
196 // We might be in the middle of incremental marking with compaction. | 196 // We might be in the middle of incremental marking with compaction. |
197 // Tell collector to treat this code object in a special way and | 197 // Tell collector to treat this code object in a special way and |
198 // ignore all slots that might have been recorded on it. | 198 // ignore all slots that might have been recorded on it. |
199 isolate->heap()->mark_compact_collector()->InvalidateCode(code); | 199 isolate->heap()->mark_compact_collector()->InvalidateCode(code); |
200 | 200 |
201 // Iterate over all the functions which share the same code object | 201 // Iterate over all the functions which share the same code object |
202 // and make them use unoptimized version. | 202 // and make them use unoptimized version. |
203 Context* context = function->context()->native_context(); | 203 Context* context = function->context()->global_context(); |
204 Object* element = context->get(Context::OPTIMIZED_FUNCTIONS_LIST); | 204 Object* element = context->get(Context::OPTIMIZED_FUNCTIONS_LIST); |
205 SharedFunctionInfo* shared = function->shared(); | 205 SharedFunctionInfo* shared = function->shared(); |
206 while (!element->IsUndefined()) { | 206 while (!element->IsUndefined()) { |
207 JSFunction* func = JSFunction::cast(element); | 207 JSFunction* func = JSFunction::cast(element); |
208 // Grab element before code replacement as ReplaceCode alters the list. | 208 // Grab element before code replacement as ReplaceCode alters the list. |
209 element = func->next_function_link(); | 209 element = func->next_function_link(); |
210 if (func->code() == code) { | 210 if (func->code() == code) { |
211 func->ReplaceCode(shared->code()); | 211 func->ReplaceCode(shared->code()); |
212 } | 212 } |
213 } | 213 } |
(...skipping 473 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 | |
806 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 697 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
807 int frame_index) { | 698 int frame_index) { |
808 BailoutId node_id = BailoutId(iterator->Next()); | 699 BailoutId node_id = BailoutId(iterator->Next()); |
809 JSFunction* function; | 700 JSFunction* function; |
810 if (frame_index != 0) { | 701 if (frame_index != 0) { |
811 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 702 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
812 } else { | 703 } else { |
813 int closure_id = iterator->Next(); | 704 int closure_id = iterator->Next(); |
814 USE(closure_id); | 705 USE(closure_id); |
815 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 706 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 } | 1094 } |
1204 __ bind(&done); | 1095 __ bind(&done); |
1205 } | 1096 } |
1206 | 1097 |
1207 #undef __ | 1098 #undef __ |
1208 | 1099 |
1209 | 1100 |
1210 } } // namespace v8::internal | 1101 } } // namespace v8::internal |
1211 | 1102 |
1212 #endif // V8_TARGET_ARCH_IA32 | 1103 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |