Skip to content
Permalink
Browse files

8245289: Clean up offset code in JavaClasses

Make offset member names consistent and private, move static initializations near owning classes

Reviewed-by: fparain, lfoltan
  • Loading branch information
Coleen Phillimore
Coleen Phillimore committed May 29, 2020
1 parent e639c9a commit 5314d28f8412e9c993880884a3b626f05b590743
Showing with 789 additions and 843 deletions.
  1. +10 −10 src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp
  2. +2 −3 src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp
  3. +2 −2 src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp
  4. +11 −13 src/hotspot/cpu/arm/methodHandles_arm.cpp
  5. +1 −2 src/hotspot/cpu/arm/templateInterpreterGenerator_arm.cpp
  6. +2 −2 src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp
  7. +15 −17 src/hotspot/cpu/ppc/methodHandles_ppc.cpp
  8. +2 −3 src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
  9. +2 −2 src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp
  10. +11 −13 src/hotspot/cpu/s390/methodHandles_s390.cpp
  11. +2 −3 src/hotspot/cpu/s390/templateInterpreterGenerator_s390.cpp
  12. +2 −2 src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp
  13. +11 −13 src/hotspot/cpu/x86/methodHandles_x86.cpp
  14. +2 −3 src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp
  15. +3 −4 src/hotspot/share/c1/c1_LIRGenerator.cpp
  16. +4 −4 src/hotspot/share/ci/ciField.cpp
  17. +1 −1 src/hotspot/share/ci/ciInstanceKlass.cpp
  18. +509 −530 src/hotspot/share/classfile/javaClasses.cpp
  19. +128 −139 src/hotspot/share/classfile/javaClasses.hpp
  20. +22 −29 src/hotspot/share/classfile/javaClasses.inline.hpp
  21. +3 −3 src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp
  22. +5 −5 src/hotspot/share/gc/shared/c1/barrierSetC1.cpp
  23. +3 −3 src/hotspot/share/gc/shared/referenceProcessor.cpp
  24. +2 −2 src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
  25. +1 −1 src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
  26. +3 −3 src/hotspot/share/gc/z/zBarrier.inline.hpp
  27. +1 −1 src/hotspot/share/interpreter/interpreterRuntime.cpp
  28. +1 −1 src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
  29. +1 −1 src/hotspot/share/oops/instanceKlass.cpp
  30. +6 −6 src/hotspot/share/oops/instanceRefKlass.cpp
  31. +1 −1 src/hotspot/share/opto/compile.cpp
  32. +5 −5 src/hotspot/share/opto/graphKit.cpp
  33. +5 −6 src/hotspot/share/opto/library_call.cpp
  34. +5 −5 src/hotspot/share/opto/memnode.cpp
  35. +3 −3 src/hotspot/share/opto/stringopts.cpp
  36. +2 −2 src/hotspot/share/opto/type.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -47,7 +47,7 @@ void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_
if (VerifyMethodHandles)
verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
"MH argument is a Class");
__ ldr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset_in_bytes()));
__ ldr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset()));
}

#ifdef ASSERT
@@ -135,13 +135,13 @@ void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,

// Load the invoker, as MH -> MH.form -> LF.vmentry
__ verify_oop(recv);
__ load_heap_oop(method_temp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes())), temp2);
__ load_heap_oop(method_temp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset())), temp2);
__ verify_oop(method_temp);
__ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes())), temp2);
__ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset())), temp2);
__ verify_oop(method_temp);
__ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes())), temp2);
__ load_heap_oop(method_temp, Address(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset())), temp2);
__ verify_oop(method_temp);
__ access_load_at(T_ADDRESS, IN_HEAP, method_temp, Address(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes())), noreg, noreg);
__ access_load_at(T_ADDRESS, IN_HEAP, method_temp, Address(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset())), noreg, noreg);

if (VerifyMethodHandles && !for_compiler_entry) {
// make sure recv is already on stack
@@ -283,10 +283,10 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
"MemberName required for invokeVirtual etc.");
}

