704 emit_d32(cbuf, framesize);
705 } else if (framesize) {
706 emit_opcode(cbuf, 0x83); // add SP, #framesize
707 emit_rm(cbuf, 0x3, 0x00, ESP_enc);
708 emit_d8(cbuf, framesize);
709 }
710
711 emit_opcode(cbuf, 0x58 | EBP_enc);
712
713 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
714 __ reserved_stack_check();
715 }
716
717 if (do_polling() && C->is_method_compilation()) {
718 Register thread = as_Register(EBX_enc);
719 MacroAssembler masm(&cbuf);
720 __ get_thread(thread);
721 Label dummy_label;
722 Label* code_stub = &dummy_label;
723 if (!C->output()->in_scratch_emit_size()) {
724 code_stub = &C->output()->safepoint_poll_table()->add_safepoint(__ offset());
725 }
726 __ relocate(relocInfo::poll_return_type);
727 __ safepoint_poll(*code_stub, thread, true /* at_return */, true /* in_nmethod */);
728 }
729 }
730
731 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
732 return MachNode::size(ra_); // too many variables; just compute it
733 // the hard way
734 }
735
736 int MachEpilogNode::reloc() const {
737 return 0; // a large enough number
738 }
739
740 const Pipeline * MachEpilogNode::pipeline() const {
741 return MachNode::pipeline_class();
742 }
743
744 //=============================================================================
13678 ins_encode();
13679 ins_pipe( empty );
13680 %}
13681
13682
13683 // Rethrow exception:
13684 // The exception oop will come in the first argument position.
13685 // Then JUMP (not call) to the rethrow stub code.
13686 instruct RethrowException()
13687 %{
13688 match(Rethrow);
13689
13690 // use the following format syntax
13691 format %{ "JMP rethrow_stub" %}
13692 ins_encode(enc_rethrow);
13693 ins_pipe( pipe_jmp );
13694 %}
13695
13696 // inlined locking and unlocking
13697
13698 instruct cmpFastLockRTM(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eDXRegI scr, rRegI cx1, rRegI cx2) %{
13699 predicate(Compile::current()->use_rtm());
13700 match(Set cr (FastLock object box));
13701 effect(TEMP tmp, TEMP scr, TEMP cx1, TEMP cx2, USE_KILL box);
13702 ins_cost(300);
13703 format %{ "FASTLOCK $object,$box\t! kills $box,$tmp,$scr,$cx1,$cx2" %}
13704 ins_encode %{
13705 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register,
13706 $scr$$Register, $cx1$$Register, $cx2$$Register,
13707 _counters, _rtm_counters, _stack_rtm_counters,
13708 ((Method*)(ra_->C->method()->constant_encoding()))->method_data(),
13709 true, ra_->C->profile_rtm());
13710 %}
13711 ins_pipe(pipe_slow);
13712 %}
13713
13714 instruct cmpFastLock(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eRegP scr) %{
13715 predicate(!Compile::current()->use_rtm());
13716 match(Set cr (FastLock object box));
13717 effect(TEMP tmp, TEMP scr, USE_KILL box);
13718 ins_cost(300);
13719 format %{ "FASTLOCK $object,$box\t! kills $box,$tmp,$scr" %}
13720 ins_encode %{
13721 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register,
13722 $scr$$Register, noreg, noreg, _counters, NULL, NULL, NULL, false, false);
13723 %}
13724 ins_pipe(pipe_slow);
13725 %}
13726
13727 instruct cmpFastUnlock(eFlagsReg cr, eRegP object, eAXRegP box, eRegP tmp ) %{
13728 match(Set cr (FastUnlock object box));
13729 effect(TEMP tmp, USE_KILL box);
13730 ins_cost(300);
13731 format %{ "FASTUNLOCK $object,$box\t! kills $box,$tmp" %}
13732 ins_encode %{
13733 __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register, ra_->C->use_rtm());
13734 %}
13735 ins_pipe(pipe_slow);
13736 %}
13737
13738
13739
13740 // ============================================================================
13741 // Safepoint Instruction
13742 instruct safePoint_poll_tls(eFlagsReg cr, eRegP_no_EBP poll) %{
13743 match(SafePoint poll);
13744 effect(KILL cr, USE poll);
13745
13746 format %{ "TSTL #EAX,[$poll]\t! Safepoint: poll for GC" %}
13747 ins_cost(125);
13748 // EBP would need size(3)
13749 size(2); /* setting an explicit size will cause debug builds to assert if size is incorrect */
13750 ins_encode %{
13751 __ relocate(relocInfo::poll_type);
13752 address pre_pc = __ pc();
13753 __ testl(rax, Address($poll$$Register, 0));
13754 address post_pc = __ pc();
13755 guarantee(pre_pc[0] == 0x85, "must emit test-ax [reg]");
13756 %}
13757 ins_pipe(ialu_reg_mem);
13758 %}
|
704 emit_d32(cbuf, framesize);
705 } else if (framesize) {
706 emit_opcode(cbuf, 0x83); // add SP, #framesize
707 emit_rm(cbuf, 0x3, 0x00, ESP_enc);
708 emit_d8(cbuf, framesize);
709 }
710
711 emit_opcode(cbuf, 0x58 | EBP_enc);
712
713 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
714 __ reserved_stack_check();
715 }
716
717 if (do_polling() && C->is_method_compilation()) {
718 Register thread = as_Register(EBX_enc);
719 MacroAssembler masm(&cbuf);
720 __ get_thread(thread);
721 Label dummy_label;
722 Label* code_stub = &dummy_label;
723 if (!C->output()->in_scratch_emit_size()) {
724 C2SafepointPollStub* stub = new (C->comp_arena()) C2SafepointPollStub(__ offset());
725 C->output()->add_stub(stub);
726 code_stub = &stub->entry();
727 }
728 __ relocate(relocInfo::poll_return_type);
729 __ safepoint_poll(*code_stub, thread, true /* at_return */, true /* in_nmethod */);
730 }
731 }
732
733 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
734 return MachNode::size(ra_); // too many variables; just compute it
735 // the hard way
736 }
737
738 int MachEpilogNode::reloc() const {
739 return 0; // a large enough number
740 }
741
742 const Pipeline * MachEpilogNode::pipeline() const {
743 return MachNode::pipeline_class();
744 }
745
746 //=============================================================================
13680 ins_encode();
13681 ins_pipe( empty );
13682 %}
13683
13684
13685 // Rethrow exception:
13686 // The exception oop will come in the first argument position.
13687 // Then JUMP (not call) to the rethrow stub code.
13688 instruct RethrowException()
13689 %{
13690 match(Rethrow);
13691
13692 // use the following format syntax
13693 format %{ "JMP rethrow_stub" %}
13694 ins_encode(enc_rethrow);
13695 ins_pipe( pipe_jmp );
13696 %}
13697
13698 // inlined locking and unlocking
13699
13700 instruct cmpFastLockRTM(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eDXRegI scr, rRegI cx1, rRegI cx2, eRegP thread) %{
13701 predicate(Compile::current()->use_rtm());
13702 match(Set cr (FastLock object box));
13703 effect(TEMP tmp, TEMP scr, TEMP cx1, TEMP cx2, USE_KILL box, TEMP thread);
13704 ins_cost(300);
13705 format %{ "FASTLOCK $object,$box\t! kills $box,$tmp,$scr,$cx1,$cx2" %}
13706 ins_encode %{
13707 __ get_thread($thread$$Register);
13708 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register,
13709 $scr$$Register, $cx1$$Register, $cx2$$Register, $thread$$Register,
13710 _counters, _rtm_counters, _stack_rtm_counters,
13711 ((Method*)(ra_->C->method()->constant_encoding()))->method_data(),
13712 true, ra_->C->profile_rtm());
13713 %}
13714 ins_pipe(pipe_slow);
13715 %}
13716
13717 instruct cmpFastLock(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eRegP scr, eRegP thread) %{
13718 predicate(LockingMode != LM_LIGHTWEIGHT && !Compile::current()->use_rtm());
13719 match(Set cr (FastLock object box));
13720 effect(TEMP tmp, TEMP scr, USE_KILL box, TEMP thread);
13721 ins_cost(300);
13722 format %{ "FASTLOCK $object,$box\t! kills $box,$tmp,$scr" %}
13723 ins_encode %{
13724 __ get_thread($thread$$Register);
13725 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register,
13726 $scr$$Register, noreg, noreg, $thread$$Register, _counters, NULL, NULL, NULL, false, false);
13727 %}
13728 ins_pipe(pipe_slow);
13729 %}
13730
13731 instruct cmpFastUnlock(eFlagsReg cr, eRegP object, eAXRegP box, eRegP tmp ) %{
13732 predicate(LockingMode != LM_LIGHTWEIGHT);
13733 match(Set cr (FastUnlock object box));
13734 effect(TEMP tmp, USE_KILL box);
13735 ins_cost(300);
13736 format %{ "FASTUNLOCK $object,$box\t! kills $box,$tmp" %}
13737 ins_encode %{
13738 __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register, ra_->C->use_rtm());
13739 %}
13740 ins_pipe(pipe_slow);
13741 %}
13742
13743 instruct cmpFastLockLightweight(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI eax_reg, eRegP tmp, eRegP thread) %{
13744 predicate(LockingMode == LM_LIGHTWEIGHT);
13745 match(Set cr (FastLock object box));
13746 effect(TEMP eax_reg, TEMP tmp, USE_KILL box, TEMP thread);
13747 ins_cost(300);
13748 format %{ "FASTLOCK $object,$box\t! kills $box,$eax_reg,$tmp" %}
13749 ins_encode %{
13750 __ get_thread($thread$$Register);
13751 __ fast_lock_lightweight($object$$Register, $box$$Register, $eax_reg$$Register, $tmp$$Register, $thread$$Register);
13752 %}
13753 ins_pipe(pipe_slow);
13754 %}
13755
13756 instruct cmpFastUnlockLightweight(eFlagsReg cr, eRegP object, eAXRegP eax_reg, eRegP tmp, eRegP thread) %{
13757 predicate(LockingMode == LM_LIGHTWEIGHT);
13758 match(Set cr (FastUnlock object eax_reg));
13759 effect(TEMP tmp, USE_KILL eax_reg, TEMP thread);
13760 ins_cost(300);
13761 format %{ "FASTUNLOCK $object,$eax_reg\t! kills $eax_reg,$tmp" %}
13762 ins_encode %{
13763 __ get_thread($thread$$Register);
13764 __ fast_unlock_lightweight($object$$Register, $eax_reg$$Register, $tmp$$Register, $thread$$Register);
13765 %}
13766 ins_pipe(pipe_slow);
13767 %}
13768
13769 // ============================================================================
13770 // Safepoint Instruction
13771 instruct safePoint_poll_tls(eFlagsReg cr, eRegP_no_EBP poll) %{
13772 match(SafePoint poll);
13773 effect(KILL cr, USE poll);
13774
13775 format %{ "TSTL #EAX,[$poll]\t! Safepoint: poll for GC" %}
13776 ins_cost(125);
13777 // EBP would need size(3)
13778 size(2); /* setting an explicit size will cause debug builds to assert if size is incorrect */
13779 ins_encode %{
13780 __ relocate(relocInfo::poll_type);
13781 address pre_pc = __ pc();
13782 __ testl(rax, Address($poll$$Register, 0));
13783 address post_pc = __ pc();
13784 guarantee(pre_pc[0] == 0x85, "must emit test-ax [reg]");
13785 %}
13786 ins_pipe(ialu_reg_mem);
13787 %}
|