--- old/test/compiler/whitebox/CompilerWhiteBoxTest.java 2014-10-22 15:44:19.340226483 +0200 +++ new/test/compiler/whitebox/CompilerWhiteBoxTest.java 2014-10-22 15:44:19.228226480 +0200 @@ -73,8 +73,6 @@ protected static final int THRESHOLD; /** invocation count to trigger OSR compilation */ protected static final long BACKEDGE_THRESHOLD; - /** invocation count to warm up method before triggering OSR compilation */ - protected static final long OSR_WARMUP = 2000; /** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */ protected static final String MODE = System.getProperty("java.vm.info"); @@ -498,8 +496,7 @@ = new Callable() { @Override public Integer call() throws Exception { - int result = warmup(OSR_CONSTRUCTOR); - return result + new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode(); + return new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode(); } }; @@ -509,8 +506,7 @@ @Override public Integer call() throws Exception { - int result = warmup(OSR_METHOD); - return result + helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD); + return helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD); } }; @@ -518,11 +514,54 @@ = new Callable() { @Override public Integer call() throws Exception { - int result = warmup(OSR_STATIC); - return result + osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD); + return osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD); } }; + private static final Constructor CONSTRUCTOR; + private static final Constructor OSR_CONSTRUCTOR; + private static final Method METHOD; + private static final Method STATIC; + private static final Method OSR_METHOD; + private static final Method OSR_STATIC; + + static { + try { + CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class); + } catch (NoSuchMethodException | SecurityException e) { + throw new RuntimeException( + "exception on getting method Helper.(int)", e); + } + try { + OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor( + Object.class, long.class); + } catch (NoSuchMethodException | SecurityException e) { + throw new RuntimeException( + "exception on getting method Helper.(Object, long)", e); + } + METHOD = getMethod("method"); + STATIC = getMethod("staticMethod"); + OSR_METHOD = getMethod("osrMethod", long.class); + OSR_STATIC = getMethod("osrStaticMethod", long.class); + } + + private static Method getMethod(String name, Class... parameterTypes) { + try { + return Helper.class.getDeclaredMethod(name, parameterTypes); + } catch (NoSuchMethodException | SecurityException e) { + throw new RuntimeException( + "exception on getting method Helper." + name, e); + } + } + + private static int staticMethod() { + return 1138; + } + + private int method() { + return 42; + } + /** * Deoptimizes all non-osr versions of the given executable after * compilation finished. @@ -549,11 +588,15 @@ * @throws Exception */ private static int warmup(Method m) throws Exception { + waitAndDeoptimize(m); Helper helper = new Helper(); int result = 0; - for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { + for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) { result += (int)m.invoke(helper, 1); } + // Wait to make sure OSR compilation is not blocked by + // non-OSR compilation in the compile queue + CompilerWhiteBoxTest.waitBackgroundCompilation(m); return result; } @@ -567,77 +610,35 @@ * @throws Exception */ private static int warmup(Constructor c) throws Exception { + waitAndDeoptimize(c); int result = 0; - for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { + for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) { result += c.newInstance(null, 1).hashCode(); } + // Wait to make sure OSR compilation is not blocked by + // non-OSR compilation in the compile queue + CompilerWhiteBoxTest.waitBackgroundCompilation(c); return result; } - private static final Constructor CONSTRUCTOR; - private static final Constructor OSR_CONSTRUCTOR; - private static final Method METHOD; - private static final Method STATIC; - private static final Method OSR_METHOD; - private static final Method OSR_STATIC; - - static { - try { - CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class); - } catch (NoSuchMethodException | SecurityException e) { - throw new RuntimeException( - "exception on getting method Helper.(int)", e); - } - try { - OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor( - Object.class, long.class); - } catch (NoSuchMethodException | SecurityException e) { - throw new RuntimeException( - "exception on getting method Helper.(Object, long)", e); - } - METHOD = getMethod("method"); - STATIC = getMethod("staticMethod"); - OSR_METHOD = getMethod("osrMethod", long.class); - OSR_STATIC = getMethod("osrStaticMethod", long.class); - } - - private static Method getMethod(String name, Class... parameterTypes) { - try { - return Helper.class.getDeclaredMethod(name, parameterTypes); - } catch (NoSuchMethodException | SecurityException e) { - throw new RuntimeException( - "exception on getting method Helper." + name, e); - } - } - - private static int staticMethod() { - return 1138; - } - - private int method() { - return 42; - } - - private static int osrStaticMethod(long limit) { + private static int osrStaticMethod(long limit) throws Exception { + int result = 0; if (limit != 1) { - // Make sure there is no compiled version after warmup - waitAndDeoptimize(OSR_STATIC); + result = warmup(OSR_STATIC); } // Trigger osr compilation - int result = 0; for (long i = 0; i < limit; ++i) { result += staticMethod(); } return result; } - private int osrMethod(long limit) { + private int osrMethod(long limit) throws Exception { + int result = 0; if (limit != 1) { - // Make sure there is no compiled version after warmup - waitAndDeoptimize(OSR_METHOD); + result = warmup(OSR_METHOD); } // Trigger osr compilation - int result = 0; for (long i = 0; i < limit; ++i) { result += method(); } @@ -652,13 +653,12 @@ } // for OSR constructor test case - private Helper(Object o, long limit) { + private Helper(Object o, long limit) throws Exception { + int result = 0; if (limit != 1) { - // Make sure there is no compiled version after warmup - waitAndDeoptimize(OSR_CONSTRUCTOR); + result = warmup(OSR_CONSTRUCTOR); } // Trigger osr compilation - int result = 0; for (long i = 0; i < limit; ++i) { result += method(); }