From 85b8ac38d92fbea71accb12eeeb64666ddc9b70c Mon Sep 17 00:00:00 2001 From: roland Date: Tue, 11 Sep 2012 16:20:57 +0200 Subject: [PATCH] 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere Summary: C1 needs knowledge of T_METADATA at the LIR level. Reviewed-by: kvn, coleenp --- src/cpu/sparc/vm/c1_FrameMap_sparc.cpp | 66 ++++++++++++++++++++ src/cpu/sparc/vm/c1_FrameMap_sparc.hpp | 33 ++++++++++ src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp | 7 +++ src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp | 15 ++--- src/cpu/sparc/vm/sharedRuntime_sparc.cpp | 2 + src/cpu/x86/vm/c1_FrameMap_x86.cpp | 28 +++++++++ src/cpu/x86/vm/c1_FrameMap_x86.hpp | 16 +++++ src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 12 ++++ src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 16 ++--- src/cpu/x86/vm/sharedRuntime_x86_32.cpp | 1 + src/cpu/x86/vm/sharedRuntime_x86_64.cpp | 1 + src/share/vm/c1/c1_FrameMap.hpp | 4 ++ src/share/vm/c1/c1_LIR.cpp | 8 ++- src/share/vm/c1/c1_LIR.hpp | 28 ++++++++- src/share/vm/c1/c1_LIRGenerator.cpp | 28 ++++----- src/share/vm/c1/c1_LinearScan.cpp | 6 ++ src/share/vm/c1/c1_ValueType.cpp | 1 + src/share/vm/opto/runtime.cpp | 2 +- src/share/vm/utilities/globalDefinitions.cpp | 2 +- 19 files changed, 242 insertions(+), 34 deletions(-) diff --git a/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp b/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp index 6b9e5652a..0dce25054 100644 --- a/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp +++ b/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp @@ -147,6 +147,39 @@ LIR_Opr FrameMap::I5_oop_opr; LIR_Opr FrameMap::I6_oop_opr; LIR_Opr FrameMap::I7_oop_opr; +LIR_Opr FrameMap::G0_metadata_opr; +LIR_Opr FrameMap::G1_metadata_opr; +LIR_Opr FrameMap::G2_metadata_opr; +LIR_Opr FrameMap::G3_metadata_opr; +LIR_Opr FrameMap::G4_metadata_opr; +LIR_Opr FrameMap::G5_metadata_opr; +LIR_Opr FrameMap::G6_metadata_opr; +LIR_Opr FrameMap::G7_metadata_opr; +LIR_Opr FrameMap::O0_metadata_opr; +LIR_Opr FrameMap::O1_metadata_opr; +LIR_Opr FrameMap::O2_metadata_opr; +LIR_Opr FrameMap::O3_metadata_opr; +LIR_Opr FrameMap::O4_metadata_opr; +LIR_Opr FrameMap::O5_metadata_opr; +LIR_Opr FrameMap::O6_metadata_opr; +LIR_Opr FrameMap::O7_metadata_opr; +LIR_Opr FrameMap::L0_metadata_opr; +LIR_Opr FrameMap::L1_metadata_opr; +LIR_Opr FrameMap::L2_metadata_opr; +LIR_Opr FrameMap::L3_metadata_opr; +LIR_Opr FrameMap::L4_metadata_opr; +LIR_Opr FrameMap::L5_metadata_opr; +LIR_Opr FrameMap::L6_metadata_opr; +LIR_Opr FrameMap::L7_metadata_opr; +LIR_Opr FrameMap::I0_metadata_opr; +LIR_Opr FrameMap::I1_metadata_opr; +LIR_Opr FrameMap::I2_metadata_opr; +LIR_Opr FrameMap::I3_metadata_opr; +LIR_Opr FrameMap::I4_metadata_opr; +LIR_Opr FrameMap::I5_metadata_opr; +LIR_Opr FrameMap::I6_metadata_opr; +LIR_Opr FrameMap::I7_metadata_opr; + LIR_Opr FrameMap::SP_opr; LIR_Opr FrameMap::FP_opr; @@ -310,6 +343,39 @@ void FrameMap::initialize() { I6_oop_opr = as_oop_opr(I6); I7_oop_opr = as_oop_opr(I7); + G0_metadata_opr = as_metadata_opr(G0); + G1_metadata_opr = as_metadata_opr(G1); + G2_metadata_opr = as_metadata_opr(G2); + G3_metadata_opr = as_metadata_opr(G3); + G4_metadata_opr = as_metadata_opr(G4); + G5_metadata_opr = as_metadata_opr(G5); + G6_metadata_opr = as_metadata_opr(G6); + G7_metadata_opr = as_metadata_opr(G7); + O0_metadata_opr = as_metadata_opr(O0); + O1_metadata_opr = as_metadata_opr(O1); + O2_metadata_opr = as_metadata_opr(O2); + O3_metadata_opr = as_metadata_opr(O3); + O4_metadata_opr = as_metadata_opr(O4); + O5_metadata_opr = as_metadata_opr(O5); + O6_metadata_opr = as_metadata_opr(O6); + O7_metadata_opr = as_metadata_opr(O7); + L0_metadata_opr = as_metadata_opr(L0); + L1_metadata_opr = as_metadata_opr(L1); + L2_metadata_opr = as_metadata_opr(L2); + L3_metadata_opr = as_metadata_opr(L3); + L4_metadata_opr = as_metadata_opr(L4); + L5_metadata_opr = as_metadata_opr(L5); + L6_metadata_opr = as_metadata_opr(L6); + L7_metadata_opr = as_metadata_opr(L7); + I0_metadata_opr = as_metadata_opr(I0); + I1_metadata_opr = as_metadata_opr(I1); + I2_metadata_opr = as_metadata_opr(I2); + I3_metadata_opr = as_metadata_opr(I3); + I4_metadata_opr = as_metadata_opr(I4); + I5_metadata_opr = as_metadata_opr(I5); + I6_metadata_opr = as_metadata_opr(I6); + I7_metadata_opr = as_metadata_opr(I7); + FP_opr = as_pointer_opr(FP); SP_opr = as_pointer_opr(SP); diff --git a/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp b/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp index 2304c2d01..4eb731d7b 100644 --- a/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp +++ b/src/cpu/sparc/vm/c1_FrameMap_sparc.hpp @@ -104,6 +104,39 @@ static LIR_Opr I6_oop_opr; static LIR_Opr I7_oop_opr; + static LIR_Opr G0_metadata_opr; + static LIR_Opr G1_metadata_opr; + static LIR_Opr G2_metadata_opr; + static LIR_Opr G3_metadata_opr; + static LIR_Opr G4_metadata_opr; + static LIR_Opr G5_metadata_opr; + static LIR_Opr G6_metadata_opr; + static LIR_Opr G7_metadata_opr; + static LIR_Opr O0_metadata_opr; + static LIR_Opr O1_metadata_opr; + static LIR_Opr O2_metadata_opr; + static LIR_Opr O3_metadata_opr; + static LIR_Opr O4_metadata_opr; + static LIR_Opr O5_metadata_opr; + static LIR_Opr O6_metadata_opr; + static LIR_Opr O7_metadata_opr; + static LIR_Opr L0_metadata_opr; + static LIR_Opr L1_metadata_opr; + static LIR_Opr L2_metadata_opr; + static LIR_Opr L3_metadata_opr; + static LIR_Opr L4_metadata_opr; + static LIR_Opr L5_metadata_opr; + static LIR_Opr L6_metadata_opr; + static LIR_Opr L7_metadata_opr; + static LIR_Opr I0_metadata_opr; + static LIR_Opr I1_metadata_opr; + static LIR_Opr I2_metadata_opr; + static LIR_Opr I3_metadata_opr; + static LIR_Opr I4_metadata_opr; + static LIR_Opr I5_metadata_opr; + static LIR_Opr I6_metadata_opr; + static LIR_Opr I7_metadata_opr; + static LIR_Opr in_long_opr; static LIR_Opr out_long_opr; static LIR_Opr g1_long_single_opr; diff --git a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 694dedfd1..2890c56d8 100644 --- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -447,9 +447,12 @@ int LIR_Assembler::emit_unwind_handler() { if (compilation()->env()->dtrace_method_probes()) { __ mov(G2_thread, O0); + __ save_thread(I1); // need to preserve thread in G2 across + // runtime call metadata2reg(method()->constant_encoding(), O1); __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), relocInfo::runtime_call_type); __ delayed()->nop(); + __ restore_thread(I1); } if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) { @@ -843,6 +846,7 @@ int LIR_Assembler::store(LIR_Opr from_reg, Register base, int offset, BasicType #endif break; case T_ADDRESS: + case T_METADATA: __ st_ptr(from_reg->as_register(), base, offset); break; case T_ARRAY : // fall through @@ -965,6 +969,7 @@ int LIR_Assembler::load(Register base, int offset, LIR_Opr to_reg, BasicType typ #endif } break; + case T_METADATA: case T_ADDRESS: __ ld_ptr(base, offset, to_reg->as_register()); break; case T_ARRAY : // fall through case T_OBJECT: @@ -1366,6 +1371,7 @@ Address LIR_Assembler::as_Address_lo(LIR_Address* addr) { void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool wide, bool unaligned) { + assert(type != T_METADATA, "load of metadata ptr not supported"); LIR_Address* addr = src_opr->as_address_ptr(); LIR_Opr to_reg = dest; @@ -1513,6 +1519,7 @@ void LIR_Assembler::reg2reg(LIR_Opr from_reg, LIR_Opr to_reg) { void LIR_Assembler::reg2mem(LIR_Opr from_reg, LIR_Opr dest, BasicType type, LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack, bool wide, bool unaligned) { + assert(type != T_METADATA, "store of metadata ptr not supported"); LIR_Address* addr = dest->as_address_ptr(); Register src = addr->base()->as_pointer_register(); diff --git a/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp index 9128a6f7d..75b7b6cdf 100644 --- a/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp +++ b/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp @@ -884,7 +884,7 @@ void LIRGenerator::do_NewInstance(NewInstance* x) { LIR_Opr tmp2 = FrameMap::G3_oop_opr; LIR_Opr tmp3 = FrameMap::G4_oop_opr; LIR_Opr tmp4 = FrameMap::O1_oop_opr; - LIR_Opr klass_reg = FrameMap::G5_oop_opr; + LIR_Opr klass_reg = FrameMap::G5_metadata_opr; new_instance(reg, x->klass(), tmp1, tmp2, tmp3, tmp4, klass_reg, info); LIR_Opr result = rlock_result(x); __ move(reg, result); @@ -903,11 +903,11 @@ void LIRGenerator::do_NewTypeArray(NewTypeArray* x) { LIR_Opr tmp2 = FrameMap::G3_oop_opr; LIR_Opr tmp3 = FrameMap::G4_oop_opr; LIR_Opr tmp4 = FrameMap::O1_oop_opr; - LIR_Opr klass_reg = FrameMap::G5_oop_opr; + LIR_Opr klass_reg = FrameMap::G5_metadata_opr; LIR_Opr len = length.result(); BasicType elem_type = x->elt_type(); - __ oop2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); + __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info); __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path); @@ -935,7 +935,7 @@ void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { LIR_Opr tmp2 = FrameMap::G3_oop_opr; LIR_Opr tmp3 = FrameMap::G4_oop_opr; LIR_Opr tmp4 = FrameMap::O1_oop_opr; - LIR_Opr klass_reg = FrameMap::G5_oop_opr; + LIR_Opr klass_reg = FrameMap::G5_metadata_opr; LIR_Opr len = length.result(); CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info); @@ -985,8 +985,8 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { // This instruction can be deoptimized in the slow path : use // O0 as result register. - const LIR_Opr reg = result_register_for(x->type()); - klass2reg_with_patching(reg, x->klass(), patching_info); + const LIR_Opr klass_reg = FrameMap::O0_metadata_opr; + klass2reg_with_patching(klass_reg, x->klass(), patching_info); LIR_Opr rank = FrameMap::O1_opr; __ move(LIR_OprFact::intConst(x->rank()), rank); LIR_Opr varargs = FrameMap::as_pointer_opr(O2); @@ -995,9 +995,10 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { LIR_OprFact::intptrConst(offset_from_sp), varargs); LIR_OprList* args = new LIR_OprList(3); - args->append(reg); + args->append(klass_reg); args->append(rank); args->append(varargs); + const LIR_Opr reg = result_register_for(x->type()); __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); diff --git a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp index f1d06dc1c..2968bc8df 100644 --- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp @@ -1340,6 +1340,7 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt, case T_ADDRESS: // raw pointers, like current thread, for VM calls case T_ARRAY: case T_OBJECT: + case T_METADATA: regs[i].set2( int_stk_helper( j ) ); break; case T_FLOAT: @@ -1388,6 +1389,7 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt, case T_FLOAT: case T_INT: case T_OBJECT: + case T_METADATA: case T_SHORT: regs[i].set1( int_stk_helper( i ) ); break; diff --git a/src/cpu/x86/vm/c1_FrameMap_x86.cpp b/src/cpu/x86/vm/c1_FrameMap_x86.cpp index 52f42977f..87b32a433 100644 --- a/src/cpu/x86/vm/c1_FrameMap_x86.cpp +++ b/src/cpu/x86/vm/c1_FrameMap_x86.cpp @@ -96,6 +96,13 @@ LIR_Opr FrameMap::rax_oop_opr; LIR_Opr FrameMap::rdx_oop_opr; LIR_Opr FrameMap::rcx_oop_opr; +LIR_Opr FrameMap::rsi_metadata_opr; +LIR_Opr FrameMap::rdi_metadata_opr; +LIR_Opr FrameMap::rbx_metadata_opr; +LIR_Opr FrameMap::rax_metadata_opr; +LIR_Opr FrameMap::rdx_metadata_opr; +LIR_Opr FrameMap::rcx_metadata_opr; + LIR_Opr FrameMap::long0_opr; LIR_Opr FrameMap::long1_opr; LIR_Opr FrameMap::fpu0_float_opr; @@ -122,6 +129,13 @@ LIR_Opr FrameMap::r11_oop_opr; LIR_Opr FrameMap::r12_oop_opr; LIR_Opr FrameMap::r13_oop_opr; LIR_Opr FrameMap::r14_oop_opr; + +LIR_Opr FrameMap::r8_metadata_opr; +LIR_Opr FrameMap::r9_metadata_opr; +LIR_Opr FrameMap::r11_metadata_opr; +LIR_Opr FrameMap::r12_metadata_opr; +LIR_Opr FrameMap::r13_metadata_opr; +LIR_Opr FrameMap::r14_metadata_opr; #endif // _LP64 LIR_Opr FrameMap::_caller_save_cpu_regs[] = { 0, }; @@ -236,6 +250,13 @@ void FrameMap::initialize() { rdx_oop_opr = as_oop_opr(rdx); rcx_oop_opr = as_oop_opr(rcx); + rsi_metadata_opr = as_metadata_opr(rsi); + rdi_metadata_opr = as_metadata_opr(rdi); + rbx_metadata_opr = as_metadata_opr(rbx); + rax_metadata_opr = as_metadata_opr(rax); + rdx_metadata_opr = as_metadata_opr(rdx); + rcx_metadata_opr = as_metadata_opr(rcx); + rsp_opr = as_pointer_opr(rsp); rbp_opr = as_pointer_opr(rbp); @@ -246,6 +267,13 @@ void FrameMap::initialize() { r12_oop_opr = as_oop_opr(r12); r13_oop_opr = as_oop_opr(r13); r14_oop_opr = as_oop_opr(r14); + + r8_metadata_opr = as_metadata_opr(r8); + r9_metadata_opr = as_metadata_opr(r9); + r11_metadata_opr = as_metadata_opr(r11); + r12_metadata_opr = as_metadata_opr(r12); + r13_metadata_opr = as_metadata_opr(r13); + r14_metadata_opr = as_metadata_opr(r14); #endif // _LP64 VMRegPair regs; diff --git a/src/cpu/x86/vm/c1_FrameMap_x86.hpp b/src/cpu/x86/vm/c1_FrameMap_x86.hpp index 642701c28..e61f72aa7 100644 --- a/src/cpu/x86/vm/c1_FrameMap_x86.hpp +++ b/src/cpu/x86/vm/c1_FrameMap_x86.hpp @@ -73,6 +73,14 @@ static LIR_Opr rax_oop_opr; static LIR_Opr rdx_oop_opr; static LIR_Opr rcx_oop_opr; + + static LIR_Opr rsi_metadata_opr; + static LIR_Opr rdi_metadata_opr; + static LIR_Opr rbx_metadata_opr; + static LIR_Opr rax_metadata_opr; + static LIR_Opr rdx_metadata_opr; + static LIR_Opr rcx_metadata_opr; + #ifdef _LP64 static LIR_Opr r8_opr; @@ -92,6 +100,14 @@ static LIR_Opr r13_oop_opr; static LIR_Opr r14_oop_opr; + static LIR_Opr r8_metadata_opr; + static LIR_Opr r9_metadata_opr; + + static LIR_Opr r11_metadata_opr; + static LIR_Opr r12_metadata_opr; + static LIR_Opr r13_metadata_opr; + static LIR_Opr r14_metadata_opr; + #endif // _LP64 static LIR_Opr long0_opr; diff --git a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index e0b8b18b5..36bd4d764 100644 --- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -950,6 +950,8 @@ void LIR_Assembler::reg2stack(LIR_Opr src, LIR_Opr dest, BasicType type, bool po if (type == T_OBJECT || type == T_ARRAY) { __ verify_oop(src->as_register()); __ movptr (dst, src->as_register()); + } else if (type == T_METADATA) { + __ movptr (dst, src->as_register()); } else { __ movl (dst, src->as_register()); } @@ -1041,6 +1043,14 @@ void LIR_Assembler::reg2mem(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch __ movptr(as_Address(to_addr), src->as_register()); } break; + case T_METADATA: + // We get here to store a method pointer to the stack to pass to + // a dtrace runtime call. This can't work on 64 bit with + // compressed klass ptrs: T_METADATA can be a compressed klass + // ptr or a 64 bit method pointer. + LP64_ONLY(ShouldNotReachHere()); + __ movptr(as_Address(to_addr), src->as_register()); + break; case T_ADDRESS: __ movptr(as_Address(to_addr), src->as_register()); break; @@ -1118,6 +1128,8 @@ void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) { if (type == T_ARRAY || type == T_OBJECT) { __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); __ verify_oop(dest->as_register()); + } else if (type == T_METADATA) { + __ movptr(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); } else { __ movl(dest->as_register(), frame_map()->address_for_slot(src->single_stack_ix())); } diff --git a/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index e2345914e..d363c0eec 100644 --- a/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -1002,13 +1002,12 @@ void LIRGenerator::do_NewInstance(NewInstance* x) { #endif CodeEmitInfo* info = state_for(x, x->state()); LIR_Opr reg = result_register_for(x->type()); - LIR_Opr klass_reg = new_register(objectType); new_instance(reg, x->klass(), FrameMap::rcx_oop_opr, FrameMap::rdi_oop_opr, FrameMap::rsi_oop_opr, LIR_OprFact::illegalOpr, - FrameMap::rdx_oop_opr, info); + FrameMap::rdx_metadata_opr, info); LIR_Opr result = rlock_result(x); __ move(reg, result); } @@ -1025,11 +1024,11 @@ void LIRGenerator::do_NewTypeArray(NewTypeArray* x) { LIR_Opr tmp2 = FrameMap::rsi_oop_opr; LIR_Opr tmp3 = FrameMap::rdi_oop_opr; LIR_Opr tmp4 = reg; - LIR_Opr klass_reg = FrameMap::rdx_oop_opr; + LIR_Opr klass_reg = FrameMap::rdx_metadata_opr; LIR_Opr len = length.result(); BasicType elem_type = x->elt_type(); - __ oop2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); + __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info); __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path); @@ -1055,7 +1054,7 @@ void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { LIR_Opr tmp2 = FrameMap::rsi_oop_opr; LIR_Opr tmp3 = FrameMap::rdi_oop_opr; LIR_Opr tmp4 = reg; - LIR_Opr klass_reg = FrameMap::rdx_oop_opr; + LIR_Opr klass_reg = FrameMap::rdx_metadata_opr; length.load_item_force(FrameMap::rbx_opr); LIR_Opr len = length.result(); @@ -1103,17 +1102,18 @@ void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { store_stack_parameter(size->result(), in_ByteSize(i*4)); } - LIR_Opr reg = result_register_for(x->type()); - klass2reg_with_patching(reg, x->klass(), patching_info); + LIR_Opr klass_reg = FrameMap::rax_metadata_opr; + klass2reg_with_patching(klass_reg, x->klass(), patching_info); LIR_Opr rank = FrameMap::rbx_opr; __ move(LIR_OprFact::intConst(x->rank()), rank); LIR_Opr varargs = FrameMap::rcx_opr; __ move(FrameMap::rsp_opr, varargs); LIR_OprList* args = new LIR_OprList(3); - args->append(reg); + args->append(klass_reg); args->append(rank); args->append(varargs); + LIR_Opr reg = result_register_for(x->type()); __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), LIR_OprFact::illegalOpr, reg, args, info); diff --git a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index 3bf6763f5..30b5cfca9 100644 --- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -938,6 +938,7 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt, case T_OBJECT: case T_ARRAY: case T_ADDRESS: + case T_METADATA: regs[i].set1(VMRegImpl::stack2reg(stack++)); break; case T_LONG: diff --git a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index b605c4af6..4059ca6b3 100644 --- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -903,6 +903,7 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt, case T_OBJECT: case T_ARRAY: case T_ADDRESS: + case T_METADATA: if (int_args < Argument::n_int_register_parameters_c) { regs[i].set2(INT_ArgReg[int_args++]->as_VMReg()); #ifdef _WIN64 diff --git a/src/share/vm/c1/c1_FrameMap.hpp b/src/share/vm/c1/c1_FrameMap.hpp index b1e186214..2847b3f50 100644 --- a/src/share/vm/c1/c1_FrameMap.hpp +++ b/src/share/vm/c1/c1_FrameMap.hpp @@ -194,6 +194,10 @@ class FrameMap : public CompilationResourceObj { return LIR_OprFact::single_cpu_oop(cpu_reg2rnr(r)); } + static LIR_Opr as_metadata_opr(Register r) { + return LIR_OprFact::single_cpu_metadata(cpu_reg2rnr(r)); + } + FrameMap(ciMethod* method, int monitors, int reserved_argument_area_size); bool finalize_frame(int nof_slots); diff --git a/src/share/vm/c1/c1_LIR.cpp b/src/share/vm/c1/c1_LIR.cpp index dd855deff..9bc7ab8ed 100644 --- a/src/share/vm/c1/c1_LIR.cpp +++ b/src/share/vm/c1/c1_LIR.cpp @@ -89,8 +89,12 @@ LIR_Opr LIR_OprFact::value_type(ValueType* type) { ClassConstant* c = type->as_ClassConstant(); if (c != NULL && !c->value()->is_loaded()) { return LIR_OprFact::metadataConst(NULL); - } else { + } else if (c != NULL) { return LIR_OprFact::metadataConst(c->value()->constant_encoding()); + } else { + MethodConstant* m = type->as_MethodConstant(); + assert (m != NULL, "not a class or a method?"); + return LIR_OprFact::metadataConst(m->value()->constant_encoding()); } } case objectTag : { @@ -1166,10 +1170,12 @@ void LIR_List::append(LIR_InsertionBuffer* buffer) { void LIR_List::oop2reg_patch(jobject o, LIR_Opr reg, CodeEmitInfo* info) { + assert(reg->type() == T_OBJECT, "bad reg"); append(new LIR_Op1(lir_move, LIR_OprFact::oopConst(o), reg, T_OBJECT, lir_patch_normal, info)); } void LIR_List::klass2reg_patch(Metadata* o, LIR_Opr reg, CodeEmitInfo* info) { + assert(reg->type() == T_METADATA, "bad reg"); append(new LIR_Op1(lir_move, LIR_OprFact::metadataConst(o), reg, T_METADATA, lir_patch_normal, info)); } diff --git a/src/share/vm/c1/c1_LIR.hpp b/src/share/vm/c1/c1_LIR.hpp index 41b7812d7..a79a8ace4 100644 --- a/src/share/vm/c1/c1_LIR.hpp +++ b/src/share/vm/c1/c1_LIR.hpp @@ -299,6 +299,7 @@ class LIR_OprDesc: public CompilationResourceObj { , address_type = 4 << type_shift , float_type = 5 << type_shift , double_type = 6 << type_shift + , metadata_type = 7 << type_shift }; friend OprType as_OprType(BasicType t); friend BasicType as_BasicType(OprType t); @@ -322,6 +323,7 @@ class LIR_OprDesc: public CompilationResourceObj { case T_ADDRESS: case T_OBJECT: case T_ARRAY: + case T_METADATA: return single_size; break; @@ -474,6 +476,7 @@ inline LIR_OprDesc::OprType as_OprType(BasicType type) { case T_OBJECT: case T_ARRAY: return LIR_OprDesc::object_type; case T_ADDRESS: return LIR_OprDesc::address_type; + case T_METADATA: return LIR_OprDesc::metadata_type; case T_ILLEGAL: // fall through default: ShouldNotReachHere(); return LIR_OprDesc::unknown_type; } @@ -487,6 +490,7 @@ inline BasicType as_BasicType(LIR_OprDesc::OprType t) { case LIR_OprDesc::double_type: return T_DOUBLE; case LIR_OprDesc::object_type: return T_OBJECT; case LIR_OprDesc::address_type: return T_ADDRESS; + case LIR_OprDesc::metadata_type:return T_METADATA; case LIR_OprDesc::unknown_type: // fall through default: ShouldNotReachHere(); return T_ILLEGAL; } @@ -587,6 +591,12 @@ class LIR_OprFact: public AllStatic { LIR_OprDesc::cpu_register | LIR_OprDesc::single_size); } + static LIR_Opr single_cpu_metadata(int reg) { + return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) | + LIR_OprDesc::metadata_type | + LIR_OprDesc::cpu_register | + LIR_OprDesc::single_size); + } static LIR_Opr double_cpu(int reg1, int reg2) { LP64_ONLY(assert(reg1 == reg2, "must be identical")); return (LIR_Opr)(intptr_t)((reg1 << LIR_OprDesc::reg1_shift) | @@ -660,6 +670,14 @@ class LIR_OprFact: public AllStatic { LIR_OprDesc::virtual_mask); break; + case T_METADATA: + res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) | + LIR_OprDesc::metadata_type| + LIR_OprDesc::cpu_register | + LIR_OprDesc::single_size | + LIR_OprDesc::virtual_mask); + break; + case T_INT: res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) | LIR_OprDesc::int_type | @@ -757,6 +775,12 @@ class LIR_OprFact: public AllStatic { LIR_OprDesc::single_size); break; + case T_METADATA: + res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) | + LIR_OprDesc::metadata_type | + LIR_OprDesc::stack_value | + LIR_OprDesc::single_size); + break; case T_INT: res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) | LIR_OprDesc::int_type | @@ -2006,10 +2030,10 @@ class LIR_List: public CompilationResourceObj { } void volatile_move(LIR_Opr src, LIR_Opr dst, BasicType type, CodeEmitInfo* info = NULL, LIR_PatchCode patch_code = lir_patch_none) { append(new LIR_Op1(lir_move, src, dst, type, patch_code, info, lir_move_volatile)); } - void oop2reg (jobject o, LIR_Opr reg) { append(new LIR_Op1(lir_move, LIR_OprFact::oopConst(o), reg)); } + void oop2reg (jobject o, LIR_Opr reg) { assert(reg->type() == T_OBJECT, "bad reg"); append(new LIR_Op1(lir_move, LIR_OprFact::oopConst(o), reg)); } void oop2reg_patch(jobject o, LIR_Opr reg, CodeEmitInfo* info); - void oop2reg (Metadata* o, LIR_Opr reg) { append(new LIR_Op1(lir_move, LIR_OprFact::metadataConst(o), reg)); } + void metadata2reg (Metadata* o, LIR_Opr reg) { assert(reg->type() == T_METADATA, "bad reg"); append(new LIR_Op1(lir_move, LIR_OprFact::metadataConst(o), reg)); } void klass2reg_patch(Metadata* o, LIR_Opr reg, CodeEmitInfo* info); void return_op(LIR_Opr result) { append(new LIR_Op1(lir_return, result)); } diff --git a/src/share/vm/c1/c1_LIRGenerator.cpp b/src/share/vm/c1/c1_LIRGenerator.cpp index 45fa9544d..bea8b93ce 100644 --- a/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/src/share/vm/c1/c1_LIRGenerator.cpp @@ -467,7 +467,7 @@ void LIRGenerator::klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitI __ klass2reg_patch(NULL, r, info); } else { // no patching needed - __ oop2reg(obj->constant_encoding(), r); + __ metadata2reg(obj->constant_encoding(), r); } } @@ -955,8 +955,8 @@ void LIRGenerator::profile_branch(If* if_instr, If::Condition cond) { not_taken_count_offset = t; } - LIR_Opr md_reg = new_register(T_OBJECT); - __ oop2reg(md->constant_encoding(), md_reg); + LIR_Opr md_reg = new_register(T_METADATA); + __ metadata2reg(md->constant_encoding(), md_reg); LIR_Opr data_offset_reg = new_pointer_register(); __ cmove(lir_cond(cond), @@ -1192,8 +1192,8 @@ void LIRGenerator::do_Return(Return* x) { signature.append(T_OBJECT); // Method* LIR_OprList* args = new LIR_OprList(); args->append(getThreadPointer()); - LIR_Opr meth = new_register(T_OBJECT); - __ oop2reg(method()->constant_encoding(), meth); + LIR_Opr meth = new_register(T_METADATA); + __ metadata2reg(method()->constant_encoding(), meth); args->append(meth); call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), voidType, NULL); } @@ -2553,8 +2553,8 @@ void LIRGenerator::do_Goto(Goto* x) { assert(data->is_JumpData(), "need JumpData for branches"); offset = md->byte_offset_of_slot(data, JumpData::taken_offset()); } - LIR_Opr md_reg = new_register(T_OBJECT); - __ oop2reg(md->constant_encoding(), md_reg); + LIR_Opr md_reg = new_register(T_METADATA); + __ metadata2reg(md->constant_encoding(), md_reg); increment_counter(new LIR_Address(md_reg, offset, NOT_LP64(T_INT) LP64_ONLY(T_LONG)), DataLayout::counter_increment); @@ -2611,8 +2611,8 @@ void LIRGenerator::do_Base(Base* x) { signature.append(T_OBJECT); // Method* LIR_OprList* args = new LIR_OprList(); args->append(getThreadPointer()); - LIR_Opr meth = new_register(T_OBJECT); - __ oop2reg(method()->constant_encoding(), meth); + LIR_Opr meth = new_register(T_METADATA); + __ metadata2reg(method()->constant_encoding(), meth); args->append(meth); call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), voidType, NULL); } @@ -3032,21 +3032,21 @@ void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info, assert(level > CompLevel_simple, "Shouldn't be here"); int offset = -1; - LIR_Opr counter_holder = new_register(T_OBJECT); + LIR_Opr counter_holder = new_register(T_METADATA); LIR_Opr meth; if (level == CompLevel_limited_profile) { offset = in_bytes(backedge ? Method::backedge_counter_offset() : Method::invocation_counter_offset()); - __ oop2reg(method->constant_encoding(), counter_holder); + __ metadata2reg(method->constant_encoding(), counter_holder); meth = counter_holder; } else if (level == CompLevel_full_profile) { offset = in_bytes(backedge ? MethodData::backedge_counter_offset() : MethodData::invocation_counter_offset()); ciMethodData* md = method->method_data_or_null(); assert(md != NULL, "Sanity"); - __ oop2reg(md->constant_encoding(), counter_holder); - meth = new_register(T_OBJECT); - __ oop2reg(method->constant_encoding(), meth); + __ metadata2reg(md->constant_encoding(), counter_holder); + meth = new_register(T_METADATA); + __ metadata2reg(method->constant_encoding(), meth); } else { ShouldNotReachHere(); } diff --git a/src/share/vm/c1/c1_LinearScan.cpp b/src/share/vm/c1/c1_LinearScan.cpp index bd4061ec7..fab4834a9 100644 --- a/src/share/vm/c1/c1_LinearScan.cpp +++ b/src/share/vm/c1/c1_LinearScan.cpp @@ -2067,6 +2067,12 @@ LIR_Opr LinearScan::calc_operand_for_interval(const Interval* interval) { return LIR_OprFact::single_cpu_address(assigned_reg); } + case T_METADATA: { + assert(assigned_reg >= pd_first_cpu_reg && assigned_reg <= pd_last_cpu_reg, "no cpu register"); + assert(interval->assigned_regHi() == any_reg, "must not have hi register"); + return LIR_OprFact::single_cpu_metadata(assigned_reg); + } + #ifdef __SOFTFP__ case T_FLOAT: // fall through #endif // __SOFTFP__ diff --git a/src/share/vm/c1/c1_ValueType.cpp b/src/share/vm/c1/c1_ValueType.cpp index 9a4def5ad..0aebd036a 100644 --- a/src/share/vm/c1/c1_ValueType.cpp +++ b/src/share/vm/c1/c1_ValueType.cpp @@ -168,6 +168,7 @@ BasicType as_BasicType(ValueType* type) { case floatTag: return T_FLOAT; case doubleTag: return T_DOUBLE; case objectTag: return T_OBJECT; + case metaDataTag:return T_METADATA; case addressTag: return T_ADDRESS; case illegalTag: return T_ILLEGAL; } diff --git a/src/share/vm/opto/runtime.cpp b/src/share/vm/opto/runtime.cpp index f6364a7b7..e33c042e1 100644 --- a/src/share/vm/opto/runtime.cpp +++ b/src/share/vm/opto/runtime.cpp @@ -1148,7 +1148,7 @@ const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage - fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // Method*; Method we are entering + fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); // create result type (range) diff --git a/src/share/vm/utilities/globalDefinitions.cpp b/src/share/vm/utilities/globalDefinitions.cpp index df459580f..cfec229ee 100644 --- a/src/share/vm/utilities/globalDefinitions.cpp +++ b/src/share/vm/utilities/globalDefinitions.cpp @@ -213,7 +213,7 @@ BasicType name2type(const char* name) { // Map BasicType to size in words -int type2size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, 1, -1}; +int type2size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, -1}; BasicType type2field[T_CONFLICT+1] = { (BasicType)0, // 0, -- GitLab