Address member_clazz( member_reg, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()));
Address member_vmindex( member_reg, NONZERO(java_lang_invoke_MemberName::vmindex_offset_in_bytes()));
Address member_vmtarget( member_reg, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes()));
Address vmtarget_method( rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes()));
Address member_clazz( member_reg, NONZERO(java_lang_invoke_MemberName::clazz_offset()));
Address member_vmindex( member_reg, NONZERO(java_lang_invoke_MemberName::vmindex_offset()));
Address member_vmtarget( member_reg, NONZERO(java_lang_invoke_MemberName::method_offset()));
Address vmtarget_method( rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()));

Register temp1_recv_klass = temp1;
if (iid != vmIntrinsics::_linkToStatic) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -939,8 +939,7 @@ address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {

address entry = __ pc();

const int referent_offset = java_lang_ref_Reference::referent_offset;
guarantee(referent_offset > 0, "referent offset not initialized");
const int referent_offset = java_lang_ref_Reference::referent_offset();

Label slow_path;
const Register local_0 = c_rarg0;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -311,7 +311,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {

assert(_obj != noreg, "must be a valid register");
// Rtemp should be OK in C1
__ ldr(Rtemp, Address(_obj, java_lang_Class::klass_offset_in_bytes()));
__ ldr(Rtemp, Address(_obj, java_lang_Class::klass_offset()));
__ ldr(Rtemp, Address(Rtemp, InstanceKlass::init_thread_offset()));
__ cmp(Rtemp, Rthread);
__ b(call_patch, ne);
@@ -53,7 +53,7 @@ void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_
verify_klass(_masm, klass_reg, temp1, temp2, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
"MH argument is a Class");
}
__ ldr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset_in_bytes()));
__ ldr(klass_reg, Address(klass_reg, java_lang_Class::klass_offset()));
}

#ifdef ASSERT
@@ -95,7 +95,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
void MethodHandles::verify_ref_kind(MacroAssembler* _masm, int ref_kind, Register member_reg, Register temp) {
Label L;
BLOCK_COMMENT("verify_ref_kind {");
__ ldr_u32(temp, Address(member_reg, NONZERO(java_lang_invoke_MemberName::flags_offset_in_bytes())));
__ ldr_u32(temp, Address(member_reg, NONZERO(java_lang_invoke_MemberName::flags_offset())));
__ logical_shift_right(temp, temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT);
__ andr(temp, temp, (unsigned)java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK);
__ cmp(temp, ref_kind);
@@ -148,15 +148,15 @@ void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,
assert_different_registers(recv, tmp, Rmethod);

// Load the invoker, as MH -> MH.form -> LF.vmentry
__ load_heap_oop(tmp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes())));
__ load_heap_oop(tmp, Address(recv, NONZERO(java_lang_invoke_MethodHandle::form_offset())));
__ verify_oop(tmp);

__ load_heap_oop(tmp, Address(tmp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes())));
__ load_heap_oop(tmp, Address(tmp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset())));
__ verify_oop(tmp);

__ load_heap_oop(Rmethod, Address(tmp, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes())));
__ load_heap_oop(Rmethod, Address(tmp, NONZERO(java_lang_invoke_MemberName::method_offset())));
__ verify_oop(Rmethod);
__ access_load_at(T_ADDRESS, IN_HEAP, Address(Rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes())), Rmethod, noreg, noreg, noreg);
__ access_load_at(T_ADDRESS, IN_HEAP, Address(Rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset())), Rmethod, noreg, noreg, noreg);

if (VerifyMethodHandles && !for_compiler_entry) {
// make sure recv is already on stack
@@ -305,10 +305,10 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
"MemberName required for invokeVirtual etc.");
}

Address member_clazz( member_reg, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()));
Address member_vmindex( member_reg, NONZERO(java_lang_invoke_MemberName::vmindex_offset_in_bytes()));
Address member_vmtarget(member_reg, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes()));
Address vmtarget_method(Rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes()));
Address member_clazz( member_reg, NONZERO(java_lang_invoke_MemberName::clazz_offset()));
Address member_vmindex( member_reg, NONZERO(java_lang_invoke_MemberName::vmindex_offset()));
Address member_vmtarget(member_reg, NONZERO(java_lang_invoke_MemberName::method_offset()));
Address vmtarget_method(Rmethod, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()));

