Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/templateInterpreter_x86_32.cpp @ 1330:4a9cc99938e3
Merge
author | acorn |
---|---|
date | Fri, 26 Mar 2010 11:10:26 -0400 |
parents | 3cf667df43ef |
children | 2338d41fbd81 |
comparison
equal
deleted
inserted
replaced
1329:84043c7507b9 | 1330:4a9cc99938e3 |
---|---|
1548 // Exceptions | 1548 // Exceptions |
1549 | 1549 |
1550 void TemplateInterpreterGenerator::generate_throw_exception() { | 1550 void TemplateInterpreterGenerator::generate_throw_exception() { |
1551 // Entry point in previous activation (i.e., if the caller was interpreted) | 1551 // Entry point in previous activation (i.e., if the caller was interpreted) |
1552 Interpreter::_rethrow_exception_entry = __ pc(); | 1552 Interpreter::_rethrow_exception_entry = __ pc(); |
1553 const Register thread = rcx; | |
1553 | 1554 |
1554 // Restore sp to interpreter_frame_last_sp even though we are going | 1555 // Restore sp to interpreter_frame_last_sp even though we are going |
1555 // to empty the expression stack for the exception processing. | 1556 // to empty the expression stack for the exception processing. |
1556 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); | 1557 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); |
1557 // rax,: exception | 1558 // rax,: exception |
1596 __ empty_expression_stack(); | 1597 __ empty_expression_stack(); |
1597 __ empty_FPU_stack(); | 1598 __ empty_FPU_stack(); |
1598 // Set the popframe_processing bit in pending_popframe_condition indicating that we are | 1599 // Set the popframe_processing bit in pending_popframe_condition indicating that we are |
1599 // currently handling popframe, so that call_VMs that may happen later do not trigger new | 1600 // currently handling popframe, so that call_VMs that may happen later do not trigger new |
1600 // popframe handling cycles. | 1601 // popframe handling cycles. |
1601 __ get_thread(rcx); | 1602 __ get_thread(thread); |
1602 __ movl(rdx, Address(rcx, JavaThread::popframe_condition_offset())); | 1603 __ movl(rdx, Address(thread, JavaThread::popframe_condition_offset())); |
1603 __ orl(rdx, JavaThread::popframe_processing_bit); | 1604 __ orl(rdx, JavaThread::popframe_processing_bit); |
1604 __ movl(Address(rcx, JavaThread::popframe_condition_offset()), rdx); | 1605 __ movl(Address(thread, JavaThread::popframe_condition_offset()), rdx); |
1605 | 1606 |
1606 { | 1607 { |
1607 // Check to see whether we are returning to a deoptimized frame. | 1608 // Check to see whether we are returning to a deoptimized frame. |
1608 // (The PopFrame call ensures that the caller of the popped frame is | 1609 // (The PopFrame call ensures that the caller of the popped frame is |
1609 // either interpreted or compiled and deoptimizes it if compiled.) | 1610 // either interpreted or compiled and deoptimizes it if compiled.) |
1627 __ shlptr(rax, Interpreter::logStackElementSize()); | 1628 __ shlptr(rax, Interpreter::logStackElementSize()); |
1628 __ restore_locals(); | 1629 __ restore_locals(); |
1629 __ subptr(rdi, rax); | 1630 __ subptr(rdi, rax); |
1630 __ addptr(rdi, wordSize); | 1631 __ addptr(rdi, wordSize); |
1631 // Save these arguments | 1632 // Save these arguments |
1632 __ get_thread(rcx); | 1633 __ get_thread(thread); |
1633 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), rcx, rax, rdi); | 1634 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), thread, rax, rdi); |
1634 | 1635 |
1635 __ remove_activation(vtos, rdx, | 1636 __ remove_activation(vtos, rdx, |
1636 /* throw_monitor_exception */ false, | 1637 /* throw_monitor_exception */ false, |
1637 /* install_monitor_exception */ false, | 1638 /* install_monitor_exception */ false, |
1638 /* notify_jvmdi */ false); | 1639 /* notify_jvmdi */ false); |
1639 | 1640 |
1640 // Inform deoptimization that it is responsible for restoring these arguments | 1641 // Inform deoptimization that it is responsible for restoring these arguments |
1641 __ get_thread(rcx); | 1642 __ get_thread(thread); |
1642 __ movl(Address(rcx, JavaThread::popframe_condition_offset()), JavaThread::popframe_force_deopt_reexecution_bit); | 1643 __ movl(Address(thread, JavaThread::popframe_condition_offset()), JavaThread::popframe_force_deopt_reexecution_bit); |
1643 | 1644 |
1644 // Continue in deoptimization handler | 1645 // Continue in deoptimization handler |
1645 __ jmp(rdx); | 1646 __ jmp(rdx); |
1646 | 1647 |
1647 __ bind(caller_not_deoptimized); | 1648 __ bind(caller_not_deoptimized); |
1663 // maintain this kind of invariant all the time we call a small | 1664 // maintain this kind of invariant all the time we call a small |
1664 // fixup routine to move the mutated arguments onto the top of our | 1665 // fixup routine to move the mutated arguments onto the top of our |
1665 // expression stack if necessary. | 1666 // expression stack if necessary. |
1666 __ mov(rax, rsp); | 1667 __ mov(rax, rsp); |
1667 __ movptr(rbx, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); | 1668 __ movptr(rbx, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
1668 __ get_thread(rcx); | 1669 __ get_thread(thread); |
1669 // PC must point into interpreter here | 1670 // PC must point into interpreter here |
1670 __ set_last_Java_frame(rcx, noreg, rbp, __ pc()); | 1671 __ set_last_Java_frame(thread, noreg, rbp, __ pc()); |
1671 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), rcx, rax, rbx); | 1672 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), thread, rax, rbx); |
1672 __ get_thread(rcx); | 1673 __ get_thread(thread); |
1673 __ reset_last_Java_frame(rcx, true, true); | 1674 __ reset_last_Java_frame(thread, true, true); |
1674 // Restore the last_sp and null it out | 1675 // Restore the last_sp and null it out |
1675 __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); | 1676 __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize)); |
1676 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); | 1677 __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD); |
1677 | 1678 |
1678 __ restore_bcp(); | 1679 __ restore_bcp(); |
1682 if (ProfileInterpreter) { | 1683 if (ProfileInterpreter) { |
1683 __ set_method_data_pointer_for_bcp(); | 1684 __ set_method_data_pointer_for_bcp(); |
1684 } | 1685 } |
1685 | 1686 |
1686 // Clear the popframe condition flag | 1687 // Clear the popframe condition flag |
1687 __ get_thread(rcx); | 1688 __ get_thread(thread); |
1688 __ movl(Address(rcx, JavaThread::popframe_condition_offset()), JavaThread::popframe_inactive); | 1689 __ movl(Address(thread, JavaThread::popframe_condition_offset()), JavaThread::popframe_inactive); |
1689 | 1690 |
1690 __ dispatch_next(vtos); | 1691 __ dispatch_next(vtos); |
1691 // end of PopFrame support | 1692 // end of PopFrame support |
1692 | 1693 |
1693 Interpreter::_remove_activation_entry = __ pc(); | 1694 Interpreter::_remove_activation_entry = __ pc(); |
1694 | 1695 |
1695 // preserve exception over this code sequence | 1696 // preserve exception over this code sequence |
1696 __ pop_ptr(rax); | 1697 __ pop_ptr(rax); |
1697 __ get_thread(rcx); | 1698 __ get_thread(thread); |
1698 __ movptr(Address(rcx, JavaThread::vm_result_offset()), rax); | 1699 __ movptr(Address(thread, JavaThread::vm_result_offset()), rax); |
1699 // remove the activation (without doing throws on illegalMonitorExceptions) | 1700 // remove the activation (without doing throws on illegalMonitorExceptions) |
1700 __ remove_activation(vtos, rdx, false, true, false); | 1701 __ remove_activation(vtos, rdx, false, true, false); |
1701 // restore exception | 1702 // restore exception |
1702 __ get_thread(rcx); | 1703 __ get_thread(thread); |
1703 __ movptr(rax, Address(rcx, JavaThread::vm_result_offset())); | 1704 __ movptr(rax, Address(thread, JavaThread::vm_result_offset())); |
1704 __ movptr(Address(rcx, JavaThread::vm_result_offset()), NULL_WORD); | 1705 __ movptr(Address(thread, JavaThread::vm_result_offset()), NULL_WORD); |
1705 __ verify_oop(rax); | 1706 __ verify_oop(rax); |
1706 | 1707 |
1707 // Inbetween activations - previous activation type unknown yet | 1708 // Inbetween activations - previous activation type unknown yet |
1708 // compute continuation point - the continuation point expects | 1709 // compute continuation point - the continuation point expects |
1709 // the following registers set up: | 1710 // the following registers set up: |
1710 // | 1711 // |
1711 // rax,: exception | 1712 // rax: exception |
1712 // rdx: return address/pc that threw exception | 1713 // rdx: return address/pc that threw exception |
1713 // rsp: expression stack of caller | 1714 // rsp: expression stack of caller |
1714 // rbp,: rbp, of caller | 1715 // rbp: rbp, of caller |
1715 __ push(rax); // save exception | 1716 __ push(rax); // save exception |
1716 __ push(rdx); // save return address | 1717 __ push(rdx); // save return address |
1717 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), rdx); | 1718 __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), thread, rdx); |
1718 __ mov(rbx, rax); // save exception handler | 1719 __ mov(rbx, rax); // save exception handler |
1719 __ pop(rdx); // restore return address | 1720 __ pop(rdx); // restore return address |
1720 __ pop(rax); // restore exception | 1721 __ pop(rax); // restore exception |
1721 // Note that an "issuing PC" is actually the next PC after the call | 1722 // Note that an "issuing PC" is actually the next PC after the call |
1722 __ jmp(rbx); // jump to exception handler of caller | 1723 __ jmp(rbx); // jump to exception handler of caller |
1726 // | 1727 // |
1727 // JVMTI ForceEarlyReturn support | 1728 // JVMTI ForceEarlyReturn support |
1728 // | 1729 // |
1729 address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) { | 1730 address TemplateInterpreterGenerator::generate_earlyret_entry_for(TosState state) { |
1730 address entry = __ pc(); | 1731 address entry = __ pc(); |
1732 const Register thread = rcx; | |
1731 | 1733 |
1732 __ restore_bcp(); | 1734 __ restore_bcp(); |
1733 __ restore_locals(); | 1735 __ restore_locals(); |
1734 __ empty_expression_stack(); | 1736 __ empty_expression_stack(); |
1735 __ empty_FPU_stack(); | 1737 __ empty_FPU_stack(); |
1736 __ load_earlyret_value(state); | 1738 __ load_earlyret_value(state); |
1737 | 1739 |
1738 __ get_thread(rcx); | 1740 __ get_thread(thread); |
1739 __ movptr(rcx, Address(rcx, JavaThread::jvmti_thread_state_offset())); | 1741 __ movptr(rcx, Address(thread, JavaThread::jvmti_thread_state_offset())); |
1740 const Address cond_addr(rcx, JvmtiThreadState::earlyret_state_offset()); | 1742 const Address cond_addr(rcx, JvmtiThreadState::earlyret_state_offset()); |
1741 | 1743 |
1742 // Clear the earlyret state | 1744 // Clear the earlyret state |
1743 __ movl(cond_addr, JvmtiThreadState::earlyret_inactive); | 1745 __ movl(cond_addr, JvmtiThreadState::earlyret_inactive); |
1744 | 1746 |