Skip to content

Commit

Permalink
8320276: Improve class initialization barrier in TemplateTable::_new
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, fparain
  • Loading branch information
Matias Saavedra Silva committed Jan 3, 2024
1 parent 296c5b6 commit 409a39e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
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 @@ -3603,11 +3603,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 @@ -165,6 +165,7 @@ enum Ampere_CPU_Model {
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: 1 addition & 1 deletion src/hotspot/cpu/ppc/vm_version_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class VM_Version: public Abstract_VM_Version {
// Override Abstract_VM_Version implementation
static void print_platform_virtualization_info(outputStream*);

// PPC64 supports fast class initialization checks for static methods.
// PPC64 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: 1 addition & 1 deletion src/hotspot/cpu/s390/vm_version_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,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 @@ -4048,11 +4048,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 @@ -756,7 +756,7 @@ class VM_Version : public Abstract_VM_Version {
// 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

1 comment on commit 409a39e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.