< prev index next >

src/hotspot/share/c1/c1_LIRAssembler.cpp

Print this page

 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "asm/assembler.inline.hpp"
 27 #include "c1/c1_Compilation.hpp"
 28 #include "c1/c1_Instruction.hpp"
 29 #include "c1/c1_InstructionPrinter.hpp"
 30 #include "c1/c1_LIRAssembler.hpp"
 31 #include "c1/c1_MacroAssembler.hpp"
 32 #include "c1/c1_ValueStack.hpp"

 33 #include "ci/ciInstance.hpp"
 34 #include "compiler/oopMap.hpp"
 35 #include "gc/shared/barrierSet.hpp"
 36 #include "runtime/os.hpp"

 37 #include "runtime/vm_version.hpp"
 38 
 39 void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
 40   // We must have enough patching space so that call can be inserted.
 41   // We cannot use fat nops here, since the concurrent code rewrite may transiently
 42   // create the illegal instruction sequence.
 43   while ((intx) _masm->pc() - (intx) patch->pc_start() < NativeGeneralJump::instruction_size) {
 44     _masm->nop();
 45   }
 46   patch->install(_masm, patch_code, obj, info);
 47   append_code_stub(patch);
 48 
 49 #ifdef ASSERT
 50   Bytecodes::Code code = info->scope()->method()->java_code_at_bci(info->stack()->bci());
 51   if (patch->id() == PatchingStub::access_field_id) {
 52     switch (code) {
 53       case Bytecodes::_putstatic:
 54       case Bytecodes::_getstatic:
 55       case Bytecodes::_putfield:
 56       case Bytecodes::_getfield:

 57         break;
 58       default:
 59         ShouldNotReachHere();
 60     }
 61   } else if (patch->id() == PatchingStub::load_klass_id) {
 62     switch (code) {
 63       case Bytecodes::_new:

 64       case Bytecodes::_anewarray:
 65       case Bytecodes::_multianewarray:
 66       case Bytecodes::_instanceof:
 67       case Bytecodes::_checkcast:
 68         break;
 69       default:
 70         ShouldNotReachHere();
 71     }
 72   } else if (patch->id() == PatchingStub::load_mirror_id) {
 73     switch (code) {
 74       case Bytecodes::_putstatic:
 75       case Bytecodes::_getstatic:
 76       case Bytecodes::_ldc:
 77       case Bytecodes::_ldc_w:
 78         break;
 79       default:
 80         ShouldNotReachHere();
 81     }
 82   } else if (patch->id() == PatchingStub::load_appendix_id) {
 83     Bytecodes::Code bc_raw = info->scope()->method()->raw_code_at_bci(info->stack()->bci());

100 //---------------------------------------------------------------
101 
102 
103 LIR_Assembler::LIR_Assembler(Compilation* c):
104    _masm(c->masm())
105  , _bs(BarrierSet::barrier_set())
106  , _compilation(c)
107  , _frame_map(c->frame_map())
108  , _current_block(NULL)
109  , _pending_non_safepoint(NULL)
110  , _pending_non_safepoint_offset(0)
111 {
112   _slow_case_stubs = new CodeStubList();
113 }
114 
115 
116 LIR_Assembler::~LIR_Assembler() {
117   // The unwind handler label may be unnbound if this destructor is invoked because of a bail-out.
118   // Reset it here to avoid an assertion.
119   _unwind_handler_entry.reset();

120 }
121 
122 
123 void LIR_Assembler::check_codespace() {
124   CodeSection* cs = _masm->code_section();
125   if (cs->remaining() < (int)(NOT_LP64(1*K)LP64_ONLY(2*K))) {
126     BAILOUT("CodeBuffer overflow");
127   }
128 }
129 
130 
131 void LIR_Assembler::append_code_stub(CodeStub* stub) {
132   _slow_case_stubs->append(stub);
133 }
134 
135 void LIR_Assembler::emit_stubs(CodeStubList* stub_list) {
136   for (int m = 0; m < stub_list->length(); m++) {
137     CodeStub* s = stub_list->at(m);
138 
139     check_codespace();

310     }
311 #endif /* PRODUCT */
312   }
313 }
314 
315 #ifdef ASSERT
316 void LIR_Assembler::check_no_unbound_labels() {
317   CHECK_BAILOUT();
318 
319   for (int i = 0; i < _branch_target_blocks.length() - 1; i++) {
320     if (!_branch_target_blocks.at(i)->label()->is_bound()) {
321       tty->print_cr("label of block B%d is not bound", _branch_target_blocks.at(i)->block_id());
322       assert(false, "unbound label");
323     }
324   }
325 }
326 #endif
327 
328 //----------------------------------debug info--------------------------------
329 
330 
331 void LIR_Assembler::add_debug_info_for_branch(CodeEmitInfo* info) {
332   int pc_offset = code_offset();
333   flush_debug_info(pc_offset);
334   info->record_debug_info(compilation()->debug_info_recorder(), pc_offset);
335   if (info->exception_handlers() != NULL) {
336     compilation()->add_exception_handlers_for_pco(pc_offset, info->exception_handlers());
337   }
338 }
339 
340 
341 void LIR_Assembler::add_call_info(int pc_offset, CodeEmitInfo* cinfo) {
342   flush_debug_info(pc_offset);
343   cinfo->record_debug_info(compilation()->debug_info_recorder(), pc_offset);
344   if (cinfo->exception_handlers() != NULL) {
345     compilation()->add_exception_handlers_for_pco(pc_offset, cinfo->exception_handlers());
346   }
347 }
348 
349 static ValueStack* debug_info(Instruction* ins) {
350   StateSplit* ss = ins->as_StateSplit();
351   if (ss != NULL) return ss->state();
352   return ins->state_before();
353 }
354 
355 void LIR_Assembler::process_debug_info(LIR_Op* op) {
356   Instruction* src = op->source();
357   if (src == NULL)  return;
358   int pc_offset = code_offset();
359   if (_pending_non_safepoint == src) {
360     _pending_non_safepoint_offset = pc_offset;
361     return;
362   }
363   ValueStack* vstack = debug_info(src);

463   case lir_dynamic_call:
464     call(op, relocInfo::static_call_type);
465     break;
466   case lir_optvirtual_call:
467     call(op, relocInfo::opt_virtual_call_type);
468     break;
469   case lir_icvirtual_call:
470     ic_call(op);
471     break;
472   default:
473     fatal("unexpected op code: %s", op->name());
474     break;
475   }
476 
477   // JSR 292
478   // Record if this method has MethodHandle invokes.
479   if (op->is_method_handle_invoke()) {
480     compilation()->set_has_method_handle_invokes(true);
481   }
482 