Register temp1_recv_klass = temp1;
if (iid != vmIntrinsics::_linkToStatic) {
@@ -532,9 +532,7 @@ void trace_method_handle_stub(const char* adaptername,
if (has_mh && oopDesc::is_oop(mh)) {
mh->print();
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0) {
java_lang_invoke_MethodHandle::form(mh)->print();
}
java_lang_invoke_MethodHandle::form(mh)->print();
}
}
}
@@ -708,8 +708,7 @@ address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
const Register Rret_addr = Rtmp_save1;
assert_different_registers(Rthis, Rret_addr, Rsender_sp);

const int referent_offset = java_lang_ref_Reference::referent_offset;
guarantee(referent_offset > 0, "referent offset not initialized");
const int referent_offset = java_lang_ref_Reference::referent_offset();

// Check if local 0 != NULL
// If the receiver is null then it is OK to jump to the slow path.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -361,7 +361,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
assert(_obj != noreg, "must be a valid register");
assert(_index >= 0, "must have oop index");
__ mr(R0, _obj); // spill
__ ld(_obj, java_lang_Class::klass_offset_in_bytes(), _obj);
__ ld(_obj, java_lang_Class::klass_offset(), _obj);
__ ld(_obj, in_bytes(InstanceKlass::init_thread_offset()), _obj);
__ cmpd(CCR0, _obj, R16_thread);
__ mr(_obj, R0); // restore
@@ -56,7 +56,7 @@ void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_
verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class),
temp_reg, temp2_reg, "MH argument is a Class");
}
__ ld(klass_reg, java_lang_Class::klass_offset_in_bytes(), klass_reg);
__ ld(klass_reg, java_lang_Class::klass_offset(), klass_reg);
}

#ifdef ASSERT
@@ -98,7 +98,7 @@ void MethodHandles::verify_klass(MacroAssembler* _masm,
void MethodHandles::verify_ref_kind(MacroAssembler* _masm, int ref_kind, Register member_reg, Register temp) {
Label L;
BLOCK_COMMENT("verify_ref_kind {");
__ load_sized_value(temp, NONZERO(java_lang_invoke_MemberName::flags_offset_in_bytes()), member_reg,
__ load_sized_value(temp, NONZERO(java_lang_invoke_MemberName::flags_offset()), member_reg,
sizeof(u4), /*is_signed*/ false);
// assert(sizeof(u4) == sizeof(java.lang.invoke.MemberName.flags), "");
__ srwi( temp, temp, java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT);
@@ -174,16 +174,16 @@ void MethodHandles::jump_to_lambda_form(MacroAssembler* _masm,

// Load the invoker, as MH -> MH.form -> LF.vmentry
__ verify_oop(recv, FILE_AND_LINE);
__ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset_in_bytes()), recv,
__ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MethodHandle::form_offset()), recv,
temp2, noreg, false, IS_NOT_NULL);
__ verify_oop(method_temp, FILE_AND_LINE);
__ load_heap_oop(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset_in_bytes()), method_temp,
__ load_heap_oop(method_temp, NONZERO(java_lang_invoke_LambdaForm::vmentry_offset()), method_temp,
temp2, noreg, false, IS_NOT_NULL);
__ verify_oop(method_temp, FILE_AND_LINE);
__ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes()), method_temp,
__ load_heap_oop(method_temp, NONZERO(java_lang_invoke_MemberName::method_offset()), method_temp,
temp2, noreg, false, IS_NOT_NULL);
__ verify_oop(method_temp, FILE_AND_LINE);
__ ld(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes()), method_temp);
__ ld(method_temp, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()), method_temp);

