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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 ok = DoOsrTranslateCommand(&iterator, &input_offset); | 420 ok = DoOsrTranslateCommand(&iterator, &input_offset); |
421 } | 421 } |
422 | 422 |
423 // If translation of any command failed, continue using the input frame. | 423 // If translation of any command failed, continue using the input frame. |
424 if (!ok) { | 424 if (!ok) { |
425 delete output_[0]; | 425 delete output_[0]; |
426 output_[0] = input_; | 426 output_[0] = input_; |
427 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); | 427 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); |
428 } else { | 428 } else { |
429 // Setup the frame pointer and the context pointer. | 429 // Setup the frame pointer and the context pointer. |
430 output_[0]->SetRegister(ebp.code(), input_->GetRegister(ebp.code())); | 430 // All OSR stack frames are dynamically aligned to an 8-byte boundary. |
| 431 int frame_pointer = input_->GetRegister(ebp.code()); |
| 432 if ((frame_pointer & 0x4) == 0) { |
| 433 // Return address at FP + 4 should be aligned, so FP mod 8 should be 4. |
| 434 frame_pointer -= kPointerSize; |
| 435 has_alignment_padding_ = 1; |
| 436 } |
| 437 output_[0]->SetRegister(ebp.code(), frame_pointer); |
431 output_[0]->SetRegister(esi.code(), input_->GetRegister(esi.code())); | 438 output_[0]->SetRegister(esi.code(), input_->GetRegister(esi.code())); |
432 | 439 |
433 unsigned pc_offset = data->OsrPcOffset()->value(); | 440 unsigned pc_offset = data->OsrPcOffset()->value(); |
434 uint32_t pc = reinterpret_cast<uint32_t>( | 441 uint32_t pc = reinterpret_cast<uint32_t>( |
435 optimized_code_->entry() + pc_offset); | 442 optimized_code_->entry() + pc_offset); |
436 output_[0]->SetPc(pc); | 443 output_[0]->SetPc(pc); |
437 } | 444 } |
438 Code* continuation = | 445 Code* continuation = |
439 function->GetIsolate()->builtins()->builtin(Builtins::kNotifyOSR); | 446 function->GetIsolate()->builtins()->builtin(Builtins::kNotifyOSR); |
440 output_[0]->SetContinuation( | 447 output_[0]->SetContinuation( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 ASSERT(frame_index >= 0 && frame_index < output_count_); | 492 ASSERT(frame_index >= 0 && frame_index < output_count_); |
486 ASSERT(output_[frame_index] == NULL); | 493 ASSERT(output_[frame_index] == NULL); |
487 output_[frame_index] = output_frame; | 494 output_[frame_index] = output_frame; |
488 | 495 |
489 // The top address for the bottommost output frame can be computed from | 496 // The top address for the bottommost output frame can be computed from |
490 // the input frame pointer and the output frame's height. For all | 497 // the input frame pointer and the output frame's height. For all |
491 // subsequent output frames, it can be computed from the previous one's | 498 // subsequent output frames, it can be computed from the previous one's |
492 // top address and the current frame's size. | 499 // top address and the current frame's size. |
493 uint32_t top_address; | 500 uint32_t top_address; |
494 if (is_bottommost) { | 501 if (is_bottommost) { |
495 // 2 = context and function in the frame. | 502 // If the optimized frame had alignment padding, adjust the frame pointer |
496 top_address = | 503 // to point to the new position of the old frame pointer after padding |
497 input_->GetRegister(ebp.code()) - (2 * kPointerSize) - height_in_bytes; | 504 // is removed. Subtract 2 * kPointerSize for the context and function slots. |
| 505 top_address = input_->GetRegister(ebp.code()) - (2 * kPointerSize) - |
| 506 height_in_bytes + has_alignment_padding_ * kPointerSize; |
498 } else { | 507 } else { |
499 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; | 508 top_address = output_[frame_index - 1]->GetTop() - output_frame_size; |
500 } | 509 } |
501 output_frame->SetTop(top_address); | 510 output_frame->SetTop(top_address); |
502 | 511 |
503 // Compute the incoming parameter translation. | 512 // Compute the incoming parameter translation. |
504 int parameter_count = function->shared()->formal_parameter_count() + 1; | 513 int parameter_count = function->shared()->formal_parameter_count() + 1; |
505 unsigned output_offset = output_frame_size; | 514 unsigned output_offset = output_frame_size; |
506 unsigned input_offset = input_frame_size; | 515 unsigned input_offset = input_frame_size; |
507 for (int i = 0; i < parameter_count; ++i) { | 516 for (int i = 0; i < parameter_count; ++i) { |
(...skipping 30 matching lines...) Expand all Loading... |
538 // pointer. | 547 // pointer. |
539 output_offset -= kPointerSize; | 548 output_offset -= kPointerSize; |
540 input_offset -= kPointerSize; | 549 input_offset -= kPointerSize; |
541 if (is_bottommost) { | 550 if (is_bottommost) { |
542 value = input_->GetFrameSlot(input_offset); | 551 value = input_->GetFrameSlot(input_offset); |
543 } else { | 552 } else { |
544 value = output_[frame_index - 1]->GetFp(); | 553 value = output_[frame_index - 1]->GetFp(); |
545 } | 554 } |
546 output_frame->SetFrameSlot(output_offset, value); | 555 output_frame->SetFrameSlot(output_offset, value); |
547 intptr_t fp_value = top_address + output_offset; | 556 intptr_t fp_value = top_address + output_offset; |
548 ASSERT(!is_bottommost || input_->GetRegister(ebp.code()) == fp_value); | 557 ASSERT(!is_bottommost || |
| 558 input_->GetRegister(ebp.code()) + has_alignment_padding_ * kPointerSize |
| 559 == fp_value); |
549 output_frame->SetFp(fp_value); | 560 output_frame->SetFp(fp_value); |
550 if (is_topmost) output_frame->SetRegister(ebp.code(), fp_value); | 561 if (is_topmost) output_frame->SetRegister(ebp.code(), fp_value); |
551 if (FLAG_trace_deopt) { | 562 if (FLAG_trace_deopt) { |
552 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", | 563 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n", |
553 fp_value, output_offset, value); | 564 fp_value, output_offset, value); |
554 } | 565 } |
555 | 566 |
556 // For the bottommost output frame the context can be gotten from the input | 567 // For the bottommost output frame the context can be gotten from the input |
557 // frame. For all subsequent output frames it can be gotten from the function | 568 // frame. For all subsequent output frames it can be gotten from the function |
558 // so long as we don't inline functions that need local contexts. | 569 // 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... |
727 // limit and copy the contents of the activation frame to the input | 738 // limit and copy the contents of the activation frame to the input |
728 // frame description. | 739 // frame description. |
729 __ lea(edx, Operand(ebx, FrameDescription::frame_content_offset())); | 740 __ lea(edx, Operand(ebx, FrameDescription::frame_content_offset())); |
730 Label pop_loop; | 741 Label pop_loop; |
731 __ bind(&pop_loop); | 742 __ bind(&pop_loop); |
732 __ pop(Operand(edx, 0)); | 743 __ pop(Operand(edx, 0)); |
733 __ add(Operand(edx), Immediate(sizeof(uint32_t))); | 744 __ add(Operand(edx), Immediate(sizeof(uint32_t))); |
734 __ cmp(ecx, Operand(esp)); | 745 __ cmp(ecx, Operand(esp)); |
735 __ j(not_equal, &pop_loop); | 746 __ j(not_equal, &pop_loop); |
736 | 747 |
| 748 // If frame was dynamically aligned, pop padding. |
| 749 Label sentinel, sentinel_done; |
| 750 __ pop(Operand(ecx)); |
| 751 __ cmp(ecx, Operand(eax, Deoptimizer::frame_alignment_marker_offset())); |
| 752 __ j(equal, &sentinel); |
| 753 __ push(Operand(ecx)); |
| 754 __ jmp(&sentinel_done); |
| 755 __ bind(&sentinel); |
| 756 __ mov(Operand(eax, Deoptimizer::has_alignment_padding_offset()), |
| 757 Immediate(1)); |
| 758 __ bind(&sentinel_done); |
737 // Compute the output frame in the deoptimizer. | 759 // Compute the output frame in the deoptimizer. |
738 __ push(eax); | 760 __ push(eax); |
739 __ PrepareCallCFunction(1, ebx); | 761 __ PrepareCallCFunction(1, ebx); |
740 __ mov(Operand(esp, 0 * kPointerSize), eax); | 762 __ mov(Operand(esp, 0 * kPointerSize), eax); |
741 { | 763 { |
742 AllowExternalCallThatCantCauseGC scope(masm()); | 764 AllowExternalCallThatCantCauseGC scope(masm()); |
743 __ CallCFunction( | 765 __ CallCFunction( |
744 ExternalReference::compute_output_frames_function(isolate), 1); | 766 ExternalReference::compute_output_frames_function(isolate), 1); |
745 } | 767 } |
746 __ pop(eax); | 768 __ pop(eax); |
747 | 769 |
| 770 if (type() == OSR) { |
| 771 // If alignment padding is added, push the sentinel. |
| 772 Label no_osr_padding; |
| 773 __ cmp(Operand(eax, Deoptimizer::has_alignment_padding_offset()), |
| 774 Immediate(0)); |
| 775 __ j(equal, &no_osr_padding, Label::kNear); |
| 776 __ push(Operand(eax, Deoptimizer::frame_alignment_marker_offset())); |
| 777 __ bind(&no_osr_padding); |
| 778 } |
| 779 |
| 780 |
748 // Replace the current frame with the output frames. | 781 // Replace the current frame with the output frames. |
749 Label outer_push_loop, inner_push_loop; | 782 Label outer_push_loop, inner_push_loop; |
750 // Outer loop state: eax = current FrameDescription**, edx = one past the | 783 // Outer loop state: eax = current FrameDescription**, edx = one past the |
751 // last FrameDescription**. | 784 // last FrameDescription**. |
752 __ mov(edx, Operand(eax, Deoptimizer::output_count_offset())); | 785 __ mov(edx, Operand(eax, Deoptimizer::output_count_offset())); |
753 __ mov(eax, Operand(eax, Deoptimizer::output_offset())); | 786 __ mov(eax, Operand(eax, Deoptimizer::output_offset())); |
754 __ lea(edx, Operand(eax, edx, times_4, 0)); | 787 __ lea(edx, Operand(eax, edx, times_4, 0)); |
755 __ bind(&outer_push_loop); | 788 __ bind(&outer_push_loop); |
756 // Inner loop state: ebx = current FrameDescription*, ecx = loop index. | 789 // Inner loop state: ebx = current FrameDescription*, ecx = loop index. |
757 __ mov(ebx, Operand(eax, 0)); | 790 __ mov(ebx, Operand(eax, 0)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 } | 841 } |
809 __ bind(&done); | 842 __ bind(&done); |
810 } | 843 } |
811 | 844 |
812 #undef __ | 845 #undef __ |
813 | 846 |
814 | 847 |
815 } } // namespace v8::internal | 848 } } // namespace v8::internal |
816 | 849 |
817 #endif // V8_TARGET_ARCH_IA32 | 850 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |