# HG changeset patch # User Matthias Grimmer # Date 1365774927 -7200 # Node ID 941d7b1fecd8cd47e6ad07c859d87ae10f790f13 # Parent 640996823a81b450f04361fa87fe4c15369e95e4 Fixes diff -r 640996823a81 -r 941d7b1fecd8 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Fri Apr 12 15:30:36 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Fri Apr 12 15:55:27 2013 +0200 @@ -29,6 +29,7 @@ import org.junit.*; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.test.*; @@ -41,7 +42,7 @@ private final MetaAccessProvider metaAccessProvider; Object[] argsToBind; - public static void main(String[] args) throws NoSuchMethodException, SecurityException { + public static void main(String[] args) throws NoSuchMethodException, SecurityException, InvalidInstalledCodeException { InstalledCodeExecuteHelperTest main = new InstalledCodeExecuteHelperTest(); main.testWithTime(); } @@ -52,7 +53,7 @@ @Ignore @Test - public void test1() throws NoSuchMethodException, SecurityException { + public void test1() throws NoSuchMethodException, SecurityException, InvalidInstalledCodeException { final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo", Object.class, Object.class, Object.class); final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) metaAccessProvider.lookupJavaMethod(fooMethod); final HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parse(fooMethod)); @@ -69,7 +70,7 @@ } - public void testWithTime() throws NoSuchMethodException, SecurityException { + public void testWithTime() throws NoSuchMethodException, SecurityException, InvalidInstalledCodeException { final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo", Object.class, Object.class, Object.class); final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) metaAccessProvider.lookupJavaMethod(fooMethod); final HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parse(fooMethod)); @@ -83,16 +84,15 @@ long start = System.currentTimeMillis(); benchmark(fooCode); long end = System.currentTimeMillis(); - @SuppressWarnings("unused") - long time = (end - start); + System.out.println((end - start)); start = System.currentTimeMillis(); installedBenchmarkCodeotInstalledCode.executeVarargs(argsToBind[0]); end = System.currentTimeMillis(); - time = (end - start); + System.out.println((end - start)); } - public static Integer benchmark(HotSpotInstalledCode code) { + public static Integer benchmark(HotSpotInstalledCode code) throws InvalidInstalledCodeException { int val = 0; for (int i = 0; i < ITERATIONS; i++) { val = (Integer) code.execute(null, null, null); diff -r 640996823a81 -r 941d7b1fecd8 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri Apr 12 15:30:36 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri Apr 12 15:55:27 2013 +0200 @@ -33,6 +33,7 @@ import com.oracle.graal.compiler.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.internal.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; @@ -167,7 +168,7 @@ } } - installMethod(result); + installMethod(result, null); } catch (BailoutException bailout) { Debug.metric("Bailouts").increment(); if (GraalOptions.ExitVMOnBailout) { @@ -197,12 +198,12 @@ MetaUtil.format("%H::%n(%p)", method), isOSR ? "@ " + entryBCI + " " : "", method.getCodeSize())); } - private void installMethod(final CompilationResult compResult) { + private void installMethod(final CompilationResult compResult, final Graph graph) { Debug.scope("CodeInstall", new Object[]{new DebugDumpScope(String.valueOf(id), true), graalRuntime.getRuntime(), method}, new Runnable() { @Override public void run() { - HotSpotInstalledCode installedCode = graalRuntime.getRuntime().installMethod(method, entryBCI, compResult); + HotSpotInstalledCode installedCode = graalRuntime.getRuntime().installMethod(method, graph, entryBCI, compResult); if (Debug.isDumpEnabled()) { Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); } diff -r 640996823a81 -r 941d7b1fecd8 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java Fri Apr 12 15:30:36 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java Fri Apr 12 15:55:27 2013 +0200 @@ -26,6 +26,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; /** diff -r 640996823a81 -r 941d7b1fecd8 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Fri Apr 12 15:30:36 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Fri Apr 12 15:55:27 2013 +0200 @@ -766,16 +766,21 @@ return graalRuntime.getCompilerToVM().getJavaField(reflectionField); } - public HotSpotInstalledCode installMethod(HotSpotResolvedJavaMethod method, int entryBCI, CompilationResult compResult) { - HotSpotInstalledCode installedCode = new HotSpotInstalledCode(method, true); + public HotSpotInstalledCode installMethod(HotSpotResolvedJavaMethod method, Graph graph, int entryBCI, CompilationResult compResult) { + HotSpotInstalledCode installedCode = new HotSpotInstalledCode(method, graph, true); graalRuntime.getCompilerToVM().installCode(new HotSpotCompilationResult(method, entryBCI, compResult), installedCode, method.getSpeculationLog()); return installedCode; } @Override public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) { + return addMethod(method, compResult, null); + } + + @Override + public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, Graph graph) { HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; - HotSpotInstalledCode code = new HotSpotInstalledCode(hotspotMethod, false); + HotSpotInstalledCode code = new HotSpotInstalledCode(hotspotMethod, graph, false); CodeInstallResult result = graalRuntime.getCompilerToVM().installCode(new HotSpotCompilationResult(hotspotMethod, -1, compResult), code, null); if (result != CodeInstallResult.OK) { return null; @@ -894,7 +899,7 @@ public String disassemble(InstalledCode code) { if (code.isValid()) { - long nmethod = ((HotSpotInstalledCode) code).getnmethod(); + long nmethod = ((HotSpotInstalledCode) code).getMethodAddress(); return graalRuntime.getCompilerToVM().disassembleNMethod(nmethod); } return null; diff -r 640996823a81 -r 941d7b1fecd8 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotInstalledCodeSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotInstalledCodeSubstitutions.java Fri Apr 12 15:30:36 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotInstalledCodeSubstitutions.java Fri Apr 12 15:55:27 2013 +0200 @@ -22,11 +22,8 @@ */ package com.oracle.graal.hotspot.replacements; -import static com.oracle.graal.graph.UnsafeAccess.*; - import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; -import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.replacements.Snippet.Fold; @@ -44,6 +41,4 @@ return new Class[]{Object.class, Object.class, Object.class}; } - - }