Skip to content
Permalink
Browse files
8264895: [lworld] assert(!InstanceKlass::cast(receiver_klass)->is_not…
…_initialized()) failed: receiver_klass must be initialized

Reviewed-by: fparain
  • Loading branch information
TobiHartmann committed Apr 12, 2021
1 parent 571322e commit 4f889591c03f25680a3c93620b77e071b999b353
Showing with 51 additions and 2 deletions.
  1. +2 −1 src/hotspot/share/c1/c1_GraphBuilder.cpp
  2. +49 −1 test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java
@@ -2488,7 +2488,8 @@ void GraphBuilder::new_instance(int klass_index) {
void GraphBuilder::default_value(int klass_index) {
bool will_link;
ciKlass* klass = stream()->get_klass(will_link);
if (!stream()->is_unresolved_klass() && klass->is_inlinetype()) {
if (!stream()->is_unresolved_klass() && klass->is_inlinetype() &&
klass->as_inline_klass()->is_initialized()) {
ciInlineKlass* vk = klass->as_inline_klass();
apush(append(new Constant(new InstanceConstant(vk->default_instance()))));
} else {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,6 +57,12 @@
}

public static void main(String[] args) throws Throwable {
// Make sure Test140Value is loaded but not linked
Class<?> class1 = Test140Value.class;
// Make sure Test141Value is linked but not initialized
Class<?> class2 = Test141Value.class;
class2.getDeclaredFields();

TestLWorld test = new TestLWorld();
test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class,
MyValue3Inline.class, Test51Value.class);
@@ -3732,4 +3738,46 @@ public void test139_verifier(boolean warmup) {
MyValueEmpty empty = test139();
Asserts.assertEquals(empty, MyValueEmpty.default);
}

// Test calling a method on a loaded but not linked inline type
final primitive class Test140Value {
final int x = 42;
public int get() {
return x;
}
}

@Test
@Warmup(0)
public int test140() {
Test140Value vt = Test140Value.default;
return vt.get();
}

@DontCompile
public void test140_verifier(boolean warmup) {
int result = test140();
Asserts.assertEquals(result, 0);
}

// Test calling a method on a linked but not initialized inline type
final primitive class Test141Value {
final int x = 42;
public int get() {
return x;
}
}

@Test
@Warmup(0)
public int test141() {
Test141Value vt = Test141Value.default;
return vt.get();
}

@DontCompile
public void test141_verifier(boolean warmup) {
int result = test141();
Asserts.assertEquals(result, 0);
}
}

0 comments on commit 4f88959

Please sign in to comment.