610 }
611
612 #ifdef ASSERT
613 if (VerifyStackAtCalls) {
614 st->print("\n\t");
615 st->print("# stack alignment check");
616 }
617 #endif
618 st->cr();
619 }
620 #endif
621
622
623 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
624 Compile* C = ra_->C;
625 MacroAssembler _masm(&cbuf);
626
627 int framesize = C->output()->frame_size_in_bytes();
628 int bangsize = C->output()->bang_size_in_bytes();
629
630 __ verified_entry(framesize, C->output()->need_stack_bang(bangsize)?bangsize:0, C->in_24_bit_fp_mode(), C->stub_function() != NULL);
631
632 C->output()->set_frame_complete(cbuf.insts_size());
633
634 if (C->has_mach_constant_base_node()) {
635 // NOTE: We set the table base offset here because users might be
636 // emitted before MachConstantBaseNode.
637 ConstantTable& constant_table = C->output()->constant_table();
638 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
639 }
640 }
641
642 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
643 return MachNode::size(ra_); // too many variables; just compute it the hard way
644 }
645
646 int MachPrologNode::reloc() const {
647 return 0; // a large enough number
648 }
649
650 //=============================================================================
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 //=============================================================================
13677 ins_encode();
13678 ins_pipe( empty );
13679 %}
13680
13681
13682 // Rethrow exception:
13683 // The exception oop will come in the first argument position.
13684 // Then JUMP (not call) to the rethrow stub code.
13685 instruct RethrowException()
13686 %{
13687 match(Rethrow);
13688
13689 // use the following format syntax
13690 format %{ "JMP rethrow_stub" %}
13691 ins_encode(enc_rethrow);
13692 ins_pipe( pipe_jmp );
13693 %}
13694
13695 // inlined locking and unlocking
13696
13697 instruct cmpFastLockRTM(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eDXRegI scr, rRegI cx1, rRegI cx2) %{
13698 predicate(Compile::current()->use_rtm());
13699 match(Set cr (FastLock object box));
13700 effect(TEMP tmp, TEMP scr, TEMP cx1, TEMP cx2, USE_KILL box);
13701 ins_cost(300);
13702 format %{ "FASTLOCK $object,$box\t! kills $box,$tmp,$scr,$cx1,$cx2" %}
13703 ins_encode %{
13704 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register,
13705 $scr$$Register, $cx1$$Register, $cx2$$Register,
13706 _counters, _rtm_counters, _stack_rtm_counters,
13707 ((Method*)(ra_->C->method()->constant_encoding()))->method_data(),
13708 true, ra_->C->profile_rtm());
13709 %}
13710 ins_pipe(pipe_slow);
13711 %}
13712
13713 instruct cmpFastLock(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eRegP scr) %{
13714 predicate(!Compile::current()->use_rtm());
13715 match(Set cr (FastLock object box));
13716 effect(TEMP tmp, TEMP scr, USE_KILL box);
13717 ins_cost(300);
13718 format %{ "FASTLOCK $object,$box\t! kills $box,$tmp,$scr" %}
13719 ins_encode %{
13720 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register,
13721 $scr$$Register, noreg, noreg, _counters, NULL, NULL, NULL, false, false);
13722 %}
13723 ins_pipe(pipe_slow);
13724 %}
13725
13726 instruct cmpFastUnlock(eFlagsReg cr, eRegP object, eAXRegP box, eRegP tmp ) %{
13727 match(Set cr (FastUnlock object box));
13728 effect(TEMP tmp, USE_KILL box);
13729 ins_cost(300);
13730 format %{ "FASTUNLOCK $object,$box\t! kills $box,$tmp" %}
13731 ins_encode %{
13732 __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register, ra_->C->use_rtm());
13733 %}
13734 ins_pipe(pipe_slow);
13735 %}
13736
13737
13738
13739 // ============================================================================
13740 // Safepoint Instruction
13741 instruct safePoint_poll_tls(eFlagsReg cr, eRegP_no_EBP poll) %{
|
610 }
611
612 #ifdef ASSERT
613 if (VerifyStackAtCalls) {
614 st->print("\n\t");
615 st->print("# stack alignment check");
616 }
617 #endif
618 st->cr();
619 }
620 #endif
621
622
623 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
624 Compile* C = ra_->C;
625 MacroAssembler _masm(&cbuf);
626
627 int framesize = C->output()->frame_size_in_bytes();
628 int bangsize = C->output()->bang_size_in_bytes();
629
630 int max_monitors = C->method() != NULL ? C->max_monitors() : 0;
631 __ verified_entry(framesize, C->output()->need_stack_bang(bangsize)?bangsize:0, C->in_24_bit_fp_mode(), C->stub_function() != NULL, max_monitors);
632
633 C->output()->set_frame_complete(cbuf.insts_size());
634
635 if (C->has_mach_constant_base_node()) {
636 // NOTE: We set the table base offset here because users might be
637 // emitted before MachConstantBaseNode.
638 ConstantTable& constant_table = C->output()->constant_table();
639 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
640 }
641 }
642
643 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
644 return MachNode::size(ra_); // too many variables; just compute it the hard way
645 }
646
647 int MachPrologNode::reloc() const {
648 return 0; // a large enough number
649 }
650
651 //=============================================================================
705 emit_d32(cbuf, framesize);
706 } else if (framesize) {
707 emit_opcode(cbuf, 0x83); // add SP, #framesize
708 emit_rm(cbuf, 0x3, 0x00, ESP_enc);
709 emit_d8(cbuf, framesize);
710 }
711
712 emit_opcode(cbuf, 0x58 | EBP_enc);
713
714 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
715 __ reserved_stack_check();
716 }
717
718 if (do_polling() && C->is_method_compilation()) {
719 Register thread = as_Register(EBX_enc);
720 MacroAssembler masm(&cbuf);
721 __ get_thread(thread);
722 Label dummy_label;
723 Label* code_stub = &dummy_label;
724 if (!C->output()->in_scratch_emit_size()) {
725 C2SafepointPollStub* stub = new (C->comp_arena()) C2SafepointPollStub(__ offset());
726 C->output()->add_stub(stub);
727 code_stub = &stub->entry();
728 }
729 __ relocate(relocInfo::poll_return_type);
730 __ safepoint_poll(*code_stub, thread, true /* at_return */, true /* in_nmethod */);
731 }
732 }
733
734 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
735 return MachNode::size(ra_); // too many variables; just compute it
736 // the hard way
737 }
738
739 int MachEpilogNode::reloc() const {
740 return 0; // a large enough number
741 }
742
743 const Pipeline * MachEpilogNode::pipeline() const {
744 return MachNode::pipeline_class();
745 }
746
747 //=============================================================================
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(!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, NULL, 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 match(Set cr (FastUnlock object box));
13733 effect(TEMP tmp, USE_KILL box);
13734 ins_cost(300);
13735 format %{ "FASTUNLOCK $object,$box\t! kills $box,$tmp" %}
13736 ins_encode %{
13737 __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register, ra_->C->use_rtm());
13738 %}
13739 ins_pipe(pipe_slow);
13740 %}
13741
13742
13743
13744 // ============================================================================
13745 // Safepoint Instruction
13746 instruct safePoint_poll_tls(eFlagsReg cr, eRegP_no_EBP poll) %{
|