Skip to content

8264085: [lworld] C2 compilation fails with assert "inline type should be loaded" #378

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

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
27 changes: 13 additions & 14 deletions src/hotspot/share/opto/inlinetypenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,12 @@ void InlineTypeBaseNode::load(GraphKit* kit, Node* base, Node* ptr, ciInstanceKl
int offset = holder_offset + field_offset(i);
Node* value = NULL;
ciType* ft = field_type(i);
if (field_is_flattened(i)) {
if (ft->as_inline_klass()->is_empty()) {
value = InlineTypeNode::make_default(kit->gvn(), ft->as_inline_klass());
} else {
// Recursively load the flattened inline type field
value = InlineTypeNode::make_from_flattened(kit, ft->as_inline_klass(), base, ptr, holder, offset, decorators);
}
if (ft->is_inlinetype() && ft->as_inline_klass()->is_empty()) {
// Loading from a field of an empty inline type. Just return the default instance.
value = InlineTypeNode::make_default(kit->gvn(), ft->as_inline_klass());
} else if (field_is_flattened(i)) {
// Recursively load the flattened inline type field
value = InlineTypeNode::make_from_flattened(kit, ft->as_inline_klass(), base, ptr, holder, offset, decorators);
} else {
const TypeOopPtr* oop_ptr = kit->gvn().type(base)->isa_oopptr();
bool is_array = (oop_ptr->isa_aryptr() != NULL);
Expand Down Expand Up @@ -689,13 +688,13 @@ Node* InlineTypeNode::is_loaded(PhaseGVN* phase, ciInlineKlass* vk, Node* base,
Node* value = field_value(i);
if (value->is_InlineType()) {
InlineTypeNode* vt = value->as_InlineType();
if (field_is_flattened(i)) {
if (!vt->inline_klass()->is_empty()) {
// Check inline type field load recursively
base = vt->is_loaded(phase, vk, base, offset - vt->inline_klass()->first_field_offset());
if (base == NULL) {
return NULL;
}
if (vt->inline_klass()->is_empty()) {
continue;
} else if (field_is_flattened(i)) {
// Check inline type field load recursively
base = vt->is_loaded(phase, vk, base, offset - vt->inline_klass()->first_field_offset());
if (base == NULL) {
return NULL;
}
continue;
} else {
Expand Down
21 changes: 21 additions & 0 deletions test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -3711,4 +3711,25 @@ public void test138_verifier(boolean warmup) {
Asserts.assertTrue(test138(rI, false));
Asserts.assertTrue(test138(rI, true));
}

static primitive class Test139Value {
Object obj = null;
MyValueEmpty empty = MyValueEmpty.default;
}

static primitive class Test139Wrapper {
Test139Value value = Test139Value.default;
}

@Test(failOn = ALLOC + LOAD + STORE + TRAP)
public MyValueEmpty test139() {
Test139Wrapper w = new Test139Wrapper();
return w.value.empty;
}

@DontCompile
public void test139_verifier(boolean warmup) {
MyValueEmpty empty = test139();
Asserts.assertEquals(empty, MyValueEmpty.default);
}
}