322 }
323
324 if (C->stub_function() == nullptr) {
325 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
326 bs->nmethod_entry_barrier(masm);
327 }
328
329 // offset from scratch buffer is not valid
330 if (strcmp(__ code()->name(), "Compile::Fill_buffer") == 0) {
331 C->output()->set_frame_complete( __ offset() );
332 }
333
334 if (C->has_mach_constant_base_node()) {
335 // NOTE: We set the table base offset here because users might be
336 // emitted before MachConstantBaseNode.
337 ConstantTable& constant_table = C->output()->constant_table();
338 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
339 }
340 }
341
342 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
343 return MachNode::size(ra_);
344 }
345
346 int MachPrologNode::reloc() const {
347 return 10; // a large enough number
348 }
349
350 //=============================================================================
351 #ifndef PRODUCT
352 void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
353 Compile* C = ra_->C;
354
355 size_t framesize = C->output()->frame_size_in_bytes();
356 framesize -= 2*wordSize;
357
358 if (framesize != 0) {
359 st->print("ADD R_SP, R_SP, %zu\n\t",framesize);
360 }
361 st->print("POP R_FP|R_LR_LR");
362
363 if (do_polling() && ra_->C->is_method_compilation()) {
364 st->print("\n\t");
365 st->print("MOV Rtemp, #PollAddr\t! Load Polling address\n\t");
367 }
368 }
369 #endif
370
371 void MachEpilogNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
372 Compile* C = ra_->C;
373
374 size_t framesize = C->output()->frame_size_in_bytes();
375 framesize -= 2*wordSize;
376 if (framesize != 0) {
377 __ add_slow(SP, SP, framesize);
378 }
379 __ raw_pop(FP, LR);
380
381 // If this does safepoint polling, then do it here
382 if (do_polling() && ra_->C->is_method_compilation()) {
383 __ read_polling_page(Rtemp, relocInfo::poll_return_type);
384 }
385 }
386
387 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
388 return MachNode::size(ra_);
389 }
390
391 int MachEpilogNode::reloc() const {
392 return 16; // a large enough number
393 }
394
395 const Pipeline * MachEpilogNode::pipeline() const {
396 return MachNode::pipeline_class();
397 }
398
399 //=============================================================================
400
401 // Figure out which register class each belongs in: rc_int, rc_float, rc_stack
402 enum RC { rc_bad, rc_int, rc_float, rc_stack };
403 static enum RC rc_class( OptoReg::Name reg ) {
404 if (!OptoReg::is_valid(reg)) return rc_bad;
405 if (OptoReg::is_stack(reg)) return rc_stack;
406 VMReg r = OptoReg::as_VMReg(reg);
407 if (r->is_Register()) return rc_int;
408 assert(r->is_FloatRegister(), "must be");
409 return rc_float;
410 }
832 void BoxLockNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
833 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
834 int reg = ra_->get_encode(this);
835 Register dst = reg_to_register_object(reg);
836
837 if (is_aimm(offset)) {
838 __ add(dst, SP, offset);
839 } else {
840 __ mov_slow(dst, offset);
841 __ add(dst, SP, dst);
842 }
843 }
844
845 uint BoxLockNode::size(PhaseRegAlloc *ra_) const {
846 // BoxLockNode is not a MachNode, so we can't just call MachNode::size(ra_)
847 assert(ra_ == ra_->C->regalloc(), "sanity");
848 return ra_->C->output()->scratch_emit_size(this);
849 }
850
851 //=============================================================================
852 #ifndef PRODUCT
853 #define R_RTEMP "R_R12"
854 void MachUEPNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
855 st->print_cr("\nUEP:");
856 st->print_cr("\tLDR " R_RTEMP ",[R_R0 + oopDesc::klass_offset_in_bytes]\t! Inline cache check");
857 st->print_cr("\tCMP " R_RTEMP ",R_R8" );
858 st->print ("\tB.NE SharedRuntime::handle_ic_miss_stub");
859 }
860 #endif
861
862 void MachUEPNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
863 __ ic_check(InteriorEntryAlignment);
864 }
865
866 uint MachUEPNode::size(PhaseRegAlloc *ra_) const {
867 return MachNode::size(ra_);
868 }
869
870
871 //=============================================================================
872
873 int HandlerImpl::emit_deopt_handler(C2_MacroAssembler* masm) {
874 // Can't use any of the current frame's registers as we may have deopted
875 // at a poll and everything can be live.
876 address base = __ start_a_stub(size_deopt_handler());
877 if (base == nullptr) {
878 ciEnv::current()->record_failure("CodeCache is full");
879 return 0; // CodeBuffer::expand failed
880 }
881
882 int offset = __ offset();
883
884 Label start;
885 __ bind(start);
886
887 __ jump(SharedRuntime::deopt_blob()->unpack(), relocInfo::runtime_call_type, noreg);
888
889 int entry_offset = __ offset();
890 address deopt_pc = __ pc();
|
322 }
323
324 if (C->stub_function() == nullptr) {
325 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
326 bs->nmethod_entry_barrier(masm);
327 }
328
329 // offset from scratch buffer is not valid
330 if (strcmp(__ code()->name(), "Compile::Fill_buffer") == 0) {
331 C->output()->set_frame_complete( __ offset() );
332 }
333
334 if (C->has_mach_constant_base_node()) {
335 // NOTE: We set the table base offset here because users might be
336 // emitted before MachConstantBaseNode.
337 ConstantTable& constant_table = C->output()->constant_table();
338 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
339 }
340 }
341
342 int MachPrologNode::reloc() const {
343 return 10; // a large enough number
344 }
345
346 //=============================================================================
347 #ifndef PRODUCT
348 void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
349 Compile* C = ra_->C;
350
351 size_t framesize = C->output()->frame_size_in_bytes();
352 framesize -= 2*wordSize;
353
354 if (framesize != 0) {
355 st->print("ADD R_SP, R_SP, %zu\n\t",framesize);
356 }
357 st->print("POP R_FP|R_LR_LR");
358
359 if (do_polling() && ra_->C->is_method_compilation()) {
360 st->print("\n\t");
361 st->print("MOV Rtemp, #PollAddr\t! Load Polling address\n\t");
363 }
364 }
365 #endif
366
367 void MachEpilogNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
368 Compile* C = ra_->C;
369
370 size_t framesize = C->output()->frame_size_in_bytes();
371 framesize -= 2*wordSize;
372 if (framesize != 0) {
373 __ add_slow(SP, SP, framesize);
374 }
375 __ raw_pop(FP, LR);
376
377 // If this does safepoint polling, then do it here
378 if (do_polling() && ra_->C->is_method_compilation()) {
379 __ read_polling_page(Rtemp, relocInfo::poll_return_type);
380 }
381 }
382
383 int MachEpilogNode::reloc() const {
384 return 16; // a large enough number
385 }
386
387 const Pipeline * MachEpilogNode::pipeline() const {
388 return MachNode::pipeline_class();
389 }
390
391 //=============================================================================
392
393 // Figure out which register class each belongs in: rc_int, rc_float, rc_stack
394 enum RC { rc_bad, rc_int, rc_float, rc_stack };
395 static enum RC rc_class( OptoReg::Name reg ) {
396 if (!OptoReg::is_valid(reg)) return rc_bad;
397 if (OptoReg::is_stack(reg)) return rc_stack;
398 VMReg r = OptoReg::as_VMReg(reg);
399 if (r->is_Register()) return rc_int;
400 assert(r->is_FloatRegister(), "must be");
401 return rc_float;
402 }
824 void BoxLockNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
825 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
826 int reg = ra_->get_encode(this);
827 Register dst = reg_to_register_object(reg);
828
829 if (is_aimm(offset)) {
830 __ add(dst, SP, offset);
831 } else {
832 __ mov_slow(dst, offset);
833 __ add(dst, SP, dst);
834 }
835 }
836
837 uint BoxLockNode::size(PhaseRegAlloc *ra_) const {
838 // BoxLockNode is not a MachNode, so we can't just call MachNode::size(ra_)
839 assert(ra_ == ra_->C->regalloc(), "sanity");
840 return ra_->C->output()->scratch_emit_size(this);
841 }
842
843 //=============================================================================
844 #ifndef PRODUCT
845 void MachVEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const
846 {
847 Unimplemented();
848 }
849 #endif
850
851 void MachVEPNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc* ra_) const
852 {
853 Unimplemented();
854 }
855
856 #ifndef PRODUCT
857 #define R_RTEMP "R_R12"
858 void MachUEPNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
859 st->print_cr("\nUEP:");
860 st->print_cr("\tLDR " R_RTEMP ",[R_R0 + oopDesc::klass_offset_in_bytes]\t! Inline cache check");
861 st->print_cr("\tCMP " R_RTEMP ",R_R8" );
862 st->print ("\tB.NE SharedRuntime::handle_ic_miss_stub");
863 }
864 #endif
865
866 void MachUEPNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
867 __ ic_check(InteriorEntryAlignment);
868 }
869
870 //=============================================================================
871
872 int HandlerImpl::emit_deopt_handler(C2_MacroAssembler* masm) {
873 // Can't use any of the current frame's registers as we may have deopted
874 // at a poll and everything can be live.
875 address base = __ start_a_stub(size_deopt_handler());
876 if (base == nullptr) {
877 ciEnv::current()->record_failure("CodeCache is full");
878 return 0; // CodeBuffer::expand failed
879 }
880
881 int offset = __ offset();
882
883 Label start;
884 __ bind(start);
885
886 __ jump(SharedRuntime::deopt_blob()->unpack(), relocInfo::runtime_call_type, noreg);
887
888 int entry_offset = __ offset();
889 address deopt_pc = __ pc();
|