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

8252111: [lworld] C2 intrinsic needs to handle unsafe access to non-flattened field of constant inline type holder #159

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 7 additions & 11 deletions src/hotspot/share/opto/library_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,6 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c

if (base->is_InlineType()) {
InlineTypeNode* vt = base->as_InlineType();

if (is_store) {
if (!vt->is_allocated(&_gvn) || !_gvn.type(vt)->is_inlinetype()->larval()) {
return false;
Expand All @@ -2504,18 +2503,15 @@ bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, c
return false;
}

ciField* f = vk->get_non_flattened_field_by_offset((int)off);

if (f != NULL) {
BasicType bt = f->layout_type();
if (bt == T_ARRAY || bt == T_NARROWOOP) {
ciField* field = vk->get_non_flattened_field_by_offset(off);
if (field != NULL) {
BasicType bt = field->layout_type();
if (bt == T_ARRAY || bt == T_NARROWOOP || (bt == T_INLINE_TYPE && !field->is_flattened())) {
bt = T_OBJECT;
}
if (bt == type) {
if (bt != T_INLINE_TYPE || f->type() == inline_klass) {
set_result(vt->field_value_by_offset((int)off, false));
return true;
}
if (bt == type && (bt != T_INLINE_TYPE || field->type() == inline_klass)) {
set_result(vt->field_value_by_offset(off, false));
return true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1027,4 +1027,21 @@ public void test54_verifier(boolean warmup) {
MyValue1 res = test54(v.setX(v, 0));
Asserts.assertEQ(res.hash(), v.hash());
}

static final MyValue1 test55_vt = MyValue1.createWithFieldsInline(rI, rL);

// Same as test30 but with constant field holder
@Test(failOn=CALL_Unsafe)
public MyValue2 test55() {
if (V1_FLATTENED) {
return U.getValue(test55_vt, V1_OFFSET, MyValue2.val.class);
}
return (MyValue2)U.getReference(test55_vt, V1_OFFSET);
}

@DontCompile
public void test55_verifier(boolean warmup) {
MyValue2 res = test55();
Asserts.assertEQ(res.hash(), test55_vt.v1.hash());
}
}