Mercurial > hg > graal-compiler
changeset 10030:85f926430ae6
Test deoptimization in DynamicNewArrayNode.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 13 Jun 2013 13:50:29 +0200 |
parents | 839791e70ff1 |
children | 055430b5abb9 |
files | graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java |
diffstat | 3 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Jun 13 13:19:56 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Jun 13 13:50:29 2013 +0200 @@ -358,7 +358,7 @@ test(method, expect, Collections.<DeoptimizationReason> emptySet(), receiver, args); } - protected void test(Method method, Result expect, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) { + protected Result executeActualCheckDeopt(Method method, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) { Map<DeoptimizationReason, Integer> deoptCounts = new EnumMap<>(DeoptimizationReason.class); ProfilingInfo profile = runtime.lookupJavaMethod(method).getProfilingInfo(); for (DeoptimizationReason reason : shouldNotDeopt) { @@ -368,7 +368,10 @@ for (DeoptimizationReason reason : shouldNotDeopt) { Assert.assertEquals((int) deoptCounts.get(reason), profile.getDeoptimizationCount(reason)); } + return actual; + } + protected void assertEquals(Result expect, Result actual) { if (expect.exception != null) { Assert.assertTrue("expected " + expect.exception, actual.exception != null); Assert.assertEquals(expect.exception.getClass(), actual.exception.getClass()); @@ -382,6 +385,11 @@ } } + protected void test(Method method, Result expect, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) { + Result actual = executeActualCheckDeopt(method, shouldNotDeopt, receiver, args); + assertEquals(expect, actual); + } + private Map<ResolvedJavaMethod, InstalledCode> cache = new HashMap<>(); /**
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Thu Jun 13 13:19:56 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Thu Jun 13 13:50:29 2013 +0200 @@ -126,7 +126,7 @@ Word hub = loadWordFromObject(elementType, arrayKlassOffset()); if (hub.equal(Word.zero())) { // the array class is not yet loaded - DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint); + DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.Unresolved); } int layoutHelper = readLayoutHelper(hub);
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java Thu Jun 13 13:19:56 2013 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java Thu Jun 13 13:50:29 2013 +0200 @@ -23,9 +23,11 @@ package com.oracle.graal.replacements.test; import java.lang.reflect.*; +import java.util.*; import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; /** @@ -33,6 +35,9 @@ */ public class DynamicNewArrayTest extends GraalCompilerTest { + private class Element { + } + @Test public void test1() { test("test1snippet"); @@ -63,6 +68,16 @@ test("dynamic", null, 5); } + @Test + public void test7() { + Method method = getMethod("dynamic"); + Result actual1 = executeActual(method, null, Element.class, 7); + Result actual2 = executeActualCheckDeopt(method, Collections.<DeoptimizationReason> singleton(DeoptimizationReason.Unresolved), null, Element.class, 7); + Result expected = executeExpected(method, null, Element.class, 7); + assertEquals(actual1, expected); + assertEquals(actual2, expected); + } + public static Object test1snippet() { return Array.newInstance(Integer.class, 7); }