# HG changeset patch # User Doug Simon # Date 1407766287 -7200 # Node ID b359f0468128cb0559b1718adc0a075c7ceaea4f # Parent 5992012d3bca5ce8b2dfcb325ac23f4d782993a5 added AllocSpy-based memory usage benchmarking diff -r 5992012d3bca -r b359f0468128 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Mon Aug 11 16:10:42 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Mon Aug 11 16:11:27 2014 +0200 @@ -127,7 +127,7 @@ new MemoryUsageBenchmark().run(); } - private void doCompilation(String methodName) { + private void doCompilation(String methodName, String label) { HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getMetaAccess().lookupJavaMethod(getMethod(methodName)); HotSpotBackend backend = runtime().getHostBackend(); @@ -136,8 +136,28 @@ int id = method.allocateCompileId(INVOCATION_ENTRY_BCI); long ctask = 0L; - CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id); - task.runCompilation(); + + try (MemoryUsageCloseable c = label == null ? null : new MemoryUsageCloseable(label)) { + CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id); + task.runCompilation(); + } + } + + private void allocSpyCompilation(String methodName) { + if (AllocSpy.isEnabled()) { + HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getMetaAccess().lookupJavaMethod(getMethod(methodName)); + HotSpotBackend backend = runtime().getHostBackend(); + + // invalidate any existing compiled code + method.reprofile(); + + int id = method.allocateCompileId(INVOCATION_ENTRY_BCI); + long ctask = 0L; + try (AllocSpy as = AllocSpy.open(methodName)) { + CompilationTask task = new CompilationTask(backend, method, INVOCATION_ENTRY_BCI, ctask, id); + task.runCompilation(); + } + } } private static final boolean verbose = Boolean.getBoolean("verbose"); @@ -149,14 +169,10 @@ // Warm up and initialize compiler phases used by this compilation for (int i = 0; i < 10; i++) { - try (MemoryUsageCloseable c = verbose ? new MemoryUsageCloseable(methodName + "[warmup-" + i + "]") : null) { - doCompilation(methodName); - } + doCompilation(methodName, verbose ? methodName + "[warmup-" + i + "]" : null); } - try (MemoryUsageCloseable c = new MemoryUsageCloseable(methodName)) { - doCompilation(methodName); - } + doCompilation(methodName, methodName); } public void run() { @@ -171,5 +187,7 @@ e.printStackTrace(); } } + allocSpyCompilation("simple"); + allocSpyCompilation("complex"); } }