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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 ok = DoOsrTranslateCommand(&iterator, &input_offset); | 399 ok = DoOsrTranslateCommand(&iterator, &input_offset); |
400 } | 400 } |
401 | 401 |
402 // If translation of any command failed, continue using the input frame. | 402 // If translation of any command failed, continue using the input frame. |
403 if (!ok) { | 403 if (!ok) { |
404 delete output_[0]; | 404 delete output_[0]; |
405 output_[0] = input_; | 405 output_[0] = input_; |
406 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); | 406 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); |
407 } else { | 407 } else { |
408 // Set up the frame pointer and the context pointer. | 408 // Set up the frame pointer and the context pointer. |
409 // All OSR stack frames are dynamically aligned to an 8-byte boundary. | 409 output_[0]->SetRegister(ebp.code(), input_->GetRegister(ebp.code())); |
410 int frame_pointer = input_->GetRegister(ebp.code()); | |
411 if ((frame_pointer & 0x4) == 0) { | |
412 // Return address at FP + 4 should be aligned, so FP mod 8 should be 4. | |
413 frame_pointer -= kPointerSize; | |
414 has_alignment_padding_ = 1; | |
415 } | |
416 output_[0]->SetRegister(ebp.code(), frame_pointer); | |
417 output_[0]->SetRegister(esi.code(), input_->GetRegister(esi.code())); | 410 output_[0]->SetRegister(esi.code(), input_->GetRegister(esi.code())); |
418 | 411 |
419 unsigned pc_offset = data->OsrPcOffset()->value(); | 412 unsigned pc_offset = data->OsrPcOffset()->value(); |
420 uint32_t pc = reinterpret_cast<uint32_t>( | 413 uint32_t pc = reinterpret_cast<uint32_t>( |
421 optimized_code_->entry() + pc_offset); | 414 optimized_code_->entry() + pc_offset); |
422 output_[0]->SetPc(pc); | 415 output_[0]->SetPc(pc); |
423 } | 416 } |
424 Code* continuation = | 417 Code* continuation = |
425 function->GetIsolate()->builtins()->builtin(Builtins::kNotifyOSR); | 418 function->GetIsolate()->builtins()->builtin(Builtins::kNotifyOSR); |
426 output_[0]->SetContinuation( | 419 output_[0]->SetContinuation( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 ASSERT(frame_index >= 0 && frame_index < output_count_); | 561 ASSERT(frame_index >= 0 && frame_index < output_count_); |
569 ASSERT(output_[frame_index] == NULL); | 562 ASSERT(output_[frame_index] == NULL); |
570 output_[frame_index] = output_frame; | 563 output_[frame_index] = output_frame; |
571 | 564 |
572 // The top address for the bottommost output frame can be computed from | 565 // The top address for the bottommost output frame can be computed from |
573 // the input frame pointer and the output frame's height. For all | 566 // the input frame pointer and the output frame's height. For all |
574 // subsequent output frames, it can be computed from the previous one's | 567 // subsequent output frames, it can be computed from the previous one's |
575 // top address and the current frame's size. | 568 // top address and the current frame's size. |
576 uint32_t top_address; | 569 uint32_t top_address; |
577 if (is_bottommost) { | 570 if (is_bottommost) { |
578 // If the optimized frame had alignment padding, adjust the frame pointer | 571 // 2 = context and function in the frame. |
579 // to point to the new position of the old frame pointer after padding | 572 top_address = |
580 // is removed. Subtract 2 * kPointerSize for the context and function slots. | 573 input_->GetRegister(ebp.code()) - (2 * kPointerSize) - height_in_bytes; |
581 top_address = input_->GetRegister(ebp.code()) - (2 * kPointerSize) - | |
582 height_in_bytes + has_alignment_padding_ * kPointerSize; | |
583 } else { | 574 } else { |
584 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | 575 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; |
585 } | 576 } |
586 output_frame->SetTop(top_address); | 577 output_frame->SetTop(top_address); |
587 | 578 |
588 // Compute the incoming parameter translation. | 579 // Compute the incoming parameter translation. |
589 int parameter_count = function->shared()->formal_parameter_count() + 1; | 580 int parameter_count = function->shared()->formal_parameter_count() + 1; |
590 unsigned output_offset = output_frame_size; | 581 unsigned output_offset = output_frame_size; |
591 unsigned input_offset = input_frame_size; | 582 unsigned input_offset = input_frame_size; |
592 for (int i = 0; i < parameter_count; ++i) { | 583 for (int i = 0; i < parameter_count; ++i) { |
(...skipping 30 matching lines...) Expand all Loading... |
623 // pointer. | 614 // pointer. |
624 output_offset -= kPointerSize; | 615 output_offset -= kPointerSize; |
625 input_offset -= kPointerSize; | 616 input_offset -= kPointerSize; |
626 if (is_bottommost) { | 617 if (is_bottommost) { |
627 value = input_->GetFrameSlot(input_offset); | 618 value = input_->GetFrameSlot(input_offset); |
628 } else { | 619 } else { |
629 value = output_[frame_index - 1]->GetFp(); | 620 value = output_[frame_index - 1]->GetFp(); |
630 } | 621 } |
631 output_frame->SetFrameSlot(output_offset, value); | 622 output_frame->SetFrameSlot(output_offset, value); |
632 intptr_t fp_value = top_address + output_offset; | 623 intptr_t fp_value = top_address + output_offset; |
633 ASSERT(!is_bottommost || | 624 ASSERT(!is_bottommost || input_->GetRegister(ebp.code()) == fp_value); |
634 input_->GetRegister(ebp.code()) + has_alignment_padding_ * kPointerSize | |
635 == fp_value); | |
636 output_frame->SetFp(fp_value); | 625 output_frame->SetFp(fp_value); |
637 if (is_topmost) output_frame->SetRegister(ebp.code(), fp_value); | 626 if (is_topmost) output_frame->SetRegister(ebp.code(), fp_value); |
638 if (FLAG_trace_deopt) { | 627 if (FLAG_trace_deopt) { |
639 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", | 628 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", |
640 fp_value, output_offset, value); | 629 fp_value, output_offset, value); |
641 } | 630 } |
642 | 631 |
643 // For the bottommost output frame the context can be gotten from the input | 632 // For the bottommost output frame the context can be gotten from the input |
644 // frame. For all subsequent output frames it can be gotten from the function | 633 // frame. For all subsequent output frames it can be gotten from the function |
645 // so long as we don't inline functions that need local contexts. | 634 // so long as we don't inline functions that need local contexts. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 // limit and copy the contents of the activation frame to the input | 803 // limit and copy the contents of the activation frame to the input |
815 // frame description. | 804 // frame description. |
816 __ lea(edx, Operand(ebx, FrameDescription::frame_content_offset())); | 805 __ lea(edx, Operand(ebx, FrameDescription::frame_content_offset())); |
817 Label pop_loop; | 806 Label pop_loop; |
818 __ bind(&pop_loop); | 807 __ bind(&pop_loop); |
819 __ pop(Operand(edx, 0)); | 808 __ pop(Operand(edx, 0)); |
820 __ add(edx, Immediate(sizeof(uint32_t))); | 809 __ add(edx, Immediate(sizeof(uint32_t))); |
821 __ cmp(ecx, esp); | 810 __ cmp(ecx, esp); |
822 __ j(not_equal, &pop_loop); | 811 __ j(not_equal, &pop_loop); |
823 | 812 |
824 // If frame was dynamically aligned, pop padding. | |
825 Label sentinel, sentinel_done; | |
826 __ pop(ecx); | |
827 __ cmp(ecx, Operand(eax, Deoptimizer::frame_alignment_marker_offset())); | |
828 __ j(equal, &sentinel); | |
829 __ push(ecx); | |
830 __ jmp(&sentinel_done); | |
831 __ bind(&sentinel); | |
832 __ mov(Operand(eax, Deoptimizer::has_alignment_padding_offset()), | |
833 Immediate(1)); | |
834 __ bind(&sentinel_done); | |
835 // Compute the output frame in the deoptimizer. | 813 // Compute the output frame in the deoptimizer. |
836 __ push(eax); | 814 __ push(eax); |
837 __ PrepareCallCFunction(1, ebx); | 815 __ PrepareCallCFunction(1, ebx); |
838 __ mov(Operand(esp, 0 * kPointerSize), eax); | 816 __ mov(Operand(esp, 0 * kPointerSize), eax); |
839 { | 817 { |
840 AllowExternalCallThatCantCauseGC scope(masm()); | 818 AllowExternalCallThatCantCauseGC scope(masm()); |
841 __ CallCFunction( | 819 __ CallCFunction( |
842 ExternalReference::compute_output_frames_function(isolate), 1); | 820 ExternalReference::compute_output_frames_function(isolate), 1); |
843 } | 821 } |
844 __ pop(eax); | 822 __ pop(eax); |
845 | 823 |
846 if (type() == OSR) { | |
847 // If alignment padding is added, push the sentinel. | |
848 Label no_osr_padding; | |
849 __ cmp(Operand(eax, Deoptimizer::has_alignment_padding_offset()), | |
850 Immediate(0)); | |
851 __ j(equal, &no_osr_padding, Label::kNear); | |
852 __ push(Operand(eax, Deoptimizer::frame_alignment_marker_offset())); | |
853 __ bind(&no_osr_padding); | |
854 } | |
855 | |
856 | |
857 // Replace the current frame with the output frames. | 824 // Replace the current frame with the output frames. |
858 Label outer_push_loop, inner_push_loop; | 825 Label outer_push_loop, inner_push_loop; |
859 // Outer loop state: eax = current FrameDescription**, edx = one past the | 826 // Outer loop state: eax = current FrameDescription**, edx = one past the |
860 // last FrameDescription**. | 827 // last FrameDescription**. |
861 __ mov(edx, Operand(eax, Deoptimizer::output_count_offset())); | 828 __ mov(edx, Operand(eax, Deoptimizer::output_count_offset())); |
862 __ mov(eax, Operand(eax, Deoptimizer::output_offset())); | 829 __ mov(eax, Operand(eax, Deoptimizer::output_offset())); |
863 __ lea(edx, Operand(eax, edx, times_4, 0)); | 830 __ lea(edx, Operand(eax, edx, times_4, 0)); |
864 __ bind(&outer_push_loop); | 831 __ bind(&outer_push_loop); |
865 // Inner loop state: ebx = current FrameDescription*, ecx = loop index. | 832 // Inner loop state: ebx = current FrameDescription*, ecx = loop index. |
866 __ mov(ebx, Operand(eax, 0)); | 833 __ mov(ebx, Operand(eax, 0)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 } | 884 } |
918 __ bind(&done); | 885 __ bind(&done); |
919 } | 886 } |
920 | 887 |
921 #undef __ | 888 #undef __ |
922 | 889 |
923 | 890 |
924 } } // namespace v8::internal | 891 } } // namespace v8::internal |
925 | 892 |
926 #endif // V8_TARGET_ARCH_IA32 | 893 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |