# HG changeset patch # User simonis # Date 1456936314 -3600 # Wed Mar 02 17:31:54 2016 +0100 # Node ID 3d4b1e16aab73776f339bf74ca021bdb2eebabf0 # Parent add4d35c3625f219020fead9262236cfdbbdf47b 8150646: Add support for blocking compiles though whitebox API Reviewed-by: kvn, ppunegov, simonis, neliasso Contributed-by: nils.eliasson@oracle.com, volker.simonis@gmail.com diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -303,12 +303,31 @@ return testSetForceInlineMethod0(method, value); } public boolean enqueueMethodForCompilation(Executable method, int compLevel) { - return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/); + return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/, false); + } + // This is a convenience method for doing blocking compiles. + // It adds a new compiler directive which may shadow previously added directives! + public boolean enqueueMethodForCompilation(Executable method, int compLevel, boolean block) { + return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/, block); } private native boolean enqueueMethodForCompilation0(Executable method, int compLevel, int entry_bci); public boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci) { + return enqueueMethodForCompilation(method, compLevel, entry_bci, false); + } + // This is a convenience method for doing blocking compiles. + // It adds a new compiler directive which may shadow previously added directives! + public boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci, boolean block) { Objects.requireNonNull(method); - return enqueueMethodForCompilation0(method, compLevel, entry_bci); + if (block) { + String comp = (compLevel == 4) ? "c2: {" : "c1: {"; + addCompilerDirective("[{ match: \"" + method.getDeclaringClass().getName() + "::" + method.getName() + "\", " + + comp + "BackgroundCompilation: false }}]"); + } + boolean ret = enqueueMethodForCompilation0(method, compLevel, entry_bci); + if (block) { + removeCompilerDirective(1); + } + return ret; } private native void clearMethodState0(Executable method); public void clearMethodState(Executable method) { @@ -455,4 +474,8 @@ public native boolean isSharedClass(Class c); public native boolean isShared(Object o); public native boolean areSharedStringsIgnored(); + + // Compiler Directive + public native int addCompilerDirective(String compDirect); + public native void removeCompilerDirective(int count); }