changeset 4313:79af35bd9fd7

Bootstrap with a syncrhonized method to avoid later deoptimization when the first real synchronized method is compiled.
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Thu, 19 Jan 2012 14:13:50 -0800
parents 8dd27e218e19
children 9ce8594bedaf
files graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Thu Jan 19 19:06:25 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java	Thu Jan 19 14:13:50 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -120,6 +120,17 @@
         }
     }
 
+    /**
+     * This method is the first method compiled during bootstrapping. Put any code in there that
+     * warms up compiler paths that are otherwise no exercised during bootstrapping and lead to later
+     * deoptimization when application code is compiled.
+     */
+    @SuppressWarnings("unused")
+    @Deprecated
+    private synchronized void compileWarmup() {
+        // Method is synchronized to exercise the synchronization code in the compiler.
+    }
+
     public void bootstrap() throws Throwable {
         TTY.print("Bootstrapping Graal");
         TTY.flush();
@@ -127,12 +138,13 @@
 
         // Initialize compile queue with a selected set of methods.
         Class<Object> objectKlass = Object.class;
+        enqueue(getClass().getDeclaredMethod("compileWarmup"));
         enqueue(objectKlass.getDeclaredMethod("equals", Object.class));
         enqueue(objectKlass.getDeclaredMethod("toString"));
 
         // Compile until the queue is empty.
         int z = 0;
-        while (compileQueue.getCompletedTaskCount() < Math.max(2, compileQueue.getTaskCount())) {
+        while (compileQueue.getCompletedTaskCount() < Math.max(3, compileQueue.getTaskCount())) {
             Thread.sleep(100);
             while (z < compileQueue.getCompletedTaskCount() / 100) {
                 ++z;