Skip to content
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

Removing default value #1389

Draft
wants to merge 11 commits into
base: lworld
Choose a base branch
from
9 changes: 1 addition & 8 deletions src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void InterpreterMacroAssembler::allocate_instance(Register klass, Register new_o
void InterpreterMacroAssembler::read_flat_field(Register entry,
Register field_index, Register field_offset,
Register temp, Register obj) {
Label alloc_failed, empty_value, done;
Label alloc_failed, done;
const Register src = field_offset;
const Register alloc_temp = r10;
const Register dst_temp = field_index;
Expand All @@ -239,9 +239,6 @@ void InterpreterMacroAssembler::read_flat_field(Register entry,
const Register field_klass = dst_temp;
ldr(field_klass, Address(layout_info, in_bytes(InlineLayoutInfo::klass_offset())));

// check for empty value klass
test_klass_is_empty_inline_type(field_klass, rscratch1, empty_value);

// allocate buffer
push(obj); // save holder
allocate_instance(field_klass, obj, alloc_temp, rscratch2, false, alloc_failed);
Expand All @@ -256,10 +253,6 @@ void InterpreterMacroAssembler::read_flat_field(Register entry,
pop(obj);
b(done);

bind(empty_value);
get_empty_inline_type_oop(field_klass, alloc_temp, obj);
b(done);

bind(alloc_failed);
pop(obj);
call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_flat_field),
Expand Down
50 changes: 0 additions & 50 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,42 +1190,6 @@ void MacroAssembler::check_and_handle_earlyret(Register java_thread) { }

void MacroAssembler::check_and_handle_popframe(Register java_thread) { }

void MacroAssembler::get_default_value_oop(Register inline_klass, Register temp_reg, Register obj) {
assert_different_registers(inline_klass, temp_reg, obj, rscratch2);
#ifdef ASSERT
{
Label done_check;
test_klass_is_inline_type(inline_klass, temp_reg, done_check);
stop("get_default_value_oop from non inline type klass");
bind(done_check);
}
#endif
Register offset = temp_reg;
// Getting the offset of the pre-allocated default value
ldr(offset, Address(inline_klass, in_bytes(InstanceKlass::adr_inlineklass_fixed_block_offset())));
load_sized_value(offset, Address(offset, in_bytes(InlineKlass::default_value_offset_offset())), sizeof(int), true /*is_signed*/);

// Getting the mirror
ldr(obj, Address(inline_klass, in_bytes(Klass::java_mirror_offset())));
resolve_oop_handle(obj, inline_klass, rscratch2);

// Getting the pre-allocated default value from the mirror
Address field(obj, offset);
load_heap_oop(obj, field, inline_klass, rscratch2);
}

void MacroAssembler::get_empty_inline_type_oop(Register inline_klass, Register temp_reg, Register obj) {
#ifdef ASSERT
{
Label done_check;
test_klass_is_empty_inline_type(inline_klass, temp_reg, done_check);
stop("get_empty_value from non-empty inline klass");
bind(done_check);
}
#endif
get_default_value_oop(inline_klass, temp_reg, obj);
}

// Look up the method for a megamorphic invokeinterface call.
// The target method is determined by <intf_klass, itable_index>.
// The receiver klass is in recv_klass.
Expand Down Expand Up @@ -2315,20 +2279,6 @@ void MacroAssembler::test_oop_is_not_inline_type(Register object, Register tmp,
br(Assembler::NE, not_inline_type);
}

void MacroAssembler::test_klass_is_empty_inline_type(Register klass, Register temp_reg, Label& is_empty_inline_type) {
#ifdef ASSERT
{
Label done_check;
test_klass_is_inline_type(klass, temp_reg, done_check);
stop("test_klass_is_empty_inline_type with non inline type klass");
bind(done_check);
}
#endif
ldrw(temp_reg, Address(klass, InstanceKlass::misc_flags_offset()));
andr(temp_reg, temp_reg, InstanceKlassFlags::is_empty_inline_type_value());
cbnz(temp_reg, is_empty_inline_type);
}

void MacroAssembler::test_field_is_null_free_inline_type(Register flags, Register temp_reg, Label& is_null_free_inline_type) {
assert(temp_reg == noreg, "not needed"); // keep signature uniform with x86
tbnz(flags, ResolvedFieldEntry::is_null_free_inline_type_shift, is_null_free_inline_type);
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,15 +659,8 @@ class MacroAssembler: public Assembler {

// inlineKlass queries, kills temp_reg
void test_klass_is_inline_type(Register klass, Register temp_reg, Label& is_inline_type);
void test_klass_is_empty_inline_type(Register klass, Register temp_reg, Label& is_empty_inline_type);
void test_oop_is_not_inline_type(Register object, Register tmp, Label& not_inline_type);

// Get the default value oop for the given InlineKlass
void get_default_value_oop(Register inline_klass, Register temp_reg, Register obj);
// The empty value oop, for the given InlineKlass ("empty" as in no instance fields)
// get_default_value_oop with extra assertion for empty inline klass
void get_empty_inline_type_oop(Register inline_klass, Register temp_reg, Register obj);

void test_field_is_null_free_inline_type(Register flags, Register temp_reg, Label& is_null_free);
void test_field_is_not_null_free_inline_type(Register flags, Register temp_reg, Label& not_null_free);
void test_field_is_flat(Register flags, Register temp_reg, Label& is_flat);
Expand Down
21 changes: 3 additions & 18 deletions src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2780,18 +2780,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ push(atos);
__ b(Done);
__ bind(uninitialized);
Label slow_case, finish;
__ ldrb(rscratch1, Address(klass, InstanceKlass::init_state_offset()));
__ cmp(rscratch1, (u1)InstanceKlass::fully_initialized);
__ br(Assembler::NE, slow_case);
__ get_default_value_oop(klass, off /* temp */, r0);
__ b(finish);
__ bind(slow_case);
__ call_VM(r0, CAST_FROM_FN_PTR(address, InterpreterRuntime::uninitialized_static_inline_type_field), obj, cache);
__ bind(finish);
__ verify_oop(r0);
__ push(atos);
__ b(Done);
__ b(ExternalAddress(Interpreter::_throw_NPE_UninitializedField_entry));
} else {
Label is_flat, nonnull, is_inline_type, has_null_marker, rewrite_inline;
__ test_field_is_null_free_inline_type(flags, noreg /*temp*/, is_inline_type);
Expand All @@ -2808,8 +2797,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
// field is not flat
__ load_heap_oop(r0, field, rscratch1, rscratch2);
__ cbnz(r0, nonnull);
__ get_inline_type_field_klass(klass, field_index, inline_klass);
__ get_default_value_oop(inline_klass, klass /* temp */, r0);
__ b(ExternalAddress(Interpreter::_throw_NPE_UninitializedField_entry));
__ bind(nonnull);
__ verify_oop(r0);
__ push(atos);
Expand Down Expand Up @@ -3455,10 +3443,7 @@ void TemplateTable::fast_accessfield(TosState state)
// field is not flat
__ load_heap_oop(r0, field, rscratch1, rscratch2);
__ cbnz(r0, nonnull);
__ load_unsigned_short(index, Address(r2, in_bytes(ResolvedFieldEntry::field_index_offset())));
__ ldr(klass, Address(r2, in_bytes(ResolvedFieldEntry::field_holder_offset())));
__ get_inline_type_field_klass(klass, index, inline_klass);
__ get_default_value_oop(inline_klass, tmp /* temp */, r0);
__ b(ExternalAddress(Interpreter::_throw_NPE_UninitializedField_entry));
__ bind(nonnull);
__ verify_oop(r0);
__ b(Done);
Expand Down
9 changes: 1 addition & 8 deletions src/hotspot/cpu/x86/interp_masm_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ void InterpreterMacroAssembler::allocate_instance(Register klass, Register new_o
}

void InterpreterMacroAssembler::read_flat_field(Register entry, Register tmp1, Register tmp2, Register obj) {
Label alloc_failed, empty_value, done;
Label alloc_failed, done;
const Register alloc_temp = LP64_ONLY(rscratch1) NOT_LP64(rsi);
const Register dst_temp = LP64_ONLY(rscratch2) NOT_LP64(rdi);
assert_different_registers(obj, entry, tmp1, tmp2, dst_temp, r8, r9);
Expand All @@ -1270,9 +1270,6 @@ void InterpreterMacroAssembler::read_flat_field(Register entry, Register tmp1, R
movptr(tmp1, Address(entry, ResolvedFieldEntry::field_holder_offset()));
get_inline_type_field_klass(tmp1, tmp2, field_klass);

//check for empty value klass
test_klass_is_empty_inline_type(field_klass, dst_temp, empty_value);

// allocate buffer
push(obj); // push object being read from // FIXME spilling on stack could probably be avoided by using tmp2
allocate_instance(field_klass, obj, alloc_temp, dst_temp, false, alloc_failed);
Expand All @@ -1293,10 +1290,6 @@ void InterpreterMacroAssembler::read_flat_field(Register entry, Register tmp1, R
pop(obj);
jmp(done);

bind(empty_value);
get_empty_inline_type_oop(field_klass, dst_temp, obj);
jmp(done);

bind(alloc_failed);
pop(obj);
call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::read_flat_field),
Expand Down
50 changes: 0 additions & 50 deletions src/hotspot/cpu/x86/macroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2969,20 +2969,6 @@ void MacroAssembler::test_oop_is_not_inline_type(Register object, Register tmp,
jcc(Assembler::notEqual, not_inline_type);
}

void MacroAssembler::test_klass_is_empty_inline_type(Register klass, Register temp_reg, Label& is_empty_inline_type) {
#ifdef ASSERT
{
Label done_check;
test_klass_is_inline_type(klass, temp_reg, done_check);
stop("test_klass_is_empty_inline_type with non inline type klass");
bind(done_check);
}
#endif
movl(temp_reg, Address(klass, InstanceKlass::misc_flags_offset()));
testl(temp_reg, InstanceKlassFlags::is_empty_inline_type_value());
jcc(Assembler::notZero, is_empty_inline_type);
}

void MacroAssembler::test_field_is_null_free_inline_type(Register flags, Register temp_reg, Label& is_null_free_inline_type) {
movl(temp_reg, flags);
testl(temp_reg, 1 << ResolvedFieldEntry::is_null_free_inline_type_shift);
Expand Down Expand Up @@ -4672,42 +4658,6 @@ void MacroAssembler::inline_layout_info(Register holder_klass, Register index, R
lea(layout_info, Address(layout_info, index, Address::times_1, Array<InlineLayoutInfo>::base_offset_in_bytes()));
}

void MacroAssembler::get_default_value_oop(Register inline_klass, Register temp_reg, Register obj) {
#ifdef ASSERT
{
Label done_check;
test_klass_is_inline_type(inline_klass, temp_reg, done_check);
stop("get_default_value_oop from non inline type klass");
bind(done_check);
}
#endif
Register offset = temp_reg;
// Getting the offset of the pre-allocated default value
movptr(offset, Address(inline_klass, in_bytes(InstanceKlass::adr_inlineklass_fixed_block_offset())));
movl(offset, Address(offset, in_bytes(InlineKlass::default_value_offset_offset())));

// Getting the mirror
movptr(obj, Address(inline_klass, in_bytes(Klass::java_mirror_offset())));
resolve_oop_handle(obj, inline_klass);

// Getting the pre-allocated default value from the mirror
Address field(obj, offset, Address::times_1);
load_heap_oop(obj, field);
}

void MacroAssembler::get_empty_inline_type_oop(Register inline_klass, Register temp_reg, Register obj) {
#ifdef ASSERT
{
Label done_check;
test_klass_is_empty_inline_type(inline_klass, temp_reg, done_check);
stop("get_empty_value from non-empty inline klass");
bind(done_check);
}
#endif
get_default_value_oop(inline_klass, temp_reg, obj);
}


// Look up the method for a megamorphic invokeinterface call.
// The target method is determined by <intf_klass, itable_index>.
// The receiver klass is in recv_klass.
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/cpu/x86/macroAssembler_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,8 @@ class MacroAssembler: public Assembler {

// inlineKlass queries, kills temp_reg
void test_klass_is_inline_type(Register klass, Register temp_reg, Label& is_inline_type);
void test_klass_is_empty_inline_type(Register klass, Register temp_reg, Label& is_empty_inline_type);
void test_oop_is_not_inline_type(Register object, Register tmp, Label& not_inline_type);

// Get the default value oop for the given InlineKlass
void get_default_value_oop(Register inline_klass, Register temp_reg, Register obj);
// The empty value oop, for the given InlineKlass ("empty" as in no instance fields)
// get_default_value_oop with extra assertion for empty inline klass
void get_empty_inline_type_oop(Register inline_klass, Register temp_reg, Register obj);

void test_field_is_null_free_inline_type(Register flags, Register temp_reg, Label& is_null_free);
void test_field_is_not_null_free_inline_type(Register flags, Register temp_reg, Label& not_null_free);
void test_field_is_flat(Register flags, Register temp_reg, Label& is_flat);
Expand Down
40 changes: 9 additions & 31 deletions src/hotspot/cpu/x86/templateTable_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ void TemplateTable::aastore() {
// Have a null in rax, rdx=array, ecx=index. Store null at ary[idx]
__ bind(is_null);
if (EnableValhalla) {
Label is_null_into_value_array_npe, store_null;
Label write_null_to_null_free_array, store_null;

// Move array class to rdi
__ load_klass(rdi, rdx, rscratch1);
Expand All @@ -1208,10 +1208,10 @@ void TemplateTable::aastore() {
}

// No way to store null in null-free array
__ test_null_free_array_oop(rdx, rbx, is_null_into_value_array_npe);
__ test_null_free_array_oop(rdx, rbx, write_null_to_null_free_array);
__ jmp(store_null);

__ bind(is_null_into_value_array_npe);
__ bind(write_null_to_null_free_array);
__ jump(RuntimeAddress(Interpreter::_throw_NullPointerException_entry));

__ bind(store_null);
Expand Down Expand Up @@ -3159,26 +3159,10 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
__ push(atos);
__ jmp(Done);
__ bind(uninitialized);
#ifdef _LP64
Label slow_case, finish;
__ movptr(rbx, Address(obj, java_lang_Class::klass_offset()));
__ cmpb(Address(rbx, InstanceKlass::init_state_offset()), InstanceKlass::fully_initialized);
__ jcc(Assembler::notEqual, slow_case);
__ get_default_value_oop(rbx, rscratch1, rax);
__ jmp(finish);
__ bind(slow_case);
#endif // LP64
__ call_VM(rax, CAST_FROM_FN_PTR(address, InterpreterRuntime::uninitialized_static_inline_type_field),
obj, cache);
#ifdef _LP64
__ bind(finish);
#endif // _LP64
__ verify_oop(rax);
__ push(atos);
__ jmp(Done);
__ jump(RuntimeAddress(Interpreter::_throw_NPE_UninitializedField_entry));
} else {
Label is_flat, nonnull, is_inline_type, rewrite_inline, has_null_marker;
__ test_field_is_null_free_inline_type(flags, rscratch1, is_inline_type);
Label is_flat, nonnull, is_null_free_inline_type, rewrite_inline, has_null_marker;
__ test_field_is_null_free_inline_type(flags, rscratch1, is_null_free_inline_type);
__ test_field_has_null_marker(flags, rscratch1, has_null_marker);
// field is not a null free inline type
pop_and_check_object(obj);
Expand All @@ -3188,17 +3172,14 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr
patch_bytecode(Bytecodes::_fast_agetfield, bc, rbx);
}
__ jmp(Done);
__ bind(is_inline_type);
__ bind(is_null_free_inline_type);
__ test_field_is_flat(flags, rscratch1, is_flat);
// field is not flat
pop_and_check_object(obj);
__ load_heap_oop(rax, field);
__ testptr(rax, rax);
__ jcc(Assembler::notZero, nonnull);
__ load_unsigned_short(flags, Address(cache, in_bytes(ResolvedFieldEntry::field_index_offset())));
__ movptr(rcx, Address(cache, ResolvedFieldEntry::field_holder_offset()));
__ get_inline_type_field_klass(rcx, flags, rbx);
__ get_default_value_oop(rbx, rcx, rax);
__ jump(RuntimeAddress(Interpreter::_throw_NPE_UninitializedField_entry));
__ bind(nonnull);
__ verify_oop(rax);
__ push(atos);
Expand Down Expand Up @@ -3882,10 +3863,7 @@ void TemplateTable::fast_accessfield(TosState state) {
__ load_heap_oop(rax, field);
__ testptr(rax, rax);
__ jcc(Assembler::notZero, nonnull);
__ load_unsigned_short(rdx, Address(rcx, in_bytes(ResolvedFieldEntry::field_index_offset())));
__ movptr(rcx, Address(rcx, ResolvedFieldEntry::field_holder_offset()));
__ get_inline_type_field_klass(rcx, rdx, rbx);
__ get_default_value_oop(rbx, rcx, rax);
__ jump(RuntimeAddress(Interpreter::_throw_NPE_UninitializedField_entry));
__ bind(nonnull);
__ verify_oop(rax);
__ jmp(Done);
Expand Down
Loading