483 #if defined(IA32) && defined(COMPILER2)
484   // C2 leave fpu stack dirty clean it
485   if (UseSSE < 2 && !CompilerConfig::is_c1_only_no_jvmci()) {
486     int i;
487     for ( i = 1; i <= 7 ; i++ ) {
488       ffree(i);
489     }
490     if (!op->result_opr()->is_float_kind()) {
491       ffree(0);
492     }
493   }
494 #endif // IA32 && COMPILER2
495 }
496 
497 
498 void LIR_Assembler::emit_opLabel(LIR_OpLabel* op) {
499   _masm->bind (*(op->label()));
500 }
501 
502 

569       } else {
570         Unimplemented();
571       }
572       break;
573     }
574 
575     case lir_monaddr:
576       monitor_address(op->in_opr()->as_constant_ptr()->as_jint(), op->result_opr());
577       break;
578 
579     case lir_unwind:
580       unwind_op(op->in_opr());
581       break;
582 
583     default:
584       Unimplemented();
585       break;
586   }
587 }
588 







































































































































589 
590 void LIR_Assembler::emit_op0(LIR_Op0* op) {
591   switch (op->code()) {
592     case lir_nop:
593       assert(op->info() == NULL, "not supported");
594       _masm->nop();
595       break;
596 
597     case lir_label:
598       Unimplemented();
599       break;
600 
601     case lir_std_entry:
602       // init offsets
603       offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
604       _masm->align(CodeEntryAlignment);
605       if (needs_icache(compilation()->method())) {
606         check_icache();
607       }
608       offsets()->set_value(CodeOffsets::Verified_Entry, _masm->offset());
609       _masm->verified_entry();
610       if (needs_clinit_barrier_on_entry(compilation()->method())) {
611         clinit_barrier(compilation()->method());
612       }
613       build_frame();
614       offsets()->set_value(CodeOffsets::Frame_Complete, _masm->offset());
615       break;
616 
617     case lir_osr_entry:
618       offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
619       osr_entry();
620       break;
621 
622 #ifdef IA32
623     case lir_fpop_raw:
624       fpop();
625       break;
626 #endif // IA32
627 
628     case lir_breakpoint:
629       breakpoint();
630       break;
631 
632     case lir_membar:
633       membar();
634       break;

648     case lir_membar_storestore:
649       membar_storestore();
650       break;
651 
652     case lir_membar_loadstore:
653       membar_loadstore();
654       break;
655 
656     case lir_membar_storeload:
657       membar_storeload();
658       break;
659 
660     case lir_get_thread:
661       get_thread(op->result_opr());
662       break;
663 
664     case lir_on_spin_wait:
665       on_spin_wait();
666       break;
667 




668     default:
669       ShouldNotReachHere();
670       break;
671   }
672 }
673 
674 
675 void LIR_Assembler::emit_op2(LIR_Op2* op) {
676   switch (op->code()) {
677     case lir_cmp:
678       if (op->info() != NULL) {
679         assert(op->in_opr1()->is_address() || op->in_opr2()->is_address(),
680                "shouldn't be codeemitinfo for non-address operands");
681         add_debug_info_for_null_check_here(op->info()); // exception possible
682       }
683       comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
684       break;
685 
686     case lir_cmp_l2i:
687     case lir_cmp_fd2i:

739         op->result_opr());
740       break;
741 
742     case lir_throw:
743       throw_op(op->in_opr1(), op->in_opr2(), op->info());
744       break;
745 
746     case lir_xadd:
747     case lir_xchg:
748       atomic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->tmp1_opr());
749       break;
750 
751     default:
752       Unimplemented();
753       break;
754   }
755 }
756 
757 
758 void LIR_Assembler::build_frame() {
759   _masm->build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());

