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 573 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 RHS are expected in registers by the IC, so they don't |
| 598 // belong to the output stack frame. This means that we have to use a height |
| 599 // of 0 instead of 2. |
| 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 // 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 (RHS, see |
| 609 // 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 function. |
| 673 output_offset -= kPointerSize; |
| 674 value = reinterpret_cast<intptr_t>(setter->code()); |
| 675 output_frame->SetFrameSlot(output_offset, value); |
| 676 if (FLAG_trace_deopt) { |
| 677 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
| 678 " ; code object\n", |
| 679 top_address + output_offset, output_offset, value); |
| 680 } |
| 681 |
| 682 // Skip receiver. |
| 683 Translation::Opcode opcode = |
| 684 static_cast<Translation::Opcode>(iterator->Next()); |
| 685 iterator->Skip(Translation::NumberOfOperandsFor(opcode)); |
| 686 |
| 687 // The RHS was part of the artificial setter stub environment. |
| 688 output_offset -= kPointerSize; |
| 689 DoTranslateCommand(iterator, frame_index, output_offset); |
| 690 |
| 691 ASSERT(0 == output_offset); |
| 692 |
| 693 Code* setter_stub = |
| 694 isolate_->builtins()->builtin(Builtins::kSetterStubForDeopt); |
| 695 intptr_t pc = reinterpret_cast<intptr_t>( |
| 696 setter_stub->instruction_start() + |
| 697 isolate_->heap()->setter_stub_deopt_pc_offset()->value()); |
| 698 output_frame->SetPc(pc); |
| 699 } |
| 700 |
| 701 |
594 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 702 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
595 int frame_index) { | 703 int frame_index) { |
596 BailoutId node_id = BailoutId(iterator->Next()); | 704 BailoutId node_id = BailoutId(iterator->Next()); |
597 JSFunction* function; | 705 JSFunction* function; |
598 if (frame_index != 0) { | 706 if (frame_index != 0) { |
599 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 707 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
600 } else { | 708 } else { |
601 int closure_id = iterator->Next(); | 709 int closure_id = iterator->Next(); |
602 USE(closure_id); | 710 USE(closure_id); |
603 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 711 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 } | 1106 } |
999 __ bind(&done); | 1107 __ bind(&done); |
1000 } | 1108 } |
1001 | 1109 |
1002 #undef __ | 1110 #undef __ |
1003 | 1111 |
1004 | 1112 |
1005 } } // namespace v8::internal | 1113 } } // namespace v8::internal |
1006 | 1114 |
1007 #endif // V8_TARGET_ARCH_X64 | 1115 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |