--- old/src/hotspot/cpu/x86/macroAssembler_x86.cpp 2019-05-01 16:15:23.000000000 -0700 +++ new/src/hotspot/cpu/x86/macroAssembler_x86.cpp 2019-05-01 16:15:23.000000000 -0700 @@ -4448,6 +4448,29 @@ } +void MacroAssembler::clinit_barrier(Register klass, Register thread, Label* L_fast_path, Label* L_slow_path) { + assert(L_fast_path != NULL || L_slow_path != NULL, "at least one is required"); + + Label L_fallthrough; + if (L_fast_path == NULL) { + L_fast_path = &L_fallthrough; + } + + // Fast path check: class is fully initialized + cmpb(Address(klass, InstanceKlass::init_state_offset()), InstanceKlass::fully_initialized); + jcc(Assembler::equal, *L_fast_path); + + // Fast path check: current thread is initializer thread + cmpptr(thread, Address(klass, InstanceKlass::init_thread_offset())); + if (L_slow_path != NULL) { + jcc(Assembler::notEqual, *L_slow_path); + } else { + jcc(Assembler::equal, *L_fast_path); + } + + bind(L_fallthrough); +} + void MacroAssembler::cmov32(Condition cc, Register dst, Address src) { if (VM_Version::supports_cmov()) { cmovl(cc, dst, src); @@ -5021,15 +5044,19 @@ } void MacroAssembler::load_mirror(Register mirror, Register method, Register tmp) { + load_method_holder(mirror, method); // get mirror const int mirror_offset = in_bytes(Klass::java_mirror_offset()); - movptr(mirror, Address(method, Method::const_offset())); - movptr(mirror, Address(mirror, ConstMethod::constants_offset())); - movptr(mirror, Address(mirror, ConstantPool::pool_holder_offset_in_bytes())); movptr(mirror, Address(mirror, mirror_offset)); resolve_oop_handle(mirror, tmp); } +void MacroAssembler::load_method_holder(Register holder, Register method) { + movptr(holder, Address(method, Method::const_offset())); // ConstMethod* + movptr(holder, Address(holder, ConstMethod::constants_offset())); // ConstantPool* + movptr(holder, Address(holder, ConstantPool::pool_holder_offset_in_bytes())); // InstanceKlass* +} + void MacroAssembler::load_klass(Register dst, Register src) { #ifdef _LP64 if (UseCompressedClassPointers) {