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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 node->set_next(data->deoptimizing_code_list_); | 99 node->set_next(data->deoptimizing_code_list_); |
100 data->deoptimizing_code_list_ = node; | 100 data->deoptimizing_code_list_ = node; |
101 | 101 |
102 // We might be in the middle of incremental marking with compaction. | 102 // We might be in the middle of incremental marking with compaction. |
103 // Tell collector to treat this code object in a special way and | 103 // Tell collector to treat this code object in a special way and |
104 // ignore all slots that might have been recorded on it. | 104 // ignore all slots that might have been recorded on it. |
105 isolate->heap()->mark_compact_collector()->InvalidateCode(code); | 105 isolate->heap()->mark_compact_collector()->InvalidateCode(code); |
106 | 106 |
107 // Iterate over all the functions which share the same code object | 107 // Iterate over all the functions which share the same code object |
108 // and make them use unoptimized version. | 108 // and make them use unoptimized version. |
109 Context* context = function->context()->native_context(); | 109 Context* context = function->context()->global_context(); |
110 Object* element = context->get(Context::OPTIMIZED_FUNCTIONS_LIST); | 110 Object* element = context->get(Context::OPTIMIZED_FUNCTIONS_LIST); |
111 SharedFunctionInfo* shared = function->shared(); | 111 SharedFunctionInfo* shared = function->shared(); |
112 while (!element->IsUndefined()) { | 112 while (!element->IsUndefined()) { |
113 JSFunction* func = JSFunction::cast(element); | 113 JSFunction* func = JSFunction::cast(element); |
114 // Grab element before code replacement as ReplaceCode alters the list. | 114 // Grab element before code replacement as ReplaceCode alters the list. |
115 element = func->next_function_link(); | 115 element = func->next_function_link(); |
116 if (func->code() == code) { | 116 if (func->code() == code) { |
117 func->ReplaceCode(shared->code()); | 117 func->ReplaceCode(shared->code()); |
118 } | 118 } |
119 } | 119 } |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 588 |
589 ASSERT(0 == output_offset); | 589 ASSERT(0 == output_offset); |
590 | 590 |
591 uint32_t pc = reinterpret_cast<uint32_t>( | 591 uint32_t pc = reinterpret_cast<uint32_t>( |
592 construct_stub->instruction_start() + | 592 construct_stub->instruction_start() + |
593 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); | 593 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); |
594 output_frame->SetPc(pc); | 594 output_frame->SetPc(pc); |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 void Deoptimizer::DoComputeSetterStubFrame(TranslationIterator* iterator, | |
599 int frame_index) { | |
600 JSFunction* setter = JSFunction::cast(ComputeLiteral(iterator->Next())); | |
601 // The receiver and the implicit return value are expected in registers by the | |
602 // StoreIC, so they don't belong to the output stack frame. This means that we | |
603 // have to use a height of 0. | |
604 unsigned height = 0; | |
605 unsigned height_in_bytes = height * kPointerSize; | |
606 if (FLAG_trace_deopt) { | |
607 PrintF(" translating setter stub => height=%u\n", height_in_bytes); | |
608 } | |
609 | |
610 // We need 5 stack entries from StackFrame::INTERNAL (lr, fp, cp, frame type, | |
611 // code object, see MacroAssembler::EnterFrame) + 1 stack entry from setter | |
612 // stub (implicit return value, see StoreStubCompiler::CompileStoreViaSetter). | |
613 unsigned fixed_frame_size = (5 + 1) * kPointerSize; | |
614 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | |
615 | |
616 // Allocate and store the output frame description. | |
617 FrameDescription* output_frame = | |
618 new(output_frame_size) FrameDescription(output_frame_size, setter); | |
619 output_frame->SetFrameType(StackFrame::INTERNAL); | |
620 | |
621 // A frame for a setter stub can not be the topmost or bottommost one. | |
622 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | |
623 ASSERT(output_[frame_index] == NULL); | |
624 output_[frame_index] = output_frame; | |
625 | |
626 // The top address of the frame is computed from the previous frame's top and | |
627 // this frame's size. | |
628 uint32_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | |
629 output_frame->SetTop(top_address); | |
630 | |
631 unsigned output_offset = output_frame_size; | |
632 | |
633 // Read caller's PC from the previous frame. | |
634 output_offset -= kPointerSize; | |
635 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); | |
636 output_frame->SetFrameSlot(output_offset, callers_pc); | |
637 if (FLAG_trace_deopt) { | |
638 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
639 " ; caller's pc\n", | |
640 top_address + output_offset, output_offset, callers_pc); | |
641 } | |
642 | |
643 // Read caller's FP from the previous frame, and set this frame's FP. | |
644 output_offset -= kPointerSize; | |
645 intptr_t value = output_[frame_index - 1]->GetFp(); | |
646 output_frame->SetFrameSlot(output_offset, value); | |
647 intptr_t fp_value = top_address + output_offset; | |
648 output_frame->SetFp(fp_value); | |
649 if (FLAG_trace_deopt) { | |
650 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
651 " ; caller's fp\n", | |
652 fp_value, output_offset, value); | |
653 } | |
654 | |
655 // The context can be gotten from the previous frame. | |
656 output_offset -= kPointerSize; | |
657 value = output_[frame_index - 1]->GetContext(); | |
658 output_frame->SetFrameSlot(output_offset, value); | |
659 if (FLAG_trace_deopt) { | |
660 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
661 " ; context\n", | |
662 top_address + output_offset, output_offset, value); | |
663 } | |
664 | |
665 // A marker value is used in place of the function. | |
666 output_offset -= kPointerSize; | |
667 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL)); | |
668 output_frame->SetFrameSlot(output_offset, value); | |
669 if (FLAG_trace_deopt) { | |
670 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
671 " ; function (setter sentinel)\n", | |
672 top_address + output_offset, output_offset, value); | |
673 } | |
674 | |
675 // Get Code object from setter stub. | |
676 output_offset -= kPointerSize; | |
677 Code* setter_stub = | |
678 isolate_->builtins()->builtin(Builtins::kStoreIC_Setter_ForDeopt); | |
679 value = reinterpret_cast<intptr_t>(setter_stub); | |
680 output_frame->SetFrameSlot(output_offset, value); | |
681 if (FLAG_trace_deopt) { | |
682 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
683 " ; code object\n", | |
684 top_address + output_offset, output_offset, value); | |
685 } | |
686 | |
687 // Skip receiver. | |
688 Translation::Opcode opcode = | |
689 static_cast<Translation::Opcode>(iterator->Next()); | |
690 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); | |
691 | |
692 // The implicit return value was part of the artificial setter stub | |
693 // environment. | |
694 output_offset -= kPointerSize; | |
695 DoTranslateCommand(iterator, frame_index, output_offset); | |
696 | |
697 ASSERT(0 == output_offset); | |
698 | |
699 intptr_t pc = reinterpret_cast<intptr_t>( | |
700 setter_stub->instruction_start() + | |
701 isolate_->heap()->setter_stub_deopt_pc_offset()->value()); | |
702 output_frame->SetPc(pc); | |
703 } | |
704 | |
705 | |
706 // This code is very similar to ia32 code, but relies on register names (fp, sp) | 598 // This code is very similar to ia32 code, but relies on register names (fp, sp) |
707 // and how the frame is laid out. | 599 // and how the frame is laid out. |
708 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 600 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
709 int frame_index) { | 601 int frame_index) { |
710 // Read the ast node id, function, and frame height for this output frame. | 602 // Read the ast node id, function, and frame height for this output frame. |
711 BailoutId node_id = BailoutId(iterator->Next()); | 603 BailoutId node_id = BailoutId(iterator->Next()); |
712 JSFunction* function; | 604 JSFunction* function; |
713 if (frame_index != 0) { | 605 if (frame_index != 0) { |
714 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 606 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
715 } else { | 607 } else { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 __ push(ip); | 1004 __ push(ip); |
1113 __ b(&done); | 1005 __ b(&done); |
1114 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1006 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
1115 } | 1007 } |
1116 __ bind(&done); | 1008 __ bind(&done); |
1117 } | 1009 } |
1118 | 1010 |
1119 #undef __ | 1011 #undef __ |
1120 | 1012 |
1121 } } // namespace v8::internal | 1013 } } // namespace v8::internal |
OLD | NEW |