< prev index next >

test/lib/sun/hotspot/WhiteBox.java

Print this page
rev 1945 : 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
   1 /*
   2  * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 286   private native int     getMethodCompilationLevel0(Executable method, boolean isOsr);
 287   public         int     getMethodCompilationLevel(Executable method, boolean isOsr) {
 288     Objects.requireNonNull(method);
 289     return getMethodCompilationLevel0(method, isOsr);
 290   }
 291   private native boolean testSetDontInlineMethod0(Executable method, boolean value);
 292   public         boolean testSetDontInlineMethod(Executable method, boolean value) {
 293     Objects.requireNonNull(method);
 294     return testSetDontInlineMethod0(method, value);
 295   }
 296   public        int     getCompileQueuesSize() {
 297     return getCompileQueueSize(-1 /*any*/);
 298   }
 299   public native int     getCompileQueueSize(int compLevel);
 300   private native boolean testSetForceInlineMethod0(Executable method, boolean value);
 301   public         boolean testSetForceInlineMethod(Executable method, boolean value) {
 302     Objects.requireNonNull(method);
 303     return testSetForceInlineMethod0(method, value);
 304   }
 305   public        boolean enqueueMethodForCompilation(Executable method, int compLevel) {
 306     return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);





 307   }
 308   private native boolean enqueueMethodForCompilation0(Executable method, int compLevel, int entry_bci);
 309   public  boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci) {
 310     Objects.requireNonNull(method);
 311     return enqueueMethodForCompilation0(method, compLevel, entry_bci);














 312   }
 313   private native void    clearMethodState0(Executable method);
 314   public         void    clearMethodState(Executable method) {
 315     Objects.requireNonNull(method);
 316     clearMethodState0(method);
 317   }
 318   public native void    lockCompilation();
 319   public native void    unlockCompilation();
 320   private native int     getMethodEntryBci0(Executable method);
 321   public         int     getMethodEntryBci(Executable method) {
 322     Objects.requireNonNull(method);
 323     return getMethodEntryBci0(method);
 324   }
 325   private native Object[] getNMethod0(Executable method, boolean isOsr);
 326   public         Object[] getNMethod(Executable method, boolean isOsr) {
 327     Objects.requireNonNull(method);
 328     return getNMethod0(method, isOsr);
 329   }
 330   public native long    allocateCodeBlob(int size, int type);
 331   public        long    allocateCodeBlob(long size, int type) {


 438   private final List<BiFunction<Executable,String,Object>> methodOptionGetters
 439       = Arrays.asList(this::getMethodBooleanOption, this::getMethodIntxOption,
 440           this::getMethodUintxOption, this::getMethodDoubleOption,
 441           this::getMethodStringOption);
 442 
 443   public Object getMethodOption(Executable method, String name) {
 444     return methodOptionGetters.stream()
 445                               .map(f -> f.apply(method, name))
 446                               .filter(x -> x != null)
 447                               .findAny()
 448                               .orElse(null);
 449   }
 450 
 451   // Safepoint Checking
 452   public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue);
 453 
 454   // Sharing
 455   public native boolean isSharedClass(Class<?> c);
 456   public native boolean isShared(Object o);
 457   public native boolean areSharedStringsIgnored();




 458 }
   1 /*
   2  * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 286   private native int     getMethodCompilationLevel0(Executable method, boolean isOsr);
 287   public         int     getMethodCompilationLevel(Executable method, boolean isOsr) {
 288     Objects.requireNonNull(method);
 289     return getMethodCompilationLevel0(method, isOsr);
 290   }
 291   private native boolean testSetDontInlineMethod0(Executable method, boolean value);
 292   public         boolean testSetDontInlineMethod(Executable method, boolean value) {
 293     Objects.requireNonNull(method);
 294     return testSetDontInlineMethod0(method, value);
 295   }
 296   public        int     getCompileQueuesSize() {
 297     return getCompileQueueSize(-1 /*any*/);
 298   }
 299   public native int     getCompileQueueSize(int compLevel);
 300   private native boolean testSetForceInlineMethod0(Executable method, boolean value);
 301   public         boolean testSetForceInlineMethod(Executable method, boolean value) {
 302     Objects.requireNonNull(method);
 303     return testSetForceInlineMethod0(method, value);
 304   }
 305   public        boolean enqueueMethodForCompilation(Executable method, int compLevel) {
 306     return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/, false);
 307   }
 308   // This is a convenience method for doing blocking compiles.
 309   // It adds a new compiler directive which may shadow previously added directives!
 310   public        boolean enqueueMethodForCompilation(Executable method, int compLevel, boolean block) {
 311         return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/, block);
 312   }
 313   private native boolean enqueueMethodForCompilation0(Executable method, int compLevel, int entry_bci);
 314   public  boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci) {
 315     return enqueueMethodForCompilation(method, compLevel, entry_bci, false);
 316   }
 317   // This is a convenience method for doing blocking compiles.
 318   // It adds a new compiler directive which may shadow previously added directives!
 319   public  boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci, boolean block) {
 320     Objects.requireNonNull(method);
 321     if (block) {
 322       String comp = (compLevel == 4) ? "c2: {" : "c1: {";
 323       addCompilerDirective("[{ match: \"" + method.getDeclaringClass().getName() + "::" + method.getName() + "\", " +
 324                            comp + "BackgroundCompilation: false }}]");
 325     }
 326     boolean ret = enqueueMethodForCompilation0(method, compLevel, entry_bci);
 327     if (block) {
 328       removeCompilerDirective(1);
 329     }
 330     return ret;
 331   }
 332   private native void    clearMethodState0(Executable method);
 333   public         void    clearMethodState(Executable method) {
 334     Objects.requireNonNull(method);
 335     clearMethodState0(method);
 336   }
 337   public native void    lockCompilation();
 338   public native void    unlockCompilation();
 339   private native int     getMethodEntryBci0(Executable method);
 340   public         int     getMethodEntryBci(Executable method) {
 341     Objects.requireNonNull(method);
 342     return getMethodEntryBci0(method);
 343   }
 344   private native Object[] getNMethod0(Executable method, boolean isOsr);
 345   public         Object[] getNMethod(Executable method, boolean isOsr) {
 346     Objects.requireNonNull(method);
 347     return getNMethod0(method, isOsr);
 348   }
 349   public native long    allocateCodeBlob(int size, int type);
 350   public        long    allocateCodeBlob(long size, int type) {


 457   private final List<BiFunction<Executable,String,Object>> methodOptionGetters
 458       = Arrays.asList(this::getMethodBooleanOption, this::getMethodIntxOption,
 459           this::getMethodUintxOption, this::getMethodDoubleOption,
 460           this::getMethodStringOption);
 461 
 462   public Object getMethodOption(Executable method, String name) {
 463     return methodOptionGetters.stream()
 464                               .map(f -> f.apply(method, name))
 465                               .filter(x -> x != null)
 466                               .findAny()
 467                               .orElse(null);
 468   }
 469 
 470   // Safepoint Checking
 471   public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue);
 472 
 473   // Sharing
 474   public native boolean isSharedClass(Class<?> c);
 475   public native boolean isShared(Object o);
 476   public native boolean areSharedStringsIgnored();
 477 
 478   // Compiler Directive
 479   public native int addCompilerDirective(String compDirect);
 480   public native void removeCompilerDirective(int count);
 481 }
< prev index next >