Skip to content

Commit

Permalink
Handle interface element types properly when virtualizing StoreIndexe…
Browse files Browse the repository at this point in the history
…dNode.
  • Loading branch information
veresov committed Sep 7, 2018
1 parent 6f93765 commit 66cc097
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.List;

import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.iterators.NodeIterable;
import org.graalvm.compiler.loop.DefaultLoopPolicies;
import org.graalvm.compiler.loop.phases.LoopFullUnrollPhase;
import org.graalvm.compiler.loop.phases.LoopPeelingPhase;
Expand Down Expand Up @@ -492,4 +493,21 @@ public static void testDeoptMonitorSnippet(Object t, int i) {
public void testDeoptMonitor() {
test("testDeoptMonitorSnippet", new Object(), 0);
}

@Test
public void testInterfaceArrayAssignment() {
prepareGraph("testInterfaceArrayAssignmentSnippet", false);
NodeIterable<ReturnNode> returns = graph.getNodes().filter(ReturnNode.class);
assertTrue(returns.count() == 1);
assertFalse(returns.first().result().isConstant());
}

private interface TestInterface {
}

public static boolean testInterfaceArrayAssignmentSnippet() {
Object[] array = new TestInterface[1];
array[0] = new Object();
return array[0] == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void virtualize(VirtualizerTool tool) {
VirtualArrayNode virtual = (VirtualArrayNode) alias;
if (idx >= 0 && idx < virtual.entryCount()) {
ResolvedJavaType componentType = virtual.type().getComponentType();
if (componentType.isPrimitive() || StampTool.isPointerAlwaysNull(value) || componentType.getSuperclass() == null ||
if (componentType.isPrimitive() || StampTool.isPointerAlwaysNull(value) || componentType.isJavaLangObject() ||
(StampTool.typeReferenceOrNull(value) != null && componentType.isAssignableFrom(StampTool.typeOrNull(value)))) {
tool.setVirtualEntry(virtual, idx, value());
tool.delete();
Expand Down

0 comments on commit 66cc097

Please sign in to comment.