src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java
author lkorinth
Wed, 13 Nov 2019 11:37:29 +0100
changeset 59053 ba6c248cae19
parent 58842 6c255334120d
permissions -rw-r--r--
8232365: Implementation for JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector Reviewed-by: kbarrett, tschatzl, erikj, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53513
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.runtime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import java.net.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import java.util.regex.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.code.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.c1.*;
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 8878
diff changeset
    33
import sun.jvm.hotspot.code.*;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
import sun.jvm.hotspot.interpreter.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
import sun.jvm.hotspot.memory.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
import sun.jvm.hotspot.oops.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
import sun.jvm.hotspot.utilities.*;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    40
import sun.jvm.hotspot.runtime.*;
42889
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
    41
import sun.jvm.hotspot.classfile.*;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
/** <P> This class encapsulates the global state of the VM; the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    universe, object heap, interpreter, etc. It is a Singleton and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    must be initialized with a call to initialize() before calling
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    getVM(). </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    <P> Many auxiliary classes (i.e., most of the VMObjects) keep
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    needed field offsets in the form of static Field objects. In a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    debugging system, the VM might be shutdown and re-initialized (on
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    a differently-configured build, i.e., 32- vs. 64-bit), and all old
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    cached state (including fields and field offsets) must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    flushed. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    <P> An Observer pattern is used to implement the initialization of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    such classes. Each such class, in its static initializer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    registers an Observer with the VM class via
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    VM.registerVMInitializedObserver(). This Observer is guaranteed to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    be notified whenever the VM is initialized (or re-initialized). To
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    implement the first-time initialization, the observer is also
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    notified when it registers itself with the VM. (For bootstrapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    reasons, this implies that the constructor of VM can not
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    instantiate any such objects, since VM.soleInstance will not have
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    been set yet. This is a bootstrapping issue which may have to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    revisited later.) </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
public class VM {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  private static VM    soleInstance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  private static List  vmInitializedObservers = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  private List         vmResumedObservers   = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  private List         vmSuspendedObservers = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  private TypeDataBase db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  private boolean      isBigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  /** This is only present if in a debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  private JVMDebugger  debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  private long         stackBias;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  private long         logAddressSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  private Universe     universe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  private ObjectHeap   heap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  private SystemDictionary dict;
42889
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
    82
  private ClassLoaderDataGraph cldGraph;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  private Threads      threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  private ObjectSynchronizer synchronizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  private JNIHandles   handles;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  private Interpreter  interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  private StubRoutines stubRoutines;
49896
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
    88
  private FileMapInfo  fileMapInfo;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  private Bytes        bytes;
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 8878
diff changeset
    90
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
    91
  /** Flag indicating if JVMTI support is included in the build */
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
    92
  private boolean      isJvmtiSupported;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  /** Flags indicating whether we are attached to a core, C1, or C2 build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  private boolean      usingClientCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  private boolean      usingServerCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  /** alignment constants */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  private boolean      isLP64;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  private int          bytesPerLong;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
    99
  private int          bytesPerWord;
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   100
  private int          objectAlignmentInBytes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  private int          minObjAlignmentInBytes;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   102
  private int          logMinObjAlignmentInBytes;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   103
  private int          heapWordSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   104
  private int          heapOopSize;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   105
  private int          klassPtrSize;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   106
  private int          oopSize;
53637
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   107
  /** -XX flags (value origin) */
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   108
  public static int    Flags_DEFAULT;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   109
  public static int    Flags_COMMAND_LINE;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   110
  public static int    Flags_ENVIRON_VAR;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   111
  public static int    Flags_CONFIG_FILE;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   112
  public static int    Flags_MANAGEMENT;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   113
  public static int    Flags_ERGONOMIC;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   114
  public static int    Flags_ATTACH_ON_DEMAND;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   115
  public static int    Flags_INTERNAL;
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 54780
diff changeset
   116
  public static int    Flags_JIMAGE_RESOURCE;
53637
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   117
  private static int   Flags_VALUE_ORIGIN_MASK;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   118
  private static int   Flags_ORIG_COMMAND_LINE;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  /** This is only present in a non-core build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  private CodeCache    codeCache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  /** This is only present in a C1 build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  private Runtime1     runtime1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  /** These constants come from globalDefinitions.hpp */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  private int          invocationEntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  private ReversePtrs  revPtrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  private VMRegImpl    vmregImpl;
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   127
  private int          reserveForAllocationPrefetch;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // System.getProperties from debuggee VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  private Properties   sysProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // VM version strings come from Abstract_VM_Version class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  private String       vmRelease;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  private String       vmInternalInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  private Flag[] commandLineFlags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  private Map flagsMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   139
  private static Type intType;
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   140
  private static Type uintType;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  private static Type intxType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  private static Type uintxType;
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   143
  private static Type sizetType;
