| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 584 |
| 585 ASSERT(0 == output_offset); | 585 ASSERT(0 == output_offset); |
| 586 | 586 |
| 587 intptr_t pc = reinterpret_cast<intptr_t>( | 587 intptr_t pc = reinterpret_cast<intptr_t>( |
| 588 construct_stub->instruction_start() + | 588 construct_stub->instruction_start() + |
| 589 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); | 589 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); |
| 590 output_frame->SetPc(pc); | 590 output_frame->SetPc(pc); |
| 591 } | 591 } |
| 592 | 592 |
| 593 | 593 |
| 594 void Deoptimizer::DoComputeSetterStubFrame(TranslationIterator* iterator, | |
| 595 int frame_index) { | |
| 596 JSFunction* setter = JSFunction::cast(ComputeLiteral(iterator->Next())); | |
| 597 // The receiver and the implicit return value are expected in registers by the | |
| 598 // StoreIC, so they don't belong to the output stack frame. This means that we | |
| 599 // have to use a height of 0. | |
| 600 unsigned height = 0; | |
| 601 unsigned height_in_bytes = height * kPointerSize; | |
| 602 if (FLAG_trace_deopt) { | |
| 603 PrintF(" translating setter stub => height=%u\n", height_in_bytes); | |
| 604 } | |
| 605 | |
| 606 // We need 1 stack entry for the return address + 4 stack entries from | |
| 607 // StackFrame::INTERNAL (FP, context, frame type, code object, see | |
| 608 // MacroAssembler::EnterFrame) + 1 stack entry from setter stub (implicit | |
| 609 // return value, see StoreStubCompiler::CompileStoreViaSetter). | |
| 610 unsigned fixed_frame_size = (1 + 4 + 1) * kPointerSize; | |
| 611 unsigned output_frame_size = height_in_bytes + fixed_frame_size; | |
| 612 | |
| 613 // Allocate and store the output frame description. | |
| 614 FrameDescription* output_frame = | |
| 615 new(output_frame_size) FrameDescription(output_frame_size, setter); | |
| 616 output_frame->SetFrameType(StackFrame::INTERNAL); | |
| 617 | |
| 618 // A frame for a setter stub can not be the topmost or bottommost one. | |
| 619 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); | |
| 620 ASSERT(output_[frame_index] == NULL); | |
| 621 output_[frame_index] = output_frame; | |
| 622 | |
| 623 // The top address of the frame is computed from the previous frame's top and | |
| 624 // this frame's size. | |
| 625 intptr_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | |
| 626 output_frame->SetTop(top_address); | |
| 627 | |
| 628 unsigned output_offset = output_frame_size; | |
| 629 | |
| 630 // Read caller's PC from the previous frame. | |
| 631 output_offset -= kPointerSize; | |
| 632 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); | |
| 633 output_frame->SetFrameSlot(output_offset, callers_pc); | |
| 634 if (FLAG_trace_deopt) { | |
| 635 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 636 " ; caller's pc\n", | |
| 637 top_address + output_offset, output_offset, callers_pc); | |
| 638 } | |
| 639 | |
| 640 // Read caller's FP from the previous frame, and set this frame's FP. | |
| 641 output_offset -= kPointerSize; | |
| 642 intptr_t value = output_[frame_index - 1]->GetFp(); | |
| 643 output_frame->SetFrameSlot(output_offset, value); | |
| 644 intptr_t fp_value = top_address + output_offset; | |
| 645 output_frame->SetFp(fp_value); | |
| 646 if (FLAG_trace_deopt) { | |
| 647 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 648 " ; caller's fp\n", | |
| 649 fp_value, output_offset, value); | |
| 650 } | |
| 651 | |
| 652 // The context can be gotten from the previous frame. | |
| 653 output_offset -= kPointerSize; | |
| 654 value = output_[frame_index - 1]->GetContext(); | |
| 655 output_frame->SetFrameSlot(output_offset, value); | |
| 656 if (FLAG_trace_deopt) { | |
| 657 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 658 " ; context\n", | |
| 659 top_address + output_offset, output_offset, value); | |
| 660 } | |
| 661 | |
| 662 // A marker value is used in place of the function. | |
| 663 output_offset -= kPointerSize; | |
| 664 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL)); | |
| 665 output_frame->SetFrameSlot(output_offset, value); | |
| 666 if (FLAG_trace_deopt) { | |
| 667 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 668 " ; function (setter sentinel)\n", | |
| 669 top_address + output_offset, output_offset, value); | |
| 670 } | |
| 671 | |
| 672 // Get Code object from setter stub. | |
| 673 output_offset -= kPointerSize; | |
| 674 Code* setter_stub = | |
| 675 isolate_->builtins()->builtin(Builtins::kStoreIC_Setter_ForDeopt); | |
| 676 value = reinterpret_cast<intptr_t>(setter_stub); | |
| 677 output_frame->SetFrameSlot(output_offset, value); | |
| 678 if (FLAG_trace_deopt) { | |
| 679 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR | |
| 680 " ; code object\n", | |
| 681 top_address + output_offset, output_offset, value); | |
| 682 } | |
| 683 | |
| 684 // Skip receiver. | |
| 685 Translation::Opcode opcode = | |
| 686 static_cast<Translation::Opcode>(iterator->Next()); | |
| 687 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); | |
| 688 | |
| 689 // The implicit return value was part of the artificial setter stub | |
| 690 // environment. | |
| 691 output_offset -= kPointerSize; | |
| 692 DoTranslateCommand(iterator, frame_index, output_offset); | |
| 693 | |
| 694 ASSERT(0 == output_offset); | |
| 695 | |
| 696 intptr_t pc = reinterpret_cast<intptr_t>( | |
| 697 setter_stub->instruction_start() + | |
| 698 isolate_->heap()->setter_stub_deopt_pc_offset()->value()); | |
| 699 output_frame->SetPc(pc); | |
| 700 } | |
| 701 | |
| 702 | |
| 703 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 594 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
| 704 int frame_index) { | 595 int frame_index) { |
| 705 BailoutId node_id = BailoutId(iterator->Next()); | 596 BailoutId node_id = BailoutId(iterator->Next()); |
| 706 JSFunction* function; | 597 JSFunction* function; |
| 707 if (frame_index != 0) { | 598 if (frame_index != 0) { |
| 708 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 599 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 709 } else { | 600 } else { |
| 710 int closure_id = iterator->Next(); | 601 int closure_id = iterator->Next(); |
| 711 USE(closure_id); | 602 USE(closure_id); |
| 712 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 603 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 } | 998 } |
| 1108 __ bind(&done); | 999 __ bind(&done); |
| 1109 } | 1000 } |
| 1110 | 1001 |
| 1111 #undef __ | 1002 #undef __ |
| 1112 | 1003 |
| 1113 | 1004 |
| 1114 } } // namespace v8::internal | 1005 } } // namespace v8::internal |
| 1115 | 1006 |
| 1116 #endif // V8_TARGET_ARCH_X64 | 1007 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |