# HG changeset patch # User Christian Wimmer # Date 1327011230 28800 # Node ID 79af35bd9fd74effa67ede84824cb45de4e8c30d # Parent 8dd27e218e192dbf6ae363203b31043afd5b64e5 Bootstrap with a syncrhonized method to avoid later deoptimization when the first real synchronized method is compiled. diff -r 8dd27e218e19 -r 79af35bd9fd7 graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/bridge/VMToCompilerImpl.java --- 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 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;