Skip to content
Permalink
Browse files
8252111: [lworld] C2 intrinsic needs to handle unsafe access to non-f…
…lattened field of constant inline type holder
  • Loading branch information
TobiHartmann committed Aug 21, 2020
1 parent 2d8688f commit c75f0f146a58e0f55b7ee69aec40ec3403c9da8a
Showing 2 changed files with 24 additions and 11 deletions.
@@ -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;
@@ -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;
}
}
}
@@ -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());
}
}

0 comments on commit c75f0f1

Please sign in to comment.