OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 | 575 |
576 ASSERT(0 == output_offset); | 576 ASSERT(0 == output_offset); |
577 | 577 |
578 uint32_t pc = reinterpret_cast<uint32_t>( | 578 uint32_t pc = reinterpret_cast<uint32_t>( |
579 construct_stub->instruction_start() + | 579 construct_stub->instruction_start() + |
580 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); | 580 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); |
581 output_frame->SetPc(pc); | 581 output_frame->SetPc(pc); |
582 } | 582 } |
583 | 583 |
584 | 584 |
| 585 void Deoptimizer::DoComputeSetterStubFrame(TranslationIterator* iterator, |
| 586 int frame_index) { |
| 587 JSFunction* setter = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 588 // The receiver and RHS are expected in registers by the IC, so they don't |
| 589 // belong to the output stack frame. This means that we have to use a height |
| 590 // of 0 instead of 2. |
| 591 unsigned height = 0; |
| 592 unsigned height_in_bytes = height * kPointerSize; |
| 593 if (FLAG_trace_deopt) { |
| 594 PrintF(" translating setter stub => height=%u\n", height_in_bytes); |
| 595 } |
| 596 |
| 597 // 1 stack entry for the return address + 5 stack entries from |
| 598 // StackFrame::INTERNAL (ra, fp, cp, frame type, code object, see |
| 599 // MacroAssembler::EnterFrame) + 1 stack entry from setter stub (RHS, see |
| 600 // StoreStubCompiler::CompileStoreViaSetter). |
| 601 unsigned fixed_frame_size = (1 + 5 + 1) * kPointerSize; |
| 602 unsigned output_frame_size = height_in_bytes + fixed_frame_size; |
| 603 |
| 604 // Allocate and store the output frame description. |
| 605 FrameDescription* output_frame = |
| 606 new(output_frame_size) FrameDescription(output_frame_size, setter); |
| 607 output_frame->SetFrameType(StackFrame::INTERNAL); |
| 608 |
| 609 // A frame for a setter stub can not be the topmost or bottommost one. |
| 610 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); |
| 611 ASSERT(output_[frame_index] == NULL); |
| 612 output_[frame_index] = output_frame; |
| 613 |
| 614 // The top address of the frame is computed from the previous frame's top and |
| 615 // this frame's size. |
| 616 uint32_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; |
| 617 output_frame->SetTop(top_address); |
| 618 |
| 619 unsigned output_offset = output_frame_size; |
| 620 |
| 621 // Read caller's PC from the previous frame. |
| 622 output_offset -= kPointerSize; |
| 623 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); |
| 624 output_frame->SetFrameSlot(output_offset, callers_pc); |
| 625 if (FLAG_trace_deopt) { |
| 626 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR |
| 627 " ; caller's pc\n", |
| 628 top_address + output_offset, output_offset, callers_pc); |
| 629 } |
| 630 |
| 631 // ra |
| 632 output_offset -= kPointerSize; |
| 633 intptr_t value = 0x87654321; // TODO(svenpanne) Get ra |
| 634 output_frame->SetFrameSlot(output_offset, value); |
| 635 if (FLAG_trace_deopt) { |
| 636 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR " ; ra\n", |
| 637 top_address + output_offset, output_offset, value); |
| 638 } |
| 639 |
| 640 // Read caller's FP from the previous frame, and set this frame's FP. |
| 641 output_offset -= kPointerSize; |
| 642 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 |
585 // This code is very similar to ia32/arm code, but relies on register names | 702 // This code is very similar to ia32/arm code, but relies on register names |
586 // (fp, sp) and how the frame is laid out. | 703 // (fp, sp) and how the frame is laid out. |
587 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, | 704 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, |
588 int frame_index) { | 705 int frame_index) { |
589 // Read the ast node id, function, and frame height for this output frame. | 706 // Read the ast node id, function, and frame height for this output frame. |
590 BailoutId node_id = BailoutId(iterator->Next()); | 707 BailoutId node_id = BailoutId(iterator->Next()); |
591 JSFunction* function; | 708 JSFunction* function; |
592 if (frame_index != 0) { | 709 if (frame_index != 0) { |
593 function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 710 function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
594 } else { | 711 } else { |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 } | 1132 } |
1016 | 1133 |
1017 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), | 1134 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), |
1018 count() * table_entry_size_); | 1135 count() * table_entry_size_); |
1019 } | 1136 } |
1020 | 1137 |
1021 #undef __ | 1138 #undef __ |
1022 | 1139 |
1023 | 1140 |
1024 } } // namespace v8::internal | 1141 } } // namespace v8::internal |
OLD | NEW |