760 }
761 
762 
763 void LIR_Assembler::roundfp_op(LIR_Opr src, LIR_Opr tmp, LIR_Opr dest, bool pop_fpu_stack) {
764   assert(strict_fp_requires_explicit_rounding, "not required");
765   assert((src->is_single_fpu() && dest->is_single_stack()) ||
766          (src->is_double_fpu() && dest->is_double_stack()),
767          "round_fp: rounds register -> stack location");
768 
769   reg2stack (src, dest, src->type(), pop_fpu_stack);
770 }
771 
772 
773 void LIR_Assembler::move_op(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide) {
774   if (src->is_register()) {
775     if (dest->is_register()) {
776       assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here");
777       reg2reg(src,  dest);
778     } else if (dest->is_stack()) {
779       assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here");

 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "asm/assembler.inline.hpp"
 27 #include "c1/c1_Compilation.hpp"
 28 #include "c1/c1_Instruction.hpp"
 29 #include "c1/c1_InstructionPrinter.hpp"
 30 #include "c1/c1_LIRAssembler.hpp"
 31 #include "c1/c1_MacroAssembler.hpp"
 32 #include "c1/c1_ValueStack.hpp"
 33 #include "ci/ciInlineKlass.hpp"
 34 #include "ci/ciInstance.hpp"
 35 #include "compiler/oopMap.hpp"
 36 #include "gc/shared/barrierSet.hpp"
 37 #include "runtime/os.hpp"
 38 #include "runtime/sharedRuntime.hpp"
 39 #include "runtime/vm_version.hpp"
 40 
 41 void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) {
 42   // We must have enough patching space so that call can be inserted.
 43   // We cannot use fat nops here, since the concurrent code rewrite may transiently
 44   // create the illegal instruction sequence.
 45   while ((intx) _masm->pc() - (intx) patch->pc_start() < NativeGeneralJump::instruction_size) {
 46     _masm->nop();
 47   }
 48   patch->install(_masm, patch_code, obj, info);
 49   append_code_stub(patch);
 50 
 51 #ifdef ASSERT
 52   Bytecodes::Code code = info->scope()->method()->java_code_at_bci(info->stack()->bci());
 53   if (patch->id() == PatchingStub::access_field_id) {
 54     switch (code) {
 55       case Bytecodes::_putstatic:
 56       case Bytecodes::_getstatic:
 57       case Bytecodes::_putfield:
 58       case Bytecodes::_getfield:
 59       case Bytecodes::_withfield:
 60         break;
 61       default:
 62         ShouldNotReachHere();
 63     }
 64   } else if (patch->id() == PatchingStub::load_klass_id) {
 65     switch (code) {
 66       case Bytecodes::_new:
 67       case Bytecodes::_defaultvalue:
 68       case Bytecodes::_anewarray:
 69       case Bytecodes::_multianewarray:
 70       case Bytecodes::_instanceof:
 71       case Bytecodes::_checkcast:
 72         break;
 73       default:
 74         ShouldNotReachHere();
 75     }
 76   } else if (patch->id() == PatchingStub::load_mirror_id) {
 77     switch (code) {
 78       case Bytecodes::_putstatic:
 79       case Bytecodes::_getstatic:
 80       case Bytecodes::_ldc:
 81       case Bytecodes::_ldc_w:
 82         break;
 83       default:
 84         ShouldNotReachHere();
 85     }
 86   } else if (patch->id() == PatchingStub::load_appendix_id) {
 87     Bytecodes::Code bc_raw = info->scope()->method()->raw_code_at_bci(info->stack()->bci());

104 //---------------------------------------------------------------
105 
106 
107 LIR_Assembler::LIR_Assembler(Compilation* c):
108    _masm(c->masm())
109  , _bs(BarrierSet::barrier_set())
110  , _compilation(c)
111  , _frame_map(c->frame_map())
112  , _current_block(NULL)
113  , _pending_non_safepoint(NULL)
114  , _pending_non_safepoint_offset(0)
115 {
116   _slow_case_stubs = new CodeStubList();
117 }
118 
119 
120 LIR_Assembler::~LIR_Assembler() {
121   // The unwind handler label may be unnbound if this destructor is invoked because of a bail-out.
122   // Reset it here to avoid an assertion.
123   _unwind_handler_entry.reset();
124   _verified_inline_entry.reset();
125 }
126 
127 
128 void LIR_Assembler::check_codespace() {
129   CodeSection* cs = _masm->code_section();
130   if (cs->remaining() < (int)(NOT_LP64(1*K)LP64_ONLY(2*K))) {
131     BAILOUT("CodeBuffer overflow");
132   }
133 }
134 
135 
136 void LIR_Assembler::append_code_stub(CodeStub* stub) {
137   _slow_case_stubs->append(stub);
138 }
139 
140 void LIR_Assembler::emit_stubs(CodeStubList* stub_list) {
141   for (int m = 0; m < stub_list->length(); m++) {
142     CodeStub* s = stub_list->at(m);
143 
144     check_codespace();

315     }
316 #endif /* PRODUCT */
317   }
318 }
319 
320 #ifdef ASSERT
321 void LIR_Assembler::check_no_unbound_labels() {
322   CHECK_BAILOUT();
323 
324   for (int i = 0; i < _branch_target_blocks.length() - 1; i++) {
325     if (!_branch_target_blocks.at(i)->label()->is_bound()) {
326       tty->print_cr("label of block B%d is not bound", _branch_target_blocks.at(i)->block_id());
327       assert(false, "unbound label");
328     }
329   }
330 }
331 #endif
332 
333 //----------------------------------debug info--------------------------------
334 

335 void LIR_Assembler::add_debug_info_for_branch(CodeEmitInfo* info) {
336   int pc_offset = code_offset();
337   flush_debug_info(pc_offset);
338   info->record_debug_info(compilation()->debug_info_recorder(), pc_offset);
339   if (info->exception_handlers() != NULL) {
340     compilation()->add_exception_handlers_for_pco(pc_offset, info->exception_handlers());
341   }
342 }
343 
344 void LIR_Assembler::add_call_info(int pc_offset, CodeEmitInfo* cinfo, bool maybe_return_as_fields) {

345   flush_debug_info(pc_offset);
346   cinfo->record_debug_info(compilation()->debug_info_recorder(), pc_offset, maybe_return_as_fields);
347   if (cinfo->exception_handlers() != NULL) {
348     compilation()->add_exception_handlers_for_pco(pc_offset, cinfo->exception_handlers());
349   }
350 }
351 
352 static ValueStack* debug_info(Instruction* ins) {
353   StateSplit* ss = ins->as_StateSplit();
354   if (ss != NULL) return ss->state();
355   return ins->state_before();
356 }
357 
358 void LIR_Assembler::process_debug_info(LIR_Op* op) {
359   Instruction* src = op->source();
360   if (src == NULL)  return;
361   int pc_offset = code_offset();
362   if (_pending_non_safepoint == src) {
363     _pending_non_safepoint_offset = pc_offset;
364     return;
365   }
366   ValueStack* vstack = debug_info(src);

466   case lir_dynamic_call:
467     call(op, relocInfo::static_call_type);
468     break;
469   case lir_optvirtual_call:
470     call(op, relocInfo::opt_virtual_call_type);
471     break;
472   case lir_icvirtual_call:
473     ic_call(op);
474     break;
475   default:
476     fatal("unexpected op code: %s", op->name());
477     break;
478   }
479 
480   // JSR 292
481   // Record if this method has MethodHandle invokes.
482   if (op->is_method_handle_invoke()) {
483     compilation()->set_has_method_handle_invokes(true);
484   }
485 
486   ciInlineKlass* vk = NULL;
487   if (op->maybe_return_as_fields(&vk)) {
488     int offset = store_inline_type_fields_to_buf(vk);
489     add_call_info(offset, op->info(), true);
490   }
491 
492 #if defined(IA32) && defined(COMPILER2)
493   // C2 leave fpu stack dirty clean it
494   if (UseSSE < 2 && !CompilerConfig::is_c1_only_no_jvmci()) {
495     int i;
496     for ( i = 1; i <= 7 ; i++ ) {
497       ffree(i);
498     }
499     if (!op->result_opr()->is_float_kind()) {
500       ffree(0);
501     }
502   }
503 #endif // IA32 && COMPILER2
504 }
505 
506 
507 void LIR_Assembler::emit_opLabel(LIR_OpLabel* op) {
508   _masm->bind (*(op->label()));
509 }
510 
511 

578       } else {
579         Unimplemented();
580       }
581       break;
582     }
583 
584     case lir_monaddr:
585       monitor_address(op->in_opr()->as_constant_ptr()->as_jint(), op->result_opr());
586       break;
587 
588     case lir_unwind:
589       unwind_op(op->in_opr());
590       break;
591 
592     default:
593       Unimplemented();
594       break;
595   }
596 }
597 
598 void LIR_Assembler::add_scalarized_entry_info(int pc_offset) {
599   flush_debug_info(pc_offset);
600   DebugInformationRecorder* debug_info = compilation()->debug_info_recorder();
601   // The VEP and VIEP(RO) of a C1-compiled method call buffer_inline_args_xxx()
602   // before doing any argument shuffling. This call may cause GC. When GC happens,
603   // all the parameters are still as passed by the caller, so we just use
604   // map->set_include_argument_oops() inside frame::sender_for_compiled_frame(RegisterMap* map).
605   // There's no need to build a GC map here.
606   OopMap* oop_map = new OopMap(0, 0);
607   debug_info->add_safepoint(pc_offset, oop_map);
608   DebugToken* locvals = debug_info->create_scope_values(NULL); // FIXME is this needed (for Java debugging to work properly??)
609   DebugToken* expvals = debug_info->create_scope_values(NULL); // FIXME is this needed (for Java debugging to work properly??)
610   DebugToken* monvals = debug_info->create_monitor_values(NULL); // FIXME: need testing with synchronized method
611   bool reexecute = false;
612   bool return_oop = false; // This flag will be ignored since it used only for C2 with escape analysis.
613   bool rethrow_exception = false;
614   bool is_method_handle_invoke = false;
615   debug_info->describe_scope(pc_offset, methodHandle(), method(), 0, reexecute, rethrow_exception, is_method_handle_invoke, return_oop, false, locvals, expvals, monvals);
616   debug_info->end_safepoint(pc_offset);
617 }
618 
619 // The entries points of C1-compiled methods can have the following types:
620 // (1) Methods with no inline type args
621 // (2) Methods with inline type receiver but no inline type args
622 //     VIEP_RO is the same as VIEP
623 // (3) Methods with non-inline type receiver and some inline type args
624 //     VIEP_RO is the same as VEP
625 // (4) Methods with inline type receiver and other inline type args
626 //     Separate VEP, VIEP and VIEP_RO
627 //
628 // (1)               (2)                 (3)                    (4)
629 // UEP/UIEP:         VEP:                UEP:                   UEP:
630 //   check_icache      pack receiver       check_icache           check_icache
631 // VEP/VIEP/VIEP_RO    jump to VIEP      VEP/VIEP_RO:           VIEP_RO:
632 //   body            UEP/UIEP:             pack inline args       pack inline args (except receiver)
633 //                     check_icache        jump to VIEP           jump to VIEP
634 //                   VIEP/VIEP_RO        UIEP:                  VEP:
635 //                     body                check_icache           pack all inline args
636 //                                       VIEP:                    jump to VIEP
637 //                                         body                 UIEP:
638 //                                                                check_icache
639 //                                                              VIEP:
640 //                                                                body
641 void LIR_Assembler::emit_std_entries() {
642   offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
643 
644   _masm->align(CodeEntryAlignment);
645   const CompiledEntrySignature* ces = compilation()->compiled_entry_signature();
646   if (ces->has_scalarized_args()) {
647     assert(InlineTypePassFieldsAsArgs && method()->get_Method()->has_scalarized_args(), "must be");
648     CodeOffsets::Entries ro_entry_type = ces->c1_inline_ro_entry_type();
649 
650     // UEP: check icache and fall-through
651     if (ro_entry_type != CodeOffsets::Verified_Inline_Entry) {
652       offsets()->set_value(CodeOffsets::Entry, _masm->offset());
653       if (needs_icache(method())) {
654         check_icache();
655       }
656     }
657 
658     // VIEP_RO: pack all value parameters, except the receiver
659     if (ro_entry_type == CodeOffsets::Verified_Inline_Entry_RO) {
660       emit_std_entry(CodeOffsets::Verified_Inline_Entry_RO, ces);
661     }
662 
663     // VEP: pack all value parameters
664     _masm->align(CodeEntryAlignment);
665     emit_std_entry(CodeOffsets::Verified_Entry, ces);
666 
667     // UIEP: check icache and fall-through
668     _masm->align(CodeEntryAlignment);
669     offsets()->set_value(CodeOffsets::Inline_Entry, _masm->offset());
670     if (ro_entry_type == CodeOffsets::Verified_Inline_Entry) {
671       // Special case if we have VIEP == VIEP(RO):
672       // this means UIEP (called by C1) == UEP (called by C2).
673       offsets()->set_value(CodeOffsets::Entry, _masm->offset());
674     }
675     if (needs_icache(method())) {
676       check_icache();
677     }
678 
679     // VIEP: all value parameters are passed as refs - no packing.
680     emit_std_entry(CodeOffsets::Verified_Inline_Entry, NULL);
681 
682     if (ro_entry_type != CodeOffsets::Verified_Inline_Entry_RO) {
683       // The VIEP(RO) is the same as VEP or VIEP
684       assert(ro_entry_type == CodeOffsets::Verified_Entry ||
685              ro_entry_type == CodeOffsets::Verified_Inline_Entry, "must be");
686       offsets()->set_value(CodeOffsets::Verified_Inline_Entry_RO,
687                            offsets()->value(ro_entry_type));
688     }
689   } else {
690     // All 3 entries are the same (no inline type packing)
691     offsets()->set_value(CodeOffsets::Entry, _masm->offset());
692     offsets()->set_value(CodeOffsets::Inline_Entry, _masm->offset());
693     if (needs_icache(method())) {
694       check_icache();
695     }
696     emit_std_entry(CodeOffsets::Verified_Inline_Entry, NULL);
697     offsets()->set_value(CodeOffsets::Verified_Entry, offsets()->value(CodeOffsets::Verified_Inline_Entry));
698     offsets()->set_value(CodeOffsets::Verified_Inline_Entry_RO, offsets()->value(CodeOffsets::Verified_Inline_Entry));
699   }
700 }
701 
702 void LIR_Assembler::emit_std_entry(CodeOffsets::Entries entry, const CompiledEntrySignature* ces) {
703   offsets()->set_value(entry, _masm->offset());
704   _masm->verified_entry();
705   switch (entry) {
706   case CodeOffsets::Verified_Entry: {
707     if (needs_clinit_barrier_on_entry(method())) {
708       clinit_barrier(method());
709     }
710     int rt_call_offset = _masm->verified_entry(ces, initial_frame_size_in_bytes(), bang_size_in_bytes(), in_bytes(frame_map()->sp_offset_for_orig_pc()), _verified_inline_entry);
711     add_scalarized_entry_info(rt_call_offset);
712     break;
713   }
714   case CodeOffsets::Verified_Inline_Entry_RO: {
715     assert(!needs_clinit_barrier_on_entry(method()), "can't be static");
716     int rt_call_offset = _masm->verified_inline_ro_entry(ces, initial_frame_size_in_bytes(), bang_size_in_bytes(), in_bytes(frame_map()->sp_offset_for_orig_pc()), _verified_inline_entry);
717     add_scalarized_entry_info(rt_call_offset);
718     break;
719   }
720   case CodeOffsets::Verified_Inline_Entry: {
721     if (needs_clinit_barrier_on_entry(method())) {
722       clinit_barrier(method());
723     }
724     build_frame();
725     offsets()->set_value(CodeOffsets::Frame_Complete, _masm->offset());
726     break;
727   }
728   default:
729     ShouldNotReachHere();
730     break;
731   }
732 }
733 
734 void LIR_Assembler::emit_op0(LIR_Op0* op) {
735   switch (op->code()) {
736     case lir_nop:
737       assert(op->info() == NULL, "not supported");
738       _masm->nop();
739       break;
740 
741     case lir_label:
742       Unimplemented();
743       break;
744 
745     case lir_std_entry:
746       emit_std_entries();












747       break;
748 
749     case lir_osr_entry:
750       offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset());
751       osr_entry();
752       break;
753 
754 #ifdef IA32
755     case lir_fpop_raw:
756       fpop();
757       break;
758 #endif // IA32
759 
760     case lir_breakpoint:
761       breakpoint();
762       break;
763 
764     case lir_membar:
765       membar();
766       break;

780     case lir_membar_storestore:
781       membar_storestore();
782       break;
783 
784     case lir_membar_loadstore:
785       membar_loadstore();
786       break;
787 
788     case lir_membar_storeload:
789       membar_storeload();
790       break;
791 
792     case lir_get_thread:
793       get_thread(op->result_opr());
794       break;
795 
796     case lir_on_spin_wait:
797       on_spin_wait();
798       break;
799 
800     case lir_check_orig_pc:
801       check_orig_pc();
802       break;
803 
804     default:
805       ShouldNotReachHere();
806       break;
807   }
808 }
809 
810 
811 void LIR_Assembler::emit_op2(LIR_Op2* op) {
812   switch (op->code()) {
813     case lir_cmp:
814       if (op->info() != NULL) {
815         assert(op->in_opr1()->is_address() || op->in_opr2()->is_address(),
816                "shouldn't be codeemitinfo for non-address operands");
817         add_debug_info_for_null_check_here(op->info()); // exception possible
818       }
819       comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op);
820       break;
821 
822     case lir_cmp_l2i:
823     case lir_cmp_fd2i:

875         op->result_opr());
876       break;
877 
878     case lir_throw:
879       throw_op(op->in_opr1(), op->in_opr2(), op->info());
880       break;
881 
882     case lir_xadd:
883     case lir_xchg:
884       atomic_op(op->code(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->tmp1_opr());
885       break;
886 
887     default:
888       Unimplemented();
889       break;
890   }
891 }
892 
893 
894 void LIR_Assembler::build_frame() {
895   _masm->build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes(), in_bytes(frame_map()->sp_offset_for_orig_pc()),
896                      needs_stack_repair(), method()->has_scalarized_args(), &_verified_inline_entry);
897 }
898 
899 
900 void LIR_Assembler::roundfp_op(LIR_Opr src, LIR_Opr tmp, LIR_Opr dest, bool pop_fpu_stack) {
901   assert(strict_fp_requires_explicit_rounding, "not required");
902   assert((src->is_single_fpu() && dest->is_single_stack()) ||
903          (src->is_double_fpu() && dest->is_double_stack()),
904          "round_fp: rounds register -> stack location");
905 
906   reg2stack (src, dest, src->type(), pop_fpu_stack);
907 }
908 
909 
910 void LIR_Assembler::move_op(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide) {
911   if (src->is_register()) {
912     if (dest->is_register()) {
913       assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here");
914       reg2reg(src,  dest);
915     } else if (dest->is_stack()) {
916       assert(patch_code == lir_patch_none && info == NULL, "no patching and info allowed here");
< prev index next >