if (VerifyMethodHandles && !for_compiler_entry) {
// Make sure recv is already on stack.
@@ -342,7 +342,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
if (VerifyMethodHandles && iid != vmIntrinsics::_linkToInterface) {
Label L_ok;
Register temp2_defc = temp2;
__ load_heap_oop(temp2_defc, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg,
__ load_heap_oop(temp2_defc, NONZERO(java_lang_invoke_MemberName::clazz_offset()), member_reg,
temp3, noreg, false, IS_NOT_NULL);
load_klass_from_Class(_masm, temp2_defc, temp3, temp4);
__ verify_klass_ptr(temp2_defc);
@@ -370,18 +370,18 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
if (VerifyMethodHandles) {
verify_ref_kind(_masm, JVM_REF_invokeSpecial, member_reg, temp2);
}
__ load_heap_oop(R19_method, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes()), member_reg,
__ load_heap_oop(R19_method, NONZERO(java_lang_invoke_MemberName::method_offset()), member_reg,
temp3, noreg, false, IS_NOT_NULL);
__ ld(R19_method, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes()), R19_method);
__ ld(R19_method, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()), R19_method);
break;

case vmIntrinsics::_linkToStatic:
if (VerifyMethodHandles) {
verify_ref_kind(_masm, JVM_REF_invokeStatic, member_reg, temp2);
}
__ load_heap_oop(R19_method, NONZERO(java_lang_invoke_MemberName::method_offset_in_bytes()), member_reg,
__ load_heap_oop(R19_method, NONZERO(java_lang_invoke_MemberName::method_offset()), member_reg,
temp3, noreg, false, IS_NOT_NULL);
__ ld(R19_method, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset_in_bytes()), R19_method);
__ ld(R19_method, NONZERO(java_lang_invoke_ResolvedMethodName::vmtarget_offset()), R19_method);
break;

case vmIntrinsics::_linkToVirtual:
@@ -395,7 +395,7 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,

// pick out the vtable index from the MemberName, and then we can discard it:
Register temp2_index = temp2;
__ ld(temp2_index, NONZERO(java_lang_invoke_MemberName::vmindex_offset_in_bytes()), member_reg);
__ ld(temp2_index, NONZERO(java_lang_invoke_MemberName::vmindex_offset()), member_reg);

if (VerifyMethodHandles) {
Label L_index_ok;
@@ -422,13 +422,13 @@ void MethodHandles::generate_method_handle_dispatch(MacroAssembler* _masm,
}

Register temp2_intf = temp2;
__ load_heap_oop(temp2_intf, NONZERO(java_lang_invoke_MemberName::clazz_offset_in_bytes()), member_reg,
__ load_heap_oop(temp2_intf, NONZERO(java_lang_invoke_MemberName::clazz_offset()), member_reg,
temp3, noreg, false, IS_NOT_NULL);
load_klass_from_Class(_masm, temp2_intf, temp3, temp4);
__ verify_klass_ptr(temp2_intf);

Register vtable_index = R19_method;
__ ld(vtable_index, NONZERO(java_lang_invoke_MemberName::vmindex_offset_in_bytes()), member_reg);
__ ld(vtable_index, NONZERO(java_lang_invoke_MemberName::vmindex_offset()), member_reg);
if (VerifyMethodHandles) {
Label L_index_ok;
__ cmpdi(CCR1, vtable_index, 0);
@@ -538,9 +538,7 @@ void trace_method_handle_stub(const char* adaptername,
if (has_mh && oopDesc::is_oop(mh)) {
mh->print();
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0) {
java_lang_invoke_MethodHandle::form(mh)->print();
}
java_lang_invoke_MethodHandle::form(mh)->print();
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -507,8 +507,7 @@ address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {

address entry = __ pc();

const int referent_offset = java_lang_ref_Reference::referent_offset;
guarantee(referent_offset > 0, "referent offset not initialized");
const int referent_offset = java_lang_ref_Reference::referent_offset();

Label slow_path;

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -353,7 +353,7 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
// thread.
assert(_obj != noreg, "must be a valid register");
assert(_index >= 0, "must have oop index");
__ z_lg(Z_R1_scratch, java_lang_Class::klass_offset_in_bytes(), _obj);
__ z_lg(Z_R1_scratch, java_lang_Class::klass_offset(), _obj);
__ z_cg(Z_thread, Address(Z_R1_scratch, InstanceKlass::init_thread_offset()));
__ branch_optimized(Assembler::bcondNotEqual, call_patch);

0 comments on commit 5314d28

Please sign in to comment.