changeset 16723:c880fb576c97

add support for CompileTheWorld based memory usage analysis
author Doug Simon <doug.simon@oracle.com>
date Fri, 08 Aug 2014 12:33:22 +0200
parents 46eaf7cd8275
children 300fffc06b55
files graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java	Fri Aug 08 12:29:07 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java	Fri Aug 08 12:33:22 2014 +0200
@@ -23,6 +23,8 @@
 package com.oracle.graal.hotspot.test;
 
 import static com.oracle.graal.debug.internal.MemUseTrackerImpl.*;
+import static com.oracle.graal.hotspot.CompileTheWorld.*;
+import static com.oracle.graal.hotspot.CompileTheWorld.Options.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.nodes.StructuredGraph.*;
 
@@ -31,15 +33,24 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.CompileTheWorld.Config;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.printer.*;
 
 /**
- * Used to benchmark memory usage during Graal compilation. Run with:
+ * Used to benchmark memory usage during Graal compilation.
+ *
+ * To benchmark:
  *
  * <pre>
  *     mx vm -XX:-UseGraalClassLoader -cp @com.oracle.graal.hotspot.test com.oracle.graal.hotspot.test.MemoryUsageBenchmark
  * </pre>
+ *
+ * Memory analysis for a {@link CompileTheWorld} execution can also be performed. For example:
+ *
+ * <pre>
+ *     mx --vm server vm -XX:-UseGraalClassLoader -G:CompileTheWorldClasspath=$HOME/SPECjvm2008/SPECjvm2008.jar -cp @com.oracle.graal.hotspot.test com.oracle.graal.hotspot.test.MemoryUsageBenchmark
+ * </pre>
  */
 public class MemoryUsageBenchmark extends GraalCompilerTest {
 
@@ -149,7 +160,16 @@
     }
 
     public void run() {
+        compileAndTime("simple");
         compileAndTime("complex");
-        compileAndTime("simple");
+        if (CompileTheWorldClasspath.getValue() != SUN_BOOT_CLASS_PATH) {
+            CompileTheWorld ctw = new CompileTheWorld(CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(),
+                            CompileTheWorldStopAt.getValue(), CompileTheWorldVerbose.getValue());
+            try {
+                ctw.compile();
+            } catch (Throwable e) {
+                e.printStackTrace();
+            }
+        }
     }
 }