53513
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   144
  private static Type uint64tType;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  private static CIntegerType boolType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  private Boolean sharingEnabled;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   147
  private Boolean compressedOopsEnabled;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   148
  private Boolean compressedKlassPointersEnabled;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49896
diff changeset
   150
  // command line flags supplied to VM - see struct JVMFlag in jvmFlag.hpp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  public static final class Flag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
     private String type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
     private String name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
     private Address addr;
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   155
     private int flags;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   157
     private Flag(String type, String name, Address addr, int flags) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        this.type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
        this.name = name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
        this.addr = addr;
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   161
        this.flags = flags;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
     public String getType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
        return type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
     public String getName() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        return name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
     public Address getAddress() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
        return addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   176
     public int getOrigin() {
53637
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   177
        return flags & Flags_VALUE_ORIGIN_MASK;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   178
     }
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   179
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   180
     // See JVMFlag::print_origin() in HotSpot
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   181
     public String getOriginString() {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   182
        var origin = flags & Flags_VALUE_ORIGIN_MASK;
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   183
        if (origin == Flags_DEFAULT) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   184
            return "default";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   185
        } else if (origin == Flags_COMMAND_LINE) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   186
            return "command line";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   187
        } else if (origin == Flags_ENVIRON_VAR) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   188
            return "environment";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   189
        } else if (origin == Flags_CONFIG_FILE) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   190
            return "config file";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   191
        } else if (origin == Flags_MANAGEMENT) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   192
            return "management";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   193
        } else if (origin == Flags_ERGONOMIC) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   194
            String result = "";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   195
            if ((flags & Flags_ORIG_COMMAND_LINE) == Flags_ORIG_COMMAND_LINE) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   196
                result = "command line, ";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   197
            }
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   198
            return result + "ergonomic";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   199
        } else if (origin == Flags_ATTACH_ON_DEMAND) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   200
            return "attach";
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   201
        } else if (origin == Flags_INTERNAL) {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   202
            return "internal";
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 54780
diff changeset
   203
        } else if (origin == Flags_JIMAGE_RESOURCE) {
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 54780
diff changeset
   204
            return "jimage";
53637
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   205
        } else {
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   206
            throw new IllegalStateException(
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   207
                "Unknown flag origin " + origin + " is detected in " + name);
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   208
        }
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   209
     }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   210
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
     public boolean isBool() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
        return type.equals("bool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
     public boolean getBool() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
           Assert.that(isBool(), "not a bool flag!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
        }
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   219
        return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned()) != 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   222
     public boolean isInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   223
        return type.equals("int");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   224
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   225
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   226
     public long getInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   227
        if (Assert.ASSERTS_ENABLED) {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   228
           Assert.that(isInt(), "not an int flag!");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   229
        }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   230
        return addr.getCIntegerAt(0, intType.getSize(), false);
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   231
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   232
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   233
     public boolean isUInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   234
        return type.equals("uint");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   235
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   237
     public long getUInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   238
        if (Assert.ASSERTS_ENABLED) {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   239
           Assert.that(isUInt(), "not a uint flag!");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   240
        }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   241
        return addr.getCIntegerAt(0, uintType.getSize(), false);
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   242
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   243
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
     public boolean isIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
        return type.equals("intx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
     public long getIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
        if (Assert.ASSERTS_ENABLED) {
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   250
           Assert.that(isIntx(), "not an intx flag!");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
        return addr.getCIntegerAt(0, intxType.getSize(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
     public boolean isUIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        return type.equals("uintx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
     public long getUIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
           Assert.that(isUIntx(), "not a uintx flag!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        return addr.getCIntegerAt(0, uintxType.getSize(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   266
     public boolean isSizet() {
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   267
        return type.equals("size_t");
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   268
     }
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   269
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   270
     public long getSizet() {
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   271
        if (Assert.ASSERTS_ENABLED) {
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   272
           Assert.that(isSizet(), "not a size_t flag!");
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   273
        }
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   274
        return addr.getCIntegerAt(0, sizetType.getSize(), true);
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   275
     }
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   276
53513
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   277
     public boolean isCcstr() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   278
        return type.equals("ccstr");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   279
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   280
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   281
     public String getCcstr() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   282
        if (Assert.ASSERTS_ENABLED) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   283
           Assert.that(isCcstr(), "not a ccstr flag!");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   284
        }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   285
        return CStringUtilities.getString(addr.getAddressAt(0));
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   286
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   287
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   288
     public boolean isCcstrlist() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   289
        return type.equals("ccstrlist");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   290
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   291
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   292
     public String getCcstrlist() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   293
        if (Assert.ASSERTS_ENABLED) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   294
           Assert.that(isCcstrlist(), "not a ccstrlist flag!");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   295
        }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   296
        return CStringUtilities.getString(addr.getAddressAt(0));
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   297
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   298
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   299
     public boolean isDouble() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   300
        return type.equals("double");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   301
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   302
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   303
     public double getDouble() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   304
        if (Assert.ASSERTS_ENABLED) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   305
           Assert.that(isDouble(), "not a double flag!");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   306
        }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   307
        return addr.getJDoubleAt(0);
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   308
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   309
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   310
     public boolean isUint64t() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   311
        return type.equals("uint64_t");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   312
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   313
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   314
     public long getUint64t() {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   315
        if (Assert.ASSERTS_ENABLED) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   316
           Assert.that(isUint64t(), "not an uint64_t flag!");
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   317
        }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   318
        return addr.getCIntegerAt(0, uint64tType.getSize(), true);
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   319
     }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   320
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
     public String getValue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
        if (isBool()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   323
           return Boolean.toString(getBool());
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   324
        } else if (isInt()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   325
           return Long.toString(getInt());
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   326
        } else if (isUInt()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   327
           return Long.toString(getUInt());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
        } else if (isIntx()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   329
           return Long.toString(getIntx());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
        } else if (isUIntx()) {
53513
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   331
           return Long.toUnsignedString(getUIntx());
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   332
        } else if (isSizet()) {
53513
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   333
           return Long.toUnsignedString(getSizet());
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   334
        } else if (isCcstr()) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   335
           var str = getCcstr();
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   336
           if (str != null) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   337
               str = "\"" + str + "\"";
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   338
           }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   339
           return str;
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   340
        } else if (isCcstrlist()) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   341
           var str = getCcstrlist();
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   342
           if (str != null) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   343
               str = "\"" + str + "\"";
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   344
           }
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   345
           return str;
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   346
        } else if (isDouble()) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   347
           return Double.toString(getDouble());
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   348
        } else if (isUint64t()) {
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   349
           return Long.toUnsignedString(getUint64t());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
        } else {
53513
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   351
           throw new WrongTypeException("Unknown type: " + type + " (" + name + ")");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  private static void checkVMVersion(String vmRelease) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
     if (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
        // read sa build version.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
        String versionProp = "sun.jvm.hotspot.runtime.VM.saBuildVersion";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        String saVersion = saProps.getProperty(versionProp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        if (saVersion == null)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
           throw new RuntimeException("Missing property " + versionProp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        // Strip nonproduct VM version substring (note: saVersion doesn't have it).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
        String vmVersion = vmRelease.replaceAll("(-fastdebug)|(-debug)|(-jvmg)|(-optimized)|(-profiled)","");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
        if (saVersion.equals(vmVersion)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
           // Exact match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
           return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        if (saVersion.indexOf('-') == saVersion.lastIndexOf('-') &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
            vmVersion.indexOf('-') == vmVersion.lastIndexOf('-')) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
           // Throw exception if different release versions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
           // <major>.<minor>-b<n>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
           throw new VMVersionMismatchException(saVersion, vmRelease);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
           // Otherwise print warning to allow mismatch not release versions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
           // during development.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
           System.err.println("WARNING: Hotspot VM version " + vmRelease +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
                              " does not match with SA version " + saVersion +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
                              "." + " You may see unexpected results. ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
     } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
        System.err.println("WARNING: You have disabled SA and VM version check. You may be "  +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
                           "using incompatible version of SA and you may see unexpected " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
                           "results.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   390
  private static final boolean disableDerivedPointerTableCheck;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  private static final Properties saProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
     saProps = new Properties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
     URL url = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
     try {
30284
909da3c92522 8078519: Can't run SA tools from a non-images build
sla
parents: 29704
diff changeset
   397
       saProps.load(VM.class.getResourceAsStream("/sa.properties"));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
     } catch (Exception e) {
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   399
       System.err.println("Unable to load properties  " +
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
                                  (url == null ? "null" : url.toString()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
                                  ": " + e.getMessage());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   404
     disableDerivedPointerTableCheck = System.getProperty("sun.jvm.hotspot.runtime.VM.disableDerivedPointerTableCheck") != null;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    this.db          = db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    this.debugger    = debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
    this.isBigEndian = isBigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    // Note that we don't construct universe, heap, threads,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    // interpreter, or stubRoutines here (any more).  The current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    // initialization mechanisms require that the VM be completely set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    // up (i.e., out of its constructor, with soleInstance assigned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    // before their static initializers are run.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    if (db.getAddressSize() == 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      logAddressSize = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    } else if (db.getAddressSize() == 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      logAddressSize = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      throw new RuntimeException("Address size " + db.getAddressSize() + " not yet supported");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    // read VM version info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
       Type vmVersion = db.lookupType("Abstract_VM_Version");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
       Address releaseAddr = vmVersion.getAddressField("_s_vm_release").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
       vmRelease = CStringUtilities.getString(releaseAddr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
       Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
       vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr);
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   433
38220
8d86b82e0ac7 8153340: Disallow misconfiguration and improve the consistency of allocation prefetching
zmajo
parents: 35217
diff changeset
   434
       Type threadLocalAllocBuffer = db.lookupType("ThreadLocalAllocBuffer");
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   435
       CIntegerType intType = (CIntegerType) db.lookupType("int");
38220
8d86b82e0ac7 8153340: Disallow misconfiguration and improve the consistency of allocation prefetching
zmajo
parents: 35217
diff changeset
   436
       CIntegerField reserveForAllocationPrefetchField = threadLocalAllocBuffer.getCIntegerField("_reserve_for_allocation_prefetch");
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   437
       reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    } catch (Exception exp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
       throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    checkVMVersion(vmRelease);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    stackBias    = db.lookupIntConstant("STACK_BIAS").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   447
    // We infer the presence of JVMTI from the presence of the InstanceKlass::_breakpoints field.
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   448
    {
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   449
      Type type = db.lookupType("InstanceKlass");
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   450
      if (type.getField("_breakpoints", false, false) == null) {
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   451
        isJvmtiSupported = false;
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   452
      } else {
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   453
        isJvmtiSupported = true;
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   454
      }
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   455
    }
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   456
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    // We infer the presence of C1 or C2 from a couple of fields we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    // already have present in the type database
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   460
      Type type = db.lookupType("Method");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
      if (type.getField("_from_compiled_entry", false, false) == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
        // Neither C1 nor C2 is present
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
        usingClientCompiler = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
        usingServerCompiler = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
        // Determine whether C2 is present
10552
4c615382f246 7090654: nightly failures after 7086585
never
parents: 10547
diff changeset
   467
        if (db.lookupType("Matcher", false) != null) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
          usingServerCompiler = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
          usingClientCompiler = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
      isLP64 = debugger.getMachineDescription().isLP64();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   479
    bytesPerWord = db.lookupIntConstant("BytesPerWord").intValue();
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   480
    heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
53637
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   481
    Flags_DEFAULT = db.lookupIntConstant("JVMFlag::DEFAULT").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   482
    Flags_COMMAND_LINE = db.lookupIntConstant("JVMFlag::COMMAND_LINE").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   483
    Flags_ENVIRON_VAR = db.lookupIntConstant("JVMFlag::ENVIRON_VAR").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   484
    Flags_CONFIG_FILE = db.lookupIntConstant("JVMFlag::CONFIG_FILE").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   485
    Flags_MANAGEMENT = db.lookupIntConstant("JVMFlag::MANAGEMENT").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   486
    Flags_ERGONOMIC = db.lookupIntConstant("JVMFlag::ERGONOMIC").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   487
    Flags_ATTACH_ON_DEMAND = db.lookupIntConstant("JVMFlag::ATTACH_ON_DEMAND").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   488
    Flags_INTERNAL = db.lookupIntConstant("JVMFlag::INTERNAL").intValue();
58842
6c255334120d 8232080: jlink plugins for vendor information and run-time options
mr
parents: 54780
diff changeset
   489
    Flags_JIMAGE_RESOURCE = db.lookupIntConstant("JVMFlag::JIMAGE_RESOURCE").intValue();
53637
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   490
    Flags_VALUE_ORIGIN_MASK = db.lookupIntConstant("JVMFlag::VALUE_ORIGIN_MASK").intValue();
4366a1e4a021 8217845: SA should refer const values for JVMFlag from HotSpot
ysuenaga
parents: 53513
diff changeset
   491
    Flags_ORIG_COMMAND_LINE = db.lookupIntConstant("JVMFlag::ORIG_COMMAND_LINE").intValue();
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   492
    oopSize  = db.lookupIntConstant("oopSize").intValue();
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   493
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   494
    intType = db.lookupType("int");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   495
    uintType = db.lookupType("uint");
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   496
    intxType = db.lookupType("intx");
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   497
    uintxType = db.lookupType("uintx");
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   498
    sizetType = db.lookupType("size_t");
53513
8c035b34248d 8217612: (CL)HSDB cannot show some JVM flags
ysuenaga
parents: 50929
diff changeset
   499
    uint64tType = db.lookupType("uint64_t");
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   500
    boolType = (CIntegerType) db.lookupType("bool");
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   501
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   502
    minObjAlignmentInBytes = getObjectAlignmentInBytes();
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   503
    if (minObjAlignmentInBytes == 8) {
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   504
      logMinObjAlignmentInBytes = 3;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   505
    } else if (minObjAlignmentInBytes == 16) {
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   506
      logMinObjAlignmentInBytes = 4;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   507
    } else {
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   508
      throw new RuntimeException("Object alignment " + minObjAlignmentInBytes + " not yet supported");
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   509
    }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   510
2739
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   511
    if (isCompressedOopsEnabled()) {
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   512
      // Size info for oops within java objects is fixed
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   513
      heapOopSize = (int)getIntSize();
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   514
    } else {
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   515
      heapOopSize = (int)getOopSize();
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   516
    }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   517
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   518
    if (isCompressedKlassPointersEnabled()) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   519
      klassPtrSize = (int)getIntSize();
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   520
    } else {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   521
      klassPtrSize = (int)getOopSize(); // same as an oop
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   522
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  /** This could be used by a reflective runtime system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  public static void initialize(TypeDataBase db, boolean isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    if (soleInstance != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
      throw new RuntimeException("Attempt to initialize VM twice");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    soleInstance = new VM(db, null, isBigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  /** This is used by the debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  public static void initialize(TypeDataBase db, JVMDebugger debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    if (soleInstance != null) {
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   539
      // Using multiple SA Tool classes in the same process creates a call here.
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   540
      return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
2356
81a6245db120 6822407: heapOopSize lookup is incorrect in Serviceability Agent.
poonam
parents: 2267
diff changeset
   543
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    }
2262
51ebd610829b 6812971: SA: re-attaching to process fails
poonam
parents: 1135
diff changeset
   547
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   548
    debugger.putHeapConst(soleInstance.getHeapOopSize(), soleInstance.getKlassPtrSize(),
54780
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 53637
diff changeset
   549
                          CompressedOops.getBase(), CompressedOops.getShift(),
f8d182aedc92 8223136: Move compressed oops functions to CompressedOops class
stefank
parents: 53637
diff changeset
   550
                          CompressedKlassPointers.getBase(), CompressedKlassPointers.getShift());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  /** This is used by the debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  public static void shutdown() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
    soleInstance = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  /** This is used by both the debugger and any runtime system. It is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
      the basic mechanism by which classes which mimic underlying VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
      functionality cause themselves to be initialized. The given
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
      observer will be notified (with arguments (null, null)) when the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
      VM is re-initialized, as well as when it registers itself with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
      the VM. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  public static void registerVMInitializedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    vmInitializedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    o.update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  /** This is the primary accessor used by both the debugger and any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
      potential runtime system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  public static VM getVM() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    if (soleInstance == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
      throw new RuntimeException("VM.initialize() was not yet called");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    return soleInstance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  /** This is only used by the debugging system. The given observer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
      will be notified if the underlying VM resumes execution. NOTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
      that the given observer is not triggered if the VM is currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      running and therefore differs in behavior from {@link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
      #registerVMInitializedObserver} (because of the possibility of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
      race conditions if the observer is added while the VM is being
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
      suspended or resumed).  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  public void registerVMResumedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    vmResumedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  /** This is only used by the debugging system. The given observer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
      will be notified if the underlying VM suspends execution. NOTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
      that the given observer is not triggered if the VM is currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
      suspended and therefore differs in behavior from {@link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
      #registerVMInitializedObserver} (because of the possibility of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
      race conditions if the observer is added while the VM is being
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
      suspended or resumed).  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  public void registerVMSuspendedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    vmSuspendedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  /** This is only used by the debugging system. Informs all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
      registered resumption observers that the VM has been resumed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
      The application is responsible for actually having performed the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
      resumption. No OopHandles must be used after this point, as they
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      may move in the target address space due to garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
      collection. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  public void fireVMResumed() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
    for (Iterator iter = vmResumedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  /** This is only used by the debugging system. Informs all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
      registered suspension observers that the VM has been suspended.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
      The application is responsible for actually having performed the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
      suspension. Garbage collection must be forbidden at this point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
      for example, a JPDA-level suspension is not adequate since the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
      VM thread may still be running. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  public void fireVMSuspended() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    for (Iterator iter = vmSuspendedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  /** Returns the OS this VM is running on. Notice that by delegating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
      to the debugger we can transparently support remote
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
      debugging. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  public String getOS() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
      return debugger.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    return PlatformInfo.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  /** Returns the CPU this VM is running on. Notice that by delegating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
      to the debugger we can transparently support remote
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
      debugging. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  public String getCPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      return debugger.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    return PlatformInfo.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  public Type lookupType(String cTypeName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
    return db.lookupType(cTypeName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  public Integer lookupIntConstant(String name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    return db.lookupIntConstant(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
13873
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   652
  // Convenience function for conversions
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   653
  static public long getAddressValue(Address addr) {
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   654
    return VM.getVM().getDebugger().getAddressValue(addr);
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   655
  }
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   656
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  public long getAddressSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
    return db.getAddressSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  public long getOopSize() {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   662
    return oopSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  public long getLogAddressSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    return logAddressSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   669
  public long getIntSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   670
    return db.getJIntType().getSize();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   671
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   672
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  /** NOTE: this offset is in BYTES in this system! */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  public long getStackBias() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
    return stackBias;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  /** Indicates whether the underlying machine supports the LP64 data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
      model. This is needed for conditionalizing code in a few places */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  public boolean isLP64() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      Assert.that(isDebugging(), "Debugging system only for now");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
    return isLP64;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  /** Get bytes-per-long == long/double natural alignment. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  public int getBytesPerLong() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
    return bytesPerLong;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   692
  public int getBytesPerWord() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   693
    return bytesPerWord;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   694
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   695
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  /** Get minimum object alignment in bytes. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  public int getMinObjAlignmentInBytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
    return minObjAlignmentInBytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   700
  public int getLogMinObjAlignmentInBytes() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   701
    return logMinObjAlignmentInBytes;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   702
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   704
  public int getHeapWordSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   705
    return heapWordSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   706
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   707
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   708
  public int getHeapOopSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   709
    return heapOopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   710
  }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   711
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   712
  public int getKlassPtrSize() {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   713
    return klassPtrSize;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   714
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  /** Utility routine for getting data structure alignment correct */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  public long alignUp(long size, long alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
    return (size + alignment - 1) & ~(alignment - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  /** Utility routine for getting data structure alignment correct */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
  public long alignDown(long size, long alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
    return size & ~(alignment - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
  /** Utility routine for building an int from two "unsigned" 16-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
      shorts */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  public int buildIntFromShorts(short low, short high) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
    return (((int) high) << 16) | (((int) low) & 0xFFFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  /** Utility routine for building a long from two "unsigned" 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
      ints in <b>platform-dependent</b> order */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  public long buildLongFromIntsPD(int oneHalf, int otherHalf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    if (isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
      return (((long) otherHalf) << 32) | (((long) oneHalf) & 0x00000000FFFFFFFFL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
    } else{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
      return (((long) oneHalf) << 32) | (((long) otherHalf) & 0x00000000FFFFFFFFL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
  public TypeDataBase getTypeDataBase() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
    return db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
  public Universe    getUniverse() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
    if (universe == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
      universe = new Universe();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
    return universe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
  public ObjectHeap  getObjectHeap() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
    if (heap == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
      heap = new ObjectHeap(db);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
    return heap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  public SystemDictionary getSystemDictionary() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
    if (dict == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
      dict = new SystemDictionary();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
    return dict;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
42889
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   766
  public ClassLoaderDataGraph getClassLoaderDataGraph() {
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   767
    if (cldGraph == null) {
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   768
      cldGraph = new ClassLoaderDataGraph();
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   769
    }
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   770
    return cldGraph;
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   771
  }
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   772
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  public Threads     getThreads() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    if (threads == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
      threads = new Threads();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
    return threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  public ObjectSynchronizer getObjectSynchronizer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
    if (synchronizer == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
      synchronizer = new ObjectSynchronizer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    return synchronizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
  public JNIHandles getJNIHandles() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
    if (handles == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
      handles = new JNIHandles();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
    return handles;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
  public Interpreter getInterpreter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
    if (interpreter == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
      interpreter = new Interpreter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
    return interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
  public StubRoutines getStubRoutines() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    if (stubRoutines == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
      stubRoutines = new StubRoutines();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    return stubRoutines;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  public VMRegImpl getVMRegImplInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
    if (vmregImpl == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
      vmregImpl = new VMRegImpl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
    return vmregImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
49896
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   815
  public FileMapInfo getFileMapInfo() {
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   816
    if (!isSharingEnabled()) {
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   817
      return null;
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   818
    }
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   819
    if (fileMapInfo == null) {
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   820
      fileMapInfo = new FileMapInfo();
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   821
    }
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   822
    return fileMapInfo;
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   823
  }
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   824
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  public Bytes getBytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
    if (bytes == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
      bytes = new Bytes(debugger.getMachineDescription());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
    return bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   832
  /** Returns true if this is a isBigEndian, false otherwise */
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   833
  public boolean isBigEndian() {
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   834
    return isBigEndian;
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   835
  }
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   836
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   837
  /** Returns true if JVMTI is supported, false otherwise */
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   838
  public boolean isJvmtiSupported() {
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   839
    return isJvmtiSupported;
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   840
  }
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   841
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  /** Returns true if this is a "core" build, false if either C1 or C2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
      is present */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  public boolean isCore() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
    return (!(usingClientCompiler || usingServerCompiler));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  /** Returns true if this is a C1 build, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  public boolean isClientCompiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
    return usingClientCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  /** Returns true if this is a C2 build, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  public boolean isServerCompiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
    return usingServerCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  /** Returns true if C2 derived pointer table should be used, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  public boolean useDerivedPointerTable() {
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   860
    return !disableDerivedPointerTableCheck;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
  /** Returns the code cache; should not be used if is core build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  public CodeCache getCodeCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
      Assert.that(!isCore(), "noncore builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
    if (codeCache == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
      codeCache = new CodeCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
    return codeCache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  /** Should only be called for C1 builds */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
  public Runtime1 getRuntime1() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
      Assert.that(isClientCompiler(), "C1 builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
    if (runtime1 == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
      runtime1 = new Runtime1();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    return runtime1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
  /** Test to see whether we're in debugging mode (NOTE: this really
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
      should not be tested by this code; currently only used in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
      StackFrameStream) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  public boolean isDebugging() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
    return (debugger != null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
  /** This is only used by the debugging (i.e., non-runtime) system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  public JVMDebugger getDebugger() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
    if (debugger == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
      throw new RuntimeException("Attempt to use debugger in runtime system");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
    return debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
  /** Indicates whether a given program counter is in Java code. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
      includes but is not spanned by the interpreter and code cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
      Only used in the debugging system, for implementing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
      JavaThread.currentFrameGuess() on x86. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  public boolean isJavaPCDbg(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    // FIXME: this is not a complete enough set: must include areas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
    // like vtable stubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
    return (getInterpreter().contains(addr) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
            getCodeCache().contains(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  /** FIXME: figure out where to stick this */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  public int getInvocationEntryBCI() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
    return invocationEntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
  // FIXME: figure out where to stick this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
  public boolean wizardMode() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
  public ReversePtrs getRevPtrs() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
    return revPtrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  public void setRevPtrs(ReversePtrs rp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
    revPtrs = rp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  public String getVMRelease() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
    return vmRelease;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  public String getVMInternalInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
    return vmInternalInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   939
  public int getReserveForAllocationPrefetch() {
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   940
    return reserveForAllocationPrefetch;
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   941
  }
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   942
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  public boolean isSharingEnabled() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
    if (sharingEnabled == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
      Flag flag = getCommandLineFlag("UseSharedSpaces");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
      sharingEnabled = (flag == null)? Boolean.FALSE :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
          (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
    return sharingEnabled.booleanValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   952
  public boolean isCompressedOopsEnabled() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   953
    if (compressedOopsEnabled == null) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   954
        Flag flag = getCommandLineFlag("UseCompressedOops");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   955
        compressedOopsEnabled = (flag == null) ? Boolean.FALSE:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   956
             (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   957
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   958
    return compressedOopsEnabled.booleanValue();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   959
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   961
  public boolean isCompressedKlassPointersEnabled() {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   962
    if (compressedKlassPointersEnabled == null) {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 18481
diff changeset
   963
        Flag flag = getCommandLineFlag("UseCompressedClassPointers");
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   964
        compressedKlassPointersEnabled = (flag == null) ? Boolean.FALSE:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   965
             (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   966
    }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   967
    return compressedKlassPointersEnabled.booleanValue();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   968
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   969
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   970
  public int getObjectAlignmentInBytes() {
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   971
    if (objectAlignmentInBytes == 0) {
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   972
        Flag flag = getCommandLineFlag("ObjectAlignmentInBytes");
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   973
        objectAlignmentInBytes = (flag == null) ? 8 : (int)flag.getIntx();
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   974
    }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   975
    return objectAlignmentInBytes;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   976
  }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   977
15741
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   978
  /** Indicates whether Thread-Local Allocation Buffers are used */
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   979
  public boolean getUseTLAB() {
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   980
      Flag flag = getCommandLineFlag("UseTLAB");
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   981
      return (flag == null) ? false: flag.getBool();
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   982
  }
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   983
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   984
  public boolean getCommandLineBooleanFlag(String name) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   985
    Flag flag = getCommandLineFlag(name);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   986
    return (flag == null) ? Boolean.FALSE:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   987
      (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   988
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   989
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  public Flag[] getCommandLineFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
    if (commandLineFlags == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
       readCommandLineFlags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
    return commandLineFlags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
  public Flag getCommandLineFlag(String name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
    if (flagsMap == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
      flagsMap = new HashMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
      Flag[] flags = getCommandLineFlags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
      for (int i = 0; i < flags.length; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
        flagsMap.put(flags[i].getName(), flags[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
    return (Flag) flagsMap.get(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
  private void readCommandLineFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
    // get command line flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
    TypeDataBase db = getTypeDataBase();
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49896
diff changeset
  1013
    Type flagType = db.lookupType("JVMFlag");
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1014
    int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1015
    // NOTE: last flag contains null values.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1016
    commandLineFlags = new Flag[numFlags - 1];
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1017
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1018
    Address flagAddr = flagType.getAddressField("flags").getValue();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
  1020
    AddressField typeFld = flagType.getAddressField("_type");
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
  1021
    AddressField nameFld = flagType.getAddressField("_name");
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
  1022
    AddressField addrFld = flagType.getAddressField("_addr");
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
  1023
    CIntField flagsFld = new CIntField(flagType.getCIntegerField("_flags"), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1025
    long flagSize = flagType.getSize(); // sizeof(Flag)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1027
    // NOTE: last flag contains null values.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1028
    for (int f = 0; f < numFlags - 1; f++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1029
      String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1030
      String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1031
      Address addr = addrFld.getValue(flagAddr);
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
  1032
      int flags = (int)flagsFld.getValue(flagAddr);
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
  1033
      commandLineFlags[f] = new Flag(type, name, addr, flags);
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1034
      flagAddr = flagAddr.addOffsetTo(flagSize);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1035
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1037
    // sort flags by name
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1038
    Arrays.sort(commandLineFlags, new Comparator() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1039
        public int compare(Object o1, Object o2) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1040
          Flag f1 = (Flag) o1;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1041
          Flag f2 = (Flag) o2;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1042
          return f1.getName().compareTo(f2.getName());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1043
        }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
  1044
      });
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  public String getSystemProperty(String key) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
    Properties props = getSystemProperties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
    return (props != null)? props.getProperty(key) : null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
  public Properties getSystemProperties() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
    if (sysProps == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
       readSystemProperties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
    return sysProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
  private void readSystemProperties() {
8878
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1060
    final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1061
    systemKls.iterateStaticFields(new DefaultOopVisitor() {
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1062
        ObjectReader objReader = new ObjectReader();
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1063
        public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1064
          if (field.getID().getName().equals("props")) {
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1065
            try {
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1066
              sysProps = (Properties) objReader.readObject(field.getValue(getObj()));
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1067
            } catch (Exception e) {
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1068
              e.printStackTrace();
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1069
            }
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1070
          }
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1071
        }
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
  1072
      });
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
}