From 3271921ebd312825662525d238aaebcbe39a7959 Mon Sep 17 00:00:00 2001 From: twisti Date: Mon, 11 Oct 2010 04:18:58 -0700 Subject: [PATCH] 6829194: JSR 292 needs to support compressed oops Reviewed-by: kvn, jrose --- src/cpu/sparc/vm/assembler_sparc.cpp | 20 ++++--- src/cpu/sparc/vm/assembler_sparc.hpp | 3 +- src/cpu/sparc/vm/methodHandles_sparc.cpp | 35 ++++++----- src/cpu/sparc/vm/stubRoutines_sparc.hpp | 2 +- src/cpu/sparc/vm/templateTable_sparc.cpp | 2 +- src/cpu/x86/vm/assembler_x86.cpp | 51 +++++++++------- src/cpu/x86/vm/assembler_x86.hpp | 16 ++--- src/cpu/x86/vm/methodHandles_x86.cpp | 68 ++++++++++------------ src/cpu/x86/vm/stubRoutines_x86_64.hpp | 2 +- src/cpu/x86/vm/templateTable_x86_32.cpp | 11 ++-- src/cpu/x86/vm/templateTable_x86_64.cpp | 10 ++-- src/share/vm/asm/codeBuffer.hpp | 4 +- src/share/vm/ci/ciInstanceKlass.cpp | 2 +- src/share/vm/ci/ciTypeFlow.cpp | 2 +- src/share/vm/classfile/classFileParser.cpp | 10 ++-- src/share/vm/oops/oop.inline.hpp | 2 +- 16 files changed, 127 insertions(+), 113 deletions(-) diff --git a/src/cpu/sparc/vm/assembler_sparc.cpp b/src/cpu/sparc/vm/assembler_sparc.cpp index e84e92a41..a677b20df 100644 --- a/src/cpu/sparc/vm/assembler_sparc.cpp +++ b/src/cpu/sparc/vm/assembler_sparc.cpp @@ -3094,11 +3094,10 @@ void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg, Register temp_reg, Label& wrong_method_type) { - if (UseCompressedOops) unimplemented("coop"); // field accesses must decode assert_different_registers(mtype_reg, mh_reg, temp_reg); // compare method type against that of the receiver RegisterOrConstant mhtype_offset = delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg); - ld_ptr(mh_reg, mhtype_offset, temp_reg); + load_heap_oop(mh_reg, mhtype_offset, temp_reg); cmp(temp_reg, mtype_reg); br(Assembler::notEqual, false, Assembler::pn, wrong_method_type); delayed()->nop(); @@ -3112,16 +3111,15 @@ void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_re void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register mh_reg, Register temp_reg) { assert_different_registers(vmslots_reg, mh_reg, temp_reg); - if (UseCompressedOops) unimplemented("coop"); // field accesses must decode // load mh.type.form.vmslots if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) { // hoist vmslots into every mh to avoid dependent load chain - ld( Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); + ld( Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); } else { Register temp2_reg = vmslots_reg; - ld_ptr(Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)), temp2_reg); - ld_ptr(Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)), temp2_reg); - ld( Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); + load_heap_oop(Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)), temp2_reg); + load_heap_oop(Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)), temp2_reg); + ld( Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg); } } @@ -3130,9 +3128,8 @@ void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_ assert(mh_reg == G3_method_handle, "caller must put MH object in G3"); assert_different_registers(mh_reg, temp_reg); - if (UseCompressedOops) unimplemented("coop"); // field accesses must decode - // pick out the interpreted side of the handler + // NOTE: vmentry is not an oop! ld_ptr(mh_reg, delayed_value(java_dyn_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg); // off we go... @@ -4653,6 +4650,11 @@ void MacroAssembler::load_heap_oop(Register s1, int simm13a, Register d) { } } +void MacroAssembler::load_heap_oop(Register s1, RegisterOrConstant s2, Register d) { + if (s2.is_constant()) load_heap_oop(s1, s2.as_constant(), d); + else load_heap_oop(s1, s2.as_register(), d); +} + void MacroAssembler::store_heap_oop(Register d, Register s1, Register s2) { if (UseCompressedOops) { assert(s1 != d && s2 != d, "not enough registers"); diff --git a/src/cpu/sparc/vm/assembler_sparc.hpp b/src/cpu/sparc/vm/assembler_sparc.hpp index 4592ed81f..7d56342c5 100644 --- a/src/cpu/sparc/vm/assembler_sparc.hpp +++ b/src/cpu/sparc/vm/assembler_sparc.hpp @@ -2103,6 +2103,7 @@ public: void load_heap_oop(const Address& s, Register d); void load_heap_oop(Register s1, Register s2, Register d); void load_heap_oop(Register s1, int simm13a, Register d); + void load_heap_oop(Register s1, RegisterOrConstant s2, Register d); void store_heap_oop(Register d, Register s1, Register s2); void store_heap_oop(Register d, Register s1, int simm13a); void store_heap_oop(Register d, const Address& a, int offset = 0); @@ -2225,7 +2226,7 @@ public: void stop(const char* msg); // prints msg, dumps registers and stops execution void warn(const char* msg); // prints msg, but don't stop void untested(const char* what = ""); - void unimplemented(const char* what = "") { char* b = new char[1024]; sprintf(b, "unimplemented: %s", what); stop(b); } + void unimplemented(const char* what = "") { char* b = new char[1024]; jio_snprintf(b, 1024, "unimplemented: %s", what); stop(b); } void should_not_reach_here() { stop("should not reach here"); } void print_CPU_state(); diff --git a/src/cpu/sparc/vm/methodHandles_sparc.cpp b/src/cpu/sparc/vm/methodHandles_sparc.cpp index 887bfd63e..94cc62217 100644 --- a/src/cpu/sparc/vm/methodHandles_sparc.cpp +++ b/src/cpu/sparc/vm/methodHandles_sparc.cpp @@ -90,8 +90,8 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* } // given the MethodType, find out where the MH argument is buried - __ ld_ptr(Address(G5_method_type, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, O1_scratch)), O0_argslot); - __ ldsw( Address(O0_argslot, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O0_argslot); + __ load_heap_oop(Address(G5_method_type, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, O1_scratch)), O0_argslot); + __ ldsw( Address(O0_argslot, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O0_argslot); __ ld_ptr(__ argument_address(O0_argslot), G3_method_handle); __ check_method_handle_type(G5_method_type, G3_method_handle, O1_scratch, wrong_method_type); @@ -348,7 +348,6 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan } address interp_entry = __ pc(); - if (UseCompressedOops) __ unimplemented("UseCompressedOops"); #ifndef PRODUCT if (TraceMethodHandles) { @@ -413,7 +412,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan case _invokestatic_mh: case _invokespecial_mh: { - __ ld_ptr(G3_mh_vmtarget, G5_method); // target is a methodOop + __ load_heap_oop(G3_mh_vmtarget, G5_method); // target is a methodOop __ verify_oop(G5_method); // Same as TemplateTable::invokestatic or invokespecial, // minus the CP setup and profiling: @@ -468,7 +467,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan // minus the CP setup and profiling: __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch); Register O1_intf = O1_scratch; - __ ld_ptr(G3_mh_vmtarget, O1_intf); + __ load_heap_oop(G3_mh_vmtarget, O1_intf); __ ldsw(G3_dmh_vmindex, G5_index); __ ld_ptr(__ argument_address(O0_argslot, -1), G3_method_handle); __ null_check(G3_method_handle, oopDesc::klass_offset_in_bytes()); @@ -523,7 +522,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, O0_argslot, O1_scratch, O2_scratch, G5_index); // Store bound argument into the new stack slot: - __ ld_ptr(G3_bmh_argument, O1_scratch); + __ load_heap_oop(G3_bmh_argument, O1_scratch); if (arg_type == T_OBJECT) { __ st_ptr(O1_scratch, Address(O0_argslot, 0)); } else { @@ -541,12 +540,12 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan } if (direct_to_method) { - __ ld_ptr(G3_mh_vmtarget, G5_method); // target is a methodOop + __ load_heap_oop(G3_mh_vmtarget, G5_method); // target is a methodOop __ verify_oop(G5_method); __ jump_indirect_to(G5_method_fie, O1_scratch); __ delayed()->nop(); } else { - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); // target is a methodOop + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); // target is a methodOop __ verify_oop(G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); } @@ -556,7 +555,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan case _adapter_retype_only: case _adapter_retype_raw: // Immediately jump to the next MH layer: - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); // This is OK when all parameter types widen. // It is also OK when a return type narrows. @@ -572,8 +571,8 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan Address vmarg = __ argument_address(O0_argslot); // What class are we casting to? - __ ld_ptr(G3_amh_argument, G5_klass); // This is a Class object! - __ ld_ptr(Address(G5_klass, java_lang_Class::klass_offset_in_bytes()), G5_klass); + __ load_heap_oop(G3_amh_argument, G5_klass); // This is a Class object! + __ load_heap_oop(Address(G5_klass, java_lang_Class::klass_offset_in_bytes()), G5_klass); Label done; __ ld_ptr(vmarg, O1_scratch); @@ -590,14 +589,14 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan // If we get here, the type check failed! __ ldsw(G3_amh_vmargslot, O0_argslot); // reload argslot field - __ ld_ptr(G3_amh_argument, O3_scratch); // required class + __ load_heap_oop(G3_amh_argument, O3_scratch); // required class __ ld_ptr(vmarg, O2_scratch); // bad object __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O0_argslot); __ delayed()->mov(Bytecodes::_checkcast, O1_scratch); // who is complaining? __ bind(done); // Get the new MH: - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); } break; @@ -676,7 +675,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ st(O1_scratch, vmarg); // Get the new MH: - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); } break; @@ -721,7 +720,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan ShouldNotReachHere(); } - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); } break; @@ -851,7 +850,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan } } - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); } break; @@ -895,7 +894,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ brx(Assembler::less, false, Assembler::pt, loop); __ delayed()->nop(); // FILLME - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); } break; @@ -913,7 +912,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan remove_arg_slots(_masm, G5_stack_move, O0_argslot, O1_scratch, O2_scratch, O3_scratch); - __ ld_ptr(G3_mh_vmtarget, G3_method_handle); + __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); __ jump_to_method_handle_entry(G3_method_handle, O1_scratch); } break; diff --git a/src/cpu/sparc/vm/stubRoutines_sparc.hpp b/src/cpu/sparc/vm/stubRoutines_sparc.hpp index e02789d25..d56655b3e 100644 --- a/src/cpu/sparc/vm/stubRoutines_sparc.hpp +++ b/src/cpu/sparc/vm/stubRoutines_sparc.hpp @@ -43,7 +43,7 @@ enum /* platform_dependent_constants */ { // MethodHandles adapters enum method_handles_platform_dependent_constants { - method_handles_adapters_code_size = 12000 + method_handles_adapters_code_size = 15000 }; class Sparc { diff --git a/src/cpu/sparc/vm/templateTable_sparc.cpp b/src/cpu/sparc/vm/templateTable_sparc.cpp index b144985f1..756cd6ca5 100644 --- a/src/cpu/sparc/vm/templateTable_sparc.cpp +++ b/src/cpu/sparc/vm/templateTable_sparc.cpp @@ -3273,7 +3273,7 @@ void TemplateTable::invokedynamic(int byte_no) { __ sll(Rret, LogBytesPerWord, Rret); __ ld_ptr(Rtemp, Rret, Rret); // get return address - __ ld_ptr(G5_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, Rscratch), G3_method_handle); + __ load_heap_oop(G5_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, Rscratch), G3_method_handle); __ null_check(G3_method_handle); // Adjust Rret first so Llast_SP can be same as Rret diff --git a/src/cpu/x86/vm/assembler_x86.cpp b/src/cpu/x86/vm/assembler_x86.cpp index 4f43327d3..c9794d4c6 100644 --- a/src/cpu/x86/vm/assembler_x86.cpp +++ b/src/cpu/x86/vm/assembler_x86.cpp @@ -7709,9 +7709,14 @@ RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_ad void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg, Register temp_reg, Label& wrong_method_type) { - if (UseCompressedOops) unimplemented(); // field accesses must decode + Address type_addr(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)); // compare method type against that of the receiver - cmpptr(mtype_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg))); + if (UseCompressedOops) { + load_heap_oop(temp_reg, type_addr); + cmpptr(mtype_reg, temp_reg); + } else { + cmpptr(mtype_reg, type_addr); + } jcc(Assembler::notEqual, wrong_method_type); } @@ -7723,15 +7728,14 @@ void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_re void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register mh_reg, Register temp_reg) { assert_different_registers(vmslots_reg, mh_reg, temp_reg); - if (UseCompressedOops) unimplemented(); // field accesses must decode // load mh.type.form.vmslots if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) { // hoist vmslots into every mh to avoid dependent load chain movl(vmslots_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg))); } else { Register temp2_reg = vmslots_reg; - movptr(temp2_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg))); - movptr(temp2_reg, Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg))); + load_heap_oop(temp2_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg))); + load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg))); movl(vmslots_reg, Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg))); } } @@ -7745,9 +7749,8 @@ void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_ assert(mh_reg == rcx, "caller must put MH object in rcx"); assert_different_registers(mh_reg, temp_reg); - if (UseCompressedOops) unimplemented(); // field accesses must decode - // pick out the interpreted side of the handler + // NOTE: vmentry is not an oop! movptr(temp_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmentry_offset_in_bytes, temp_reg))); // off we go... @@ -8238,40 +8241,46 @@ void MacroAssembler::store_klass(Register dst, Register src) { movptr(Address(dst, oopDesc::klass_offset_in_bytes()), src); } -#ifdef _LP64 -void MacroAssembler::store_klass_gap(Register dst, Register src) { - if (UseCompressedOops) { - // Store to klass gap in destination - movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src); - } -} - void MacroAssembler::load_heap_oop(Register dst, Address src) { +#ifdef _LP64 if (UseCompressedOops) { movl(dst, src); decode_heap_oop(dst); - } else { - movq(dst, src); - } + } else +#endif + movptr(dst, src); } void MacroAssembler::store_heap_oop(Address dst, Register src) { +#ifdef _LP64 if (UseCompressedOops) { assert(!dst.uses(src), "not enough registers"); encode_heap_oop(src); movl(dst, src); - } else { - movq(dst, src); - } + } else +#endif + movptr(dst, src); } // Used for storing NULLs. void MacroAssembler::store_heap_oop_null(Address dst) { +#ifdef _LP64 if (UseCompressedOops) { movl(dst, (int32_t)NULL_WORD); } else { movslq(dst, (int32_t)NULL_WORD); } +#else + movl(dst, (int32_t)NULL_WORD); +#endif +} + +#ifdef _LP64 +void MacroAssembler::store_klass_gap(Register dst, Register src) { + if (UseCompressedOops) { + // Store to klass gap in destination + movl(Address(dst, oopDesc::klass_gap_offset_in_bytes()), src); + } } #ifdef ASSERT diff --git a/src/cpu/x86/vm/assembler_x86.hpp b/src/cpu/x86/vm/assembler_x86.hpp index c9b25e02f..88d082e5d 100644 --- a/src/cpu/x86/vm/assembler_x86.hpp +++ b/src/cpu/x86/vm/assembler_x86.hpp @@ -1682,24 +1682,24 @@ class MacroAssembler: public Assembler { void load_klass(Register dst, Register src); void store_klass(Register dst, Register src); + void load_heap_oop(Register dst, Address src); + void store_heap_oop(Address dst, Register src); + + // Used for storing NULL. All other oop constants should be + // stored using routines that take a jobject. + void store_heap_oop_null(Address dst); + void load_prototype_header(Register dst, Register src); #ifdef _LP64 void store_klass_gap(Register dst, Register src); - void load_heap_oop(Register dst, Address src); - void store_heap_oop(Address dst, Register src); - // This dummy is to prevent a call to store_heap_oop from // converting a zero (like NULL) into a Register by giving // the compiler two choices it can't resolve void store_heap_oop(Address dst, void* dummy); - // Used for storing NULL. All other oop constants should be - // stored using routines that take a jobject. - void store_heap_oop_null(Address dst); - void encode_heap_oop(Register r); void decode_heap_oop(Register r); void encode_heap_oop_not_null(Register r); @@ -1927,7 +1927,7 @@ class MacroAssembler: public Assembler { void untested() { stop("untested"); } - void unimplemented(const char* what = "") { char* b = new char[1024]; jio_snprintf(b, sizeof(b), "unimplemented: %s", what); stop(b); } + void unimplemented(const char* what = "") { char* b = new char[1024]; jio_snprintf(b, 1024, "unimplemented: %s", what); stop(b); } void should_not_reach_here() { stop("should not reach here"); } diff --git a/src/cpu/x86/vm/methodHandles_x86.cpp b/src/cpu/x86/vm/methodHandles_x86.cpp index 2343fbf2f..0a65e5a29 100644 --- a/src/cpu/x86/vm/methodHandles_x86.cpp +++ b/src/cpu/x86/vm/methodHandles_x86.cpp @@ -123,11 +123,9 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* } // given the MethodType, find out where the MH argument is buried - __ movptr(rdx_temp, Address(rax_mtype, - __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rdi_temp))); + __ load_heap_oop(rdx_temp, Address(rax_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rdi_temp))); Register rdx_vmslots = rdx_temp; - __ movl(rdx_vmslots, Address(rdx_temp, - __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, rdi_temp))); + __ movl(rdx_vmslots, Address(rdx_temp, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, rdi_temp))); __ movptr(rcx_recv, __ argument_address(rdx_vmslots)); trace_method_handle(_masm, "invokeExact"); @@ -154,20 +152,18 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* rcx_argslot, rbx_temp, rdx_temp); // load up an adapter from the calling type (Java weaves this) - __ movptr(rdx_temp, Address(rax_mtype, - __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rdi_temp))); + __ load_heap_oop(rdx_temp, Address(rax_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rdi_temp))); Register rdx_adapter = rdx_temp; - // movptr(rdx_adapter, Address(rdx_temp, java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes())); + // __ load_heap_oop(rdx_adapter, Address(rdx_temp, java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes())); // deal with old JDK versions: - __ lea(rdi_temp, Address(rdx_temp, - __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, rdi_temp))); + __ lea(rdi_temp, Address(rdx_temp, __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, rdi_temp))); __ cmpptr(rdi_temp, rdx_temp); Label sorry_no_invoke_generic; - __ jccb(Assembler::below, sorry_no_invoke_generic); + __ jcc(Assembler::below, sorry_no_invoke_generic); - __ movptr(rdx_adapter, Address(rdi_temp, 0)); + __ load_heap_oop(rdx_adapter, Address(rdi_temp, 0)); __ testptr(rdx_adapter, rdx_adapter); - __ jccb(Assembler::zero, sorry_no_invoke_generic); + __ jcc(Assembler::zero, sorry_no_invoke_generic); __ movptr(Address(rcx_argslot, 1 * Interpreter::stackElementSize), rdx_adapter); // As a trusted first argument, pass the type being called, so the adapter knows // the actual types of the arguments and return values. @@ -431,7 +427,6 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan } address interp_entry = __ pc(); - if (UseCompressedOops) __ unimplemented("UseCompressedOops"); trace_method_handle(_masm, entry_name(ek)); @@ -489,7 +484,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan case _invokespecial_mh: { Register rbx_method = rbx_temp; - __ movptr(rbx_method, rcx_mh_vmtarget); // target is a methodOop + __ load_heap_oop(rbx_method, rcx_mh_vmtarget); // target is a methodOop __ verify_oop(rbx_method); // same as TemplateTable::invokestatic or invokespecial, // minus the CP setup and profiling: @@ -546,8 +541,8 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ load_method_handle_vmslots(rax_argslot, rcx_recv, rdx_temp); Register rdx_intf = rdx_temp; Register rbx_index = rbx_temp; - __ movptr(rdx_intf, rcx_mh_vmtarget); - __ movl(rbx_index, rcx_dmh_vmindex); + __ load_heap_oop(rdx_intf, rcx_mh_vmtarget); + __ movl(rbx_index, rcx_dmh_vmindex); __ movptr(rcx_recv, __ argument_address(rax_argslot, -1)); __ null_check(rcx_recv, oopDesc::klass_offset_in_bytes()); @@ -602,7 +597,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan rax_argslot, rbx_temp, rdx_temp); // store bound argument into the new stack slot: - __ movptr(rbx_temp, rcx_bmh_argument); + __ load_heap_oop(rbx_temp, rcx_bmh_argument); Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type)); if (arg_type == T_OBJECT) { __ movptr(Address(rax_argslot, 0), rbx_temp); @@ -620,11 +615,11 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan if (direct_to_method) { Register rbx_method = rbx_temp; - __ movptr(rbx_method, rcx_mh_vmtarget); + __ load_heap_oop(rbx_method, rcx_mh_vmtarget); __ verify_oop(rbx_method); __ jmp(rbx_method_fie); } else { - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ verify_oop(rcx_recv); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } @@ -634,7 +629,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan case _adapter_retype_only: case _adapter_retype_raw: // immediately jump to the next MH layer: - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ verify_oop(rcx_recv); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); // This is OK when all parameter types widen. @@ -651,13 +646,13 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan vmarg = __ argument_address(rax_argslot); // What class are we casting to? - __ movptr(rbx_klass, rcx_amh_argument); // this is a Class object! - __ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes())); + __ load_heap_oop(rbx_klass, rcx_amh_argument); // this is a Class object! + __ load_heap_oop(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes())); Label done; __ movptr(rdx_temp, vmarg); __ testptr(rdx_temp, rdx_temp); - __ jccb(Assembler::zero, done); // no cast if null + __ jcc(Assembler::zero, done); // no cast if null __ load_klass(rdx_temp, rdx_temp); // live at this point: @@ -672,14 +667,15 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ movl(rax_argslot, rcx_amh_vmargslot); // reload argslot field __ movptr(rdx_temp, vmarg); - __ pushptr(rcx_amh_argument); // required class - __ push(rdx_temp); // bad object - __ push((int)Bytecodes::_checkcast); // who is complaining? + __ load_heap_oop(rbx_klass, rcx_amh_argument); // required class + __ push(rbx_klass); + __ push(rdx_temp); // bad object + __ push((int)Bytecodes::_checkcast); // who is complaining? __ jump(ExternalAddress(from_interpreted_entry(_raise_exception))); __ bind(done); // get the new MH: - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } break; @@ -741,7 +737,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan assert(CONV_VMINFO_SHIFT == 0, "preshifted"); // get the new MH: - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); // (now we are done with the old MH) // original 32-bit vmdata word must be of this form: @@ -816,7 +812,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan ShouldNotReachHere(); } - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } break; @@ -858,7 +854,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan rax_argslot, rbx_temp, rdx_temp); } - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } break; @@ -969,7 +965,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan } } - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } break; @@ -1029,7 +1025,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ pop(rdi); // restore temp - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } break; @@ -1052,7 +1048,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ pop(rdi); // restore temp - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); } break; @@ -1103,8 +1099,8 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan // Check the array type. Register rbx_klass = rbx_temp; - __ movptr(rbx_klass, rcx_amh_argument); // this is a Class object! - __ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes())); + __ load_heap_oop(rbx_klass, rcx_amh_argument); // this is a Class object! + __ load_heap_oop(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes())); Label ok_array_klass, bad_array_klass, bad_array_length; __ check_klass_subtype(rdx_array_klass, rbx_klass, rdi, ok_array_klass); @@ -1186,7 +1182,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan // Arguments are spread. Move to next method handle. UNPUSH_RSI_RDI; - __ movptr(rcx_recv, rcx_mh_vmtarget); + __ load_heap_oop(rcx_recv, rcx_mh_vmtarget); __ jump_to_method_handle_entry(rcx_recv, rdx_temp); __ bind(bad_array_klass); diff --git a/src/cpu/x86/vm/stubRoutines_x86_64.hpp b/src/cpu/x86/vm/stubRoutines_x86_64.hpp index 393d868d9..71a411512 100644 --- a/src/cpu/x86/vm/stubRoutines_x86_64.hpp +++ b/src/cpu/x86/vm/stubRoutines_x86_64.hpp @@ -35,7 +35,7 @@ enum platform_dependent_constants { // MethodHandles adapters enum method_handles_platform_dependent_constants { - method_handles_adapters_code_size = 26000 + method_handles_adapters_code_size = 40000 }; class x86 { diff --git a/src/cpu/x86/vm/templateTable_x86_32.cpp b/src/cpu/x86/vm/templateTable_x86_32.cpp index 5da242409..e8417de1f 100644 --- a/src/cpu/x86/vm/templateTable_x86_32.cpp +++ b/src/cpu/x86/vm/templateTable_x86_32.cpp @@ -3111,19 +3111,22 @@ void TemplateTable::invokedynamic(int byte_no) { // rax: CallSite object (f1) // rbx: unused (f2) + // rcx: receiver address // rdx: flags (unused) + Register rax_callsite = rax; + Register rcx_method_handle = rcx; + if (ProfileInterpreter) { - Label L; // %%% should make a type profile for any invokedynamic that takes a ref argument // profile this call __ profile_call(rsi); } - __ movptr(rcx, Address(rax, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, rcx))); - __ null_check(rcx); + __ movptr(rcx_method_handle, Address(rax_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, rcx))); + __ null_check(rcx_method_handle); __ prepare_to_jump_from_interpreted(); - __ jump_to_method_handle_entry(rcx, rdx); + __ jump_to_method_handle_entry(rcx_method_handle, rdx); } //---------------------------------------------------------------------------------------------------- diff --git a/src/cpu/x86/vm/templateTable_x86_64.cpp b/src/cpu/x86/vm/templateTable_x86_64.cpp index 4f46e9f80..c2ec71c57 100644 --- a/src/cpu/x86/vm/templateTable_x86_64.cpp +++ b/src/cpu/x86/vm/templateTable_x86_64.cpp @@ -3120,17 +3120,19 @@ void TemplateTable::invokedynamic(int byte_no) { // rcx: receiver address // rdx: flags (unused) + Register rax_callsite = rax; + Register rcx_method_handle = rcx; + if (ProfileInterpreter) { - Label L; // %%% should make a type profile for any invokedynamic that takes a ref argument // profile this call __ profile_call(r13); } - __ movptr(rcx, Address(rax, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, rcx))); - __ null_check(rcx); + __ load_heap_oop(rcx_method_handle, Address(rax_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, rcx))); + __ null_check(rcx_method_handle); __ prepare_to_jump_from_interpreted(); - __ jump_to_method_handle_entry(rcx, rdx); + __ jump_to_method_handle_entry(rcx_method_handle, rdx); } diff --git a/src/share/vm/asm/codeBuffer.hpp b/src/share/vm/asm/codeBuffer.hpp index 16880dcfa..da38c19e4 100644 --- a/src/share/vm/asm/codeBuffer.hpp +++ b/src/share/vm/asm/codeBuffer.hpp @@ -168,8 +168,8 @@ class CodeSection VALUE_OBJ_CLASS_SPEC { bool allocates(address pc) const { return pc >= _start && pc < _limit; } bool allocates2(address pc) const { return pc >= _start && pc <= _limit; } - void set_end(address pc) { assert(allocates2(pc),""); _end = pc; } - void set_mark(address pc) { assert(contains2(pc),"not in codeBuffer"); + void set_end(address pc) { assert(allocates2(pc), err_msg("not in CodeBuffer memory: " PTR_FORMAT " <= " PTR_FORMAT " <= " PTR_FORMAT, _start, pc, _limit)); _end = pc; } + void set_mark(address pc) { assert(contains2(pc), "not in codeBuffer"); _mark = pc; } void set_mark_off(int offset) { assert(contains2(offset+_start),"not in codeBuffer"); _mark = offset + _start; } diff --git a/src/share/vm/ci/ciInstanceKlass.cpp b/src/share/vm/ci/ciInstanceKlass.cpp index cd75fd524..8ad5bf91d 100644 --- a/src/share/vm/ci/ciInstanceKlass.cpp +++ b/src/share/vm/ci/ciInstanceKlass.cpp @@ -471,7 +471,7 @@ int ciInstanceKlass::compute_nonstatic_fields() { ciField* field = fields->at(i); int offset = field->offset_in_bytes(); int size = (field->_type == NULL) ? heapOopSize : field->size_in_bytes(); - assert(last_offset <= offset, "no field overlap"); + assert(last_offset <= offset, err_msg("no field overlap: %d <= %d", last_offset, offset)); if (last_offset > (int)sizeof(oopDesc)) assert((offset - last_offset) < BytesPerLong, "no big holes"); // Note: Two consecutive T_BYTE fields will be separated by wordSize-1 diff --git a/src/share/vm/ci/ciTypeFlow.cpp b/src/share/vm/ci/ciTypeFlow.cpp index 3071856b9..6a3390c45 100644 --- a/src/share/vm/ci/ciTypeFlow.cpp +++ b/src/share/vm/ci/ciTypeFlow.cpp @@ -1945,7 +1945,7 @@ ciTypeFlow::ciTypeFlow(ciEnv* env, ciMethod* method, int osr_bci) { _has_irreducible_entry = false; _osr_bci = osr_bci; _failure_reason = NULL; - assert(start_bci() >= 0 && start_bci() < code_size() , "correct osr_bci argument"); + assert(0 <= start_bci() && start_bci() < code_size() , err_msg("correct osr_bci argument: 0 <= %d < %d", start_bci(), code_size())); _work_list = NULL; _ciblock_count = _methodBlocks->num_blocks(); diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp index 36085a754..01c6bb9b2 100644 --- a/src/share/vm/classfile/classFileParser.cpp +++ b/src/share/vm/classfile/classFileParser.cpp @@ -2702,13 +2702,15 @@ void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp, // Adjust the field type from byte to an unmanaged pointer. assert(fac_ptr->nonstatic_byte_count > 0, ""); fac_ptr->nonstatic_byte_count -= 1; - (*fields_ptr)->ushort_at_put(i + instanceKlass::signature_index_offset, - word_sig_index); - fac_ptr->nonstatic_word_count += 1; + + (*fields_ptr)->ushort_at_put(i + instanceKlass::signature_index_offset, word_sig_index); + if (UseCompressedOops) fac_ptr->nonstatic_double_count += 1; + else fac_ptr->nonstatic_word_count += 1; FieldAllocationType atype = (FieldAllocationType) (*fields_ptr)->ushort_at(i + instanceKlass::low_offset); assert(atype == NONSTATIC_BYTE, ""); - FieldAllocationType new_atype = NONSTATIC_WORD; + FieldAllocationType new_atype = (wordSize == longSize) ? NONSTATIC_DOUBLE : NONSTATIC_WORD; + assert(wordSize == longSize || wordSize == jintSize, "ILP32 or LP64"); (*fields_ptr)->ushort_at_put(i + instanceKlass::low_offset, new_atype); found_vmentry = true; diff --git a/src/share/vm/oops/oop.inline.hpp b/src/share/vm/oops/oop.inline.hpp index c840f46f9..dc3245d58 100644 --- a/src/share/vm/oops/oop.inline.hpp +++ b/src/share/vm/oops/oop.inline.hpp @@ -173,7 +173,7 @@ inline oop oopDesc::decode_heap_oop_not_null(narrowOop v) { address base = Universe::narrow_oop_base(); int shift = Universe::narrow_oop_shift(); oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift)); - assert(check_obj_alignment(result), "Address not aligned"); + assert(check_obj_alignment(result), err_msg("address not aligned: " PTR_FORMAT, (void*) result)); return result; } -- GitLab