test/lib/sun/hotspot/WhiteBox.java
author neliasso
Tue, 20 Oct 2015 18:07:24 +0200
changeset 33432 d3cbcb934612
parent 33045 00f484891bcf
child 34487 db155554abc0
child 34113 210cb6523c6e
permissions -rw-r--r--
8137167: JEP165: Compiler Control: Implementation task Summary: Compiler Control JEP Reviewed-by: roland, twisti, zmajo, simonis
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     1
/*
29562
779fa8e10961 8069111: Investigate NMT detail tracking support for 32bit ARM
cjplummer
parents: 28351
diff changeset
     2
 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     4
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     8
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    13
 * accompanied this code).
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    14
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    18
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    21
 * questions.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    22
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    23
 */
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    24
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    25
package sun.hotspot;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    26
29664
54de61fbee04 8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
azakharov
parents: 28351
diff changeset
    27
import java.lang.management.MemoryUsage;
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    28
import java.lang.reflect.Executable;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    29
import java.util.Arrays;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    30
import java.util.List;
29440
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
    31
import java.util.function.BiFunction;
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    32
import java.util.function.Function;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    33
import java.security.BasicPermission;
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    34
import java.util.Objects;
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    35
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    36
import sun.hotspot.parser.DiagnosticCommand;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    37
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    38
public class WhiteBox {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    39
  @SuppressWarnings("serial")
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    40
  public static class WhiteBoxPermission extends BasicPermission {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    41
    public WhiteBoxPermission(String s) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    42
      super(s);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    43
    }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    44
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    45
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    46
  private WhiteBox() {}
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    47
  private static final WhiteBox instance = new WhiteBox();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    48
  private static native void registerNatives();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    49
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    50
  /**
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    51
   * Returns the singleton WhiteBox instance.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    52
   *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    53
   * The returned WhiteBox object should be carefully guarded
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    54
   * by the caller, since it can be used to read and write data
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    55
   * at arbitrary memory addresses. It must never be passed to
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    56
   * untrusted code.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    57
   */
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    58
  public synchronized static WhiteBox getWhiteBox() {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    59
    SecurityManager sm = System.getSecurityManager();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    60
    if (sm != null) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    61
      sm.checkPermission(new WhiteBoxPermission("getInstance"));
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    62
    }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    63
    return instance;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    64
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    65
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    66
  static {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    67
    registerNatives();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    68
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    69
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    70
  // Get the maximum heap size supporting COOPs
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    71
  public native long getCompressedOopsMaxHeapSize();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    72
  // Arguments
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    73
  public native void printHeapSizes();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    74
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    75
  // Memory
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    76
  private native long getObjectAddress0(Object o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    77
  public           long getObjectAddress(Object o) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    78
    Objects.requireNonNull(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    79
    return getObjectAddress0(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    80
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    81
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    82
  public native int  getHeapOopSize();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    83
  public native int  getVMPageSize();
31320
5358f1744a3f 8079208: gc/g1/TestLargePageUseForAuxMemory.java fails due to not considering page allocation granularity for setup
tschatzl
parents: 31317
diff changeset
    84
  public native long getVMAllocationGranularity();
30078
cecb6ee4437a 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 30077
diff changeset
    85
  public native long getVMLargePageSize();
32557
4a6715919601 8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents: 32556
diff changeset
    86
  public native long getHeapSpaceAlignment();
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    87
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    88
  private native boolean isObjectInOldGen0(Object o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    89
  public         boolean isObjectInOldGen(Object o) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    90
    Objects.requireNonNull(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    91
    return isObjectInOldGen0(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    92
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    93
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    94
  private native long getObjectSize0(Object o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    95
  public         long getObjectSize(Object o) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    96
    Objects.requireNonNull(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    97
    return getObjectSize0(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
    98
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    99
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   100
  // Runtime
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   101
  // Make sure class name is in the correct format
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   102
  public boolean isClassAlive(String name) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   103
    return isClassAlive0(name.replace('.', '/'));
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   104
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   105
  private native boolean isClassAlive0(String name);
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   106
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   107
  private native boolean isMonitorInflated0(Object obj);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   108
  public         boolean isMonitorInflated(Object obj) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   109
    Objects.requireNonNull(obj);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   110
    return isMonitorInflated0(obj);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   111
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   112
28351
bbdca807711d 8068272: Extend WhiteBox API with methods that check monitor state and force safepoint
fzhinkin
parents: 28159
diff changeset
   113
  public native void forceSafepoint();
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   114
33045
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   115
  private native long getConstantPool0(Class<?> aClass);
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   116
  public         long getConstantPool(Class<?> aClass) {
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   117
    Objects.requireNonNull(aClass);
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   118
    return getConstantPool0(aClass);
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   119
  }
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   120
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   121
  // JVMTI
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   122
  private native void addToBootstrapClassLoaderSearch0(String segment);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   123
  public         void addToBootstrapClassLoaderSearch(String segment){
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   124
    Objects.requireNonNull(segment);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   125
    addToBootstrapClassLoaderSearch0(segment);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   126
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   127
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   128
  private native void addToSystemClassLoaderSearch0(String segment);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   129
  public         void addToSystemClassLoaderSearch(String segment) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   130
    Objects.requireNonNull(segment);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   131
    addToSystemClassLoaderSearch0(segment);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   132
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   133
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   134
  // G1
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   135
  public native boolean g1InConcurrentMark();
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   136
  private native boolean g1IsHumongous0(Object o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   137
  public         boolean g1IsHumongous(Object o) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   138
    Objects.requireNonNull(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   139
    return g1IsHumongous0(o);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   140
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   141
29664
54de61fbee04 8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
azakharov
parents: 28351
diff changeset
   142
  public native long    g1NumMaxRegions();
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   143
  public native long    g1NumFreeRegions();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   144
  public native int     g1RegionSize();
29664
54de61fbee04 8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
azakharov
parents: 28351
diff changeset
   145
  public native MemoryUsage g1AuxiliaryMemoryUsage();
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   146
  private  native Object[]    parseCommandLine0(String commandline, char delim, DiagnosticCommand[] args);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   147
  public          Object[]    parseCommandLine(String commandline, char delim, DiagnosticCommand[] args) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   148
    Objects.requireNonNull(args);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   149
    return parseCommandLine0(commandline, delim, args);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   150
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   151
32557
4a6715919601 8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents: 32556
diff changeset
   152
  // Parallel GC
4a6715919601 8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents: 32556
diff changeset
   153
  public native long psVirtualSpaceAlignment();
4a6715919601 8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents: 32556
diff changeset
   154
  public native long psHeapGenerationAlignment();
4a6715919601 8081317: [NEWTEST] documented GC ratio tuning and new size options should be covered by regression tests
mchernov
parents: 32556
diff changeset
   155
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   156
  // NMT
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   157
  public native long NMTMalloc(long size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   158
  public native void NMTFree(long mem);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   159
  public native long NMTReserveMemory(long size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   160
  public native void NMTCommitMemory(long addr, long size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   161
  public native void NMTUncommitMemory(long addr, long size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   162
  public native void NMTReleaseMemory(long addr, long size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   163
  public native long NMTMallocWithPseudoStack(long size, int index);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   164
  public native boolean NMTChangeTrackingLevel();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   165
  public native int NMTGetHashSize();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   166
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   167
  // Compiler
33038
5d648743b2d1 8135068: Extract method matchers from CompilerOracle
neliasso
parents: 32557
diff changeset
   168
  public native int     matchesMethod(Executable method, String pattern);
33432
d3cbcb934612 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33045
diff changeset
   169
  public native int     matchesInline(Executable method, String pattern);
d3cbcb934612 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33045
diff changeset
   170
  public native boolean shouldPrintAssembly(Executable method);
28157
1305bf148a19 8028595: WhiteBox API for stress testing of TieredCompilation
iignatyev
parents: 28154
diff changeset
   171
  public native int     deoptimizeFrames(boolean makeNotEntrant);
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   172
  public native void    deoptimizeAll();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   173
  public        boolean isMethodCompiled(Executable method) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   174
    return isMethodCompiled(method, false /*not osr*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   175
  }
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   176
  private native boolean isMethodCompiled0(Executable method, boolean isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   177
  public         boolean isMethodCompiled(Executable method, boolean isOsr){
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   178
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   179
    return isMethodCompiled0(method, isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   180
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   181
  public        boolean isMethodCompilable(Executable method) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   182
    return isMethodCompilable(method, -1 /*any*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   183
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   184
  public        boolean isMethodCompilable(Executable method, int compLevel) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   185
    return isMethodCompilable(method, compLevel, false /*not osr*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   186
  }
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   187
  private native boolean isMethodCompilable0(Executable method, int compLevel, boolean isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   188
  public         boolean isMethodCompilable(Executable method, int compLevel, boolean isOsr) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   189
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   190
    return isMethodCompilable0(method, compLevel, isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   191
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   192
  private native boolean isMethodQueuedForCompilation0(Executable method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   193
  public         boolean isMethodQueuedForCompilation(Executable method) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   194
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   195
    return isMethodQueuedForCompilation0(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   196
  }
31949
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   197
  // Determine if the compiler corresponding to the compilation level 'compLevel'
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   198
  // and to the compilation context 'compilation_context' provides an intrinsic
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   199
  // for the method 'method'. An intrinsic is available for method 'method' if:
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   200
  //  - the intrinsic is enabled (by using the appropriate command-line flag) and
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   201
  //  - the platform on which the VM is running provides the instructions necessary
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   202
  //    for the compiler to generate the intrinsic code.
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   203
  //
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   204
  // The compilation context is related to using the DisableIntrinsic flag on a
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   205
  // per-method level, see hotspot/src/share/vm/compiler/abstractCompiler.hpp
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   206
  // for more details.
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   207
  public boolean isIntrinsicAvailable(Executable method,
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   208
                                      Executable compilationContext,
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   209
                                      int compLevel) {
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   210
      Objects.requireNonNull(method);
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   211
      return isIntrinsicAvailable0(method, compilationContext, compLevel);
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   212
  }
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   213
  // If usage of the DisableIntrinsic flag is not expected (or the usage can be ignored),
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   214
  // use the below method that does not require the compilation context as argument.
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   215
  public boolean isIntrinsicAvailable(Executable method, int compLevel) {
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   216
      return isIntrinsicAvailable(method, null, compLevel);
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   217
  }
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   218
  private native boolean isIntrinsicAvailable0(Executable method,
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   219
                                               Executable compilationContext,
ddd0594084a7 8130832: Extend the WhiteBox API to provide information about the availability of compiler intrinsics
zmajo
parents: 31572
diff changeset
   220
                                               int compLevel);
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   221
  public        int     deoptimizeMethod(Executable method) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   222
    return deoptimizeMethod(method, false /*not osr*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   223
  }
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   224
  private native int     deoptimizeMethod0(Executable method, boolean isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   225
  public         int     deoptimizeMethod(Executable method, boolean isOsr) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   226
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   227
    return deoptimizeMethod0(method, isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   228
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   229
  public        void    makeMethodNotCompilable(Executable method) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   230
    makeMethodNotCompilable(method, -1 /*any*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   231
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   232
  public        void    makeMethodNotCompilable(Executable method, int compLevel) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   233
    makeMethodNotCompilable(method, compLevel, false /*not osr*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   234
  }
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   235
  private native void    makeMethodNotCompilable0(Executable method, int compLevel, boolean isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   236
  public         void    makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   237
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   238
    makeMethodNotCompilable0(method, compLevel, isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   239
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   240
  public        int     getMethodCompilationLevel(Executable method) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   241
    return getMethodCompilationLevel(method, false /*not ost*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   242
  }
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   243
  private native int     getMethodCompilationLevel0(Executable method, boolean isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   244
  public         int     getMethodCompilationLevel(Executable method, boolean isOsr) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   245
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   246
    return getMethodCompilationLevel0(method, isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   247
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   248
  private native boolean testSetDontInlineMethod0(Executable method, boolean value);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   249
  public         boolean testSetDontInlineMethod(Executable method, boolean value) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   250
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   251
    return testSetDontInlineMethod0(method, value);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   252
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   253
  public        int     getCompileQueuesSize() {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   254
    return getCompileQueueSize(-1 /*any*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   255
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   256
  public native int     getCompileQueueSize(int compLevel);
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   257
  private native boolean testSetForceInlineMethod0(Executable method, boolean value);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   258
  public         boolean testSetForceInlineMethod(Executable method, boolean value) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   259
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   260
    return testSetForceInlineMethod0(method, value);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   261
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   262
  public        boolean enqueueMethodForCompilation(Executable method, int compLevel) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   263
    return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   264
  }
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   265
  private native boolean enqueueMethodForCompilation0(Executable method, int compLevel, int entry_bci);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   266
  public  boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   267
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   268
    return enqueueMethodForCompilation0(method, compLevel, entry_bci);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   269
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   270
  private native void    clearMethodState0(Executable method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   271
  public         void    clearMethodState(Executable method) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   272
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   273
    clearMethodState0(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   274
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   275
  public native void    lockCompilation();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   276
  public native void    unlockCompilation();
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   277
  private native int     getMethodEntryBci0(Executable method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   278
  public         int     getMethodEntryBci(Executable method) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   279
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   280
    return getMethodEntryBci0(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   281
  }
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   282
  private native Object[] getNMethod0(Executable method, boolean isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   283
  public         Object[] getNMethod(Executable method, boolean isOsr) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   284
    Objects.requireNonNull(method);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   285
    return getNMethod0(method, isOsr);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   286
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   287
  public native long    allocateCodeBlob(int size, int type);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   288
  public        long    allocateCodeBlob(long size, int type) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   289
      int intSize = (int) size;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   290
      if ((long) intSize != size || size < 0) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   291
          throw new IllegalArgumentException(
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   292
                "size argument has illegal value " + size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   293
      }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   294
      return allocateCodeBlob( intSize, type);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   295
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   296
  public native void    freeCodeBlob(long addr);
30081
2dd31ea5f49c 8075214: SIGSEGV in nmethod sweeping
thartmann
parents: 29666
diff changeset
   297
  public native void    forceNMethodSweep();
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   298
  public native Object[] getCodeHeapEntries(int type);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   299
  public native int     getCompilationActivityMode();
33045
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   300
  private native long getMethodData0(Executable method);
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   301
  public         long getMethodData(Executable method) {
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   302
    Objects.requireNonNull(method);
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   303
    return getMethodData0(method);
00f484891bcf 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33038
diff changeset
   304
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   305
  public native Object[] getCodeBlob(long addr);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   306
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   307
  // Intered strings
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   308
  public native boolean isInStringTable(String str);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   309
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   310
  // Memory
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   311
  public native void readReservedMemory();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   312
  public native long allocateMetaspace(ClassLoader classLoader, long size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   313
  public native void freeMetaspace(ClassLoader classLoader, long addr, long size);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   314
  public native long incMetaspaceCapacityUntilGC(long increment);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   315
  public native long metaspaceCapacityUntilGC();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   316
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   317
  // Force Young GC
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   318
  public native void youngGC();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   319
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   320
  // Force Full GC
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   321
  public native void fullGC();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   322
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   323
  // Method tries to start concurrent mark cycle.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   324
  // It returns false if CM Thread is always in concurrent cycle.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   325
  public native boolean g1StartConcMarkCycle();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   326
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   327
  // Tests on ReservedSpace/VirtualSpace classes
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   328
  public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   329
  public native void runMemoryUnitTests();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   330
  public native void readFromNoaccessArea();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   331
  public native long getThreadStackSize();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   332
  public native long getThreadRemainingStackSize();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   333
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   334
  // CPU features
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   335
  public native String getCPUFeatures();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   336
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   337
  // Native extensions
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   338
  public native long getHeapUsageForContext(int context);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   339
  public native long getHeapRegionCountForContext(int context);
30077
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   340
  private native int getContextForObject0(Object obj);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   341
  public         int getContextForObject(Object obj) {
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   342
    Objects.requireNonNull(obj);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   343
    return getContextForObject0(obj);
1b49d946a1c8 8043225: Make whitebox API functions more stable
iignatyev
parents: 29666
diff changeset
   344
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   345
  public native void printRegionInfo(int context);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   346
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   347
  // VM flags
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   348
  public native boolean isConstantVMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   349
  public native boolean isLockedVMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   350
  public native void    setBooleanVMFlag(String name, boolean value);
31221
72b40bd3f4ee 8080947: Add uint as a valid VM flag type
david
parents: 30083
diff changeset
   351
  public native void    setIntVMFlag(String name, long value);
72b40bd3f4ee 8080947: Add uint as a valid VM flag type
david
parents: 30083
diff changeset
   352
  public native void    setUintVMFlag(String name, long value);
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   353
  public native void    setIntxVMFlag(String name, long value);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   354
  public native void    setUintxVMFlag(String name, long value);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   355
  public native void    setUint64VMFlag(String name, long value);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   356
  public native void    setSizeTVMFlag(String name, long value);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   357
  public native void    setStringVMFlag(String name, String value);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   358
  public native void    setDoubleVMFlag(String name, double value);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   359
  public native Boolean getBooleanVMFlag(String name);
31221
72b40bd3f4ee 8080947: Add uint as a valid VM flag type
david
parents: 30083
diff changeset
   360
  public native Long    getIntVMFlag(String name);
72b40bd3f4ee 8080947: Add uint as a valid VM flag type
david
parents: 30083
diff changeset
   361
  public native Long    getUintVMFlag(String name);
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   362
  public native Long    getIntxVMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   363
  public native Long    getUintxVMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   364
  public native Long    getUint64VMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   365
  public native Long    getSizeTVMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   366
  public native String  getStringVMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   367
  public native Double  getDoubleVMFlag(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   368
  private final List<Function<String,Object>> flagsGetters = Arrays.asList(
31221
72b40bd3f4ee 8080947: Add uint as a valid VM flag type
david
parents: 30083
diff changeset
   369
    this::getBooleanVMFlag, this::getIntVMFlag, this::getUintVMFlag,
72b40bd3f4ee 8080947: Add uint as a valid VM flag type
david
parents: 30083
diff changeset
   370
    this::getIntxVMFlag, this::getUintxVMFlag, this::getUint64VMFlag,
72b40bd3f4ee 8080947: Add uint as a valid VM flag type
david
parents: 30083
diff changeset
   371
    this::getSizeTVMFlag, this::getStringVMFlag, this::getDoubleVMFlag);
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   372
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   373
  public Object getVMFlag(String name) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   374
    return flagsGetters.stream()
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   375
                       .map(f -> f.apply(name))
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   376
                       .filter(x -> x != null)
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   377
                       .findAny()
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   378
                       .orElse(null);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   379
  }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   380
  public native int getOffsetForName0(String name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   381
  public int getOffsetForName(String name) throws Exception {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   382
    int offset = getOffsetForName0(name);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   383
    if (offset == -1) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   384
      throw new RuntimeException(name + " not found");
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   385
    }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   386
    return offset;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   387
  }
29440
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   388
  public native Boolean getMethodBooleanOption(Executable method, String name);
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   389
  public native Long    getMethodIntxOption(Executable method, String name);
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   390
  public native Long    getMethodUintxOption(Executable method, String name);
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   391
  public native Double  getMethodDoubleOption(Executable method, String name);
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   392
  public native String  getMethodStringOption(Executable method, String name);
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   393
  private final List<BiFunction<Executable,String,Object>> methodOptionGetters
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   394
      = Arrays.asList(this::getMethodBooleanOption, this::getMethodIntxOption,
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   395
          this::getMethodUintxOption, this::getMethodDoubleOption,
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   396
          this::getMethodStringOption);
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   397
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   398
  public Object getMethodOption(Executable method, String name) {
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   399
    return methodOptionGetters.stream()
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   400
                              .map(f -> f.apply(method, name))
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   401
                              .filter(x -> x != null)
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   402
                              .findAny()
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   403
                              .orElse(null);
87390f81c75d 8074980: add WhiteBox API to get a flag value for a method
iignatyev
parents: 28351
diff changeset
   404
  }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   405
28159
d5940675c190 8067972: Bring changes made to WhiteBox.java in 8047290 to that file new location in the top repo
kvn
parents: 28157
diff changeset
   406
  // Safepoint Checking
d5940675c190 8067972: Bring changes made to WhiteBox.java in 8047290 to that file new location in the top repo
kvn
parents: 28157
diff changeset
   407
  public native void assertMatchingSafepointCalls(boolean mutexSafepointValue, boolean attemptedNoSafepointValue);
31314
f273a8edea25 8015086: add interned strings to the shared archive.
jiangli
parents: 31221
diff changeset
   408
f273a8edea25 8015086: add interned strings to the shared archive.
jiangli
parents: 31221
diff changeset
   409
  // Sharing
f273a8edea25 8015086: add interned strings to the shared archive.
jiangli
parents: 31221
diff changeset
   410
  public native boolean isShared(Object o);
31317
9029b3303113 8098821: Crash in system dictionary initialization with shared strings
mseledtsov
parents: 31314
diff changeset
   411
  public native boolean areSharedStringsIgnored();
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   412
}