Skip to content

8320276: Improve class initialization barrier in TemplateTable::_new #3508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3473,11 +3473,9 @@ void TemplateTable::_new() {
// get InstanceKlass
__ load_resolved_klass_at_offset(r4, r3, r4, rscratch1);

// make sure klass is initialized & doesn't have finalizer
// make sure klass is fully initialized
__ ldrb(rscratch1, Address(r4, InstanceKlass::init_state_offset()));
__ cmp(rscratch1, (u1)InstanceKlass::fully_initialized);
__ br(Assembler::NE, slow_case);
// make sure klass is initialized
assert(VM_Version::supports_fast_class_init_checks(), "Optimization requires support for fast class initialization checks");
__ clinit_barrier(r4, rscratch1, nullptr /*L_fast_path*/, &slow_case);

// get instance_size in InstanceKlass (scaled to a count of bytes)
__ ldrw(r3,
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/aarch64/vm_version_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class VM_Version : public Abstract_VM_Version {
static int dcache_line_size() { return _dcache_line_size; }
static int get_initial_sve_vector_length() { return _initial_sve_vector_length; };

// Aarch64 supports fast class initialization checks
static bool supports_fast_class_init_checks() { return true; }
constexpr static bool supports_stack_watermark_barrier() { return true; }

Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/cpu/ppc/vm_version_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class VM_Version: public Abstract_VM_Version {

// POWER 8: DSCR current value.
static uint64_t _dscr_val;

static void initialize_cpu_information(void);
Comment on lines +134 to +135

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};

#endif // CPU_PPC_VM_VERSION_PPC_HPP
2 changes: 1 addition & 1 deletion src/hotspot/cpu/s390/vm_version_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class VM_Version: public Abstract_VM_Version {
// Override Abstract_VM_Version implementation
static void print_platform_virtualization_info(outputStream*);

// s390 supports fast class initialization checks for static methods.
// s390 supports fast class initialization checks
static bool supports_fast_class_init_checks() { return true; }

// CPU feature query functions
Expand Down
9 changes: 7 additions & 2 deletions src/hotspot/cpu/x86/templateTable_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3936,11 +3936,16 @@ void TemplateTable::_new() {
__ load_resolved_klass_at_index(rcx, rcx, rdx);
__ push(rcx); // save the contexts of klass for initializing the header

// make sure klass is initialized & doesn't have finalizer
// make sure klass is fully initialized
// make sure klass is initialized
#ifdef _LP64
assert(VM_Version::supports_fast_class_init_checks(), "must support fast class initialization checks");
__ clinit_barrier(rcx, r15_thread, nullptr /*L_fast_path*/, &slow_case);
#else
__ cmpb(Address(rcx, InstanceKlass::init_state_offset()), InstanceKlass::fully_initialized);
__ jcc(Assembler::notEqual, slow_case);
#endif

// make sure klass doesn't have finalizer
// get instance_size in InstanceKlass (scaled to a count of bytes)
__ movl(rdx, Address(rcx, Klass::layout_helper_offset()));
// test to see if it has a finalizer or is malformed in some way
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/vm_version_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ enum Extended_Family {
// the intrinsic for java.lang.Thread.onSpinWait()
static bool supports_on_spin_wait() { return supports_sse2(); }

// x86_64 supports fast class initialization checks for static methods.
// x86_64 supports fast class initialization checks
static bool supports_fast_class_init_checks() {
return LP64_ONLY(true) NOT_LP64(false); // not implemented on x86_32
}
Expand Down