src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java
author rehn
Thu, 07 Jun 2018 14:11:56 +0200
changeset 50445 bd6b78feb6a3
parent 49902 3661f31c6df4
child 50929 ef57cfcd22ff
permissions -rw-r--r--
8195097: Make it possible to process StringTable outside safepoint Reviewed-by: coleenp, gziemski, iklam, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49896
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
     2
 * Copyright (c) 2000, 2018, 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 SymbolTable  symbols;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  private SystemDictionary dict;
42889
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
    83
  private ClassLoaderDataGraph cldGraph;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  private Threads      threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  private ObjectSynchronizer synchronizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  private JNIHandles   handles;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  private Interpreter  interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  private StubRoutines stubRoutines;
49896
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
    89
  private FileMapInfo  fileMapInfo;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  private Bytes        bytes;
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 8878
diff changeset
    91
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
    92
  /** 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
    93
  private boolean      isJvmtiSupported;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  /** Flags indicating whether we are attached to a core, C1, or C2 build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  private boolean      usingClientCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  private boolean      usingServerCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  /** alignment constants */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  private boolean      isLP64;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  private int          bytesPerLong;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   100
  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
   101
  private int          objectAlignmentInBytes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  private int          minObjAlignmentInBytes;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   103
  private int          logMinObjAlignmentInBytes;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   104
  private int          heapWordSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   105
  private int          heapOopSize;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   106
  private int          klassPtrSize;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   107
  private int          oopSize;
47816
ac0af7750da9 8189798: SA cleanup - part 1
jgeorge
parents: 47216
diff changeset
   108
  private final int    IndexSetSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  /** This is only present in a non-core build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  private CodeCache    codeCache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  /** This is only present in a C1 build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  private Runtime1     runtime1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  /** These constants come from globalDefinitions.hpp */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  private int          invocationEntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  private ReversePtrs  revPtrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  private VMRegImpl    vmregImpl;
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   117
  private int          reserveForAllocationPrefetch;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // System.getProperties from debuggee VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  private Properties   sysProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // VM version strings come from Abstract_VM_Version class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  private String       vmRelease;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  private String       vmInternalInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  private Flag[] commandLineFlags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  private Map flagsMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   129
  private static Type intType;
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   130
  private static Type uintType;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  private static Type intxType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  private static Type uintxType;
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   133
  private static Type sizetType;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  private static CIntegerType boolType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  private Boolean sharingEnabled;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   136
  private Boolean compressedOopsEnabled;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   137
  private Boolean compressedKlassPointersEnabled;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49896
diff changeset
   139
  // command line flags supplied to VM - see struct JVMFlag in jvmFlag.hpp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  public static final class Flag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
     private String type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
     private String name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
     private Address addr;
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   144
     private int flags;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   146
     private Flag(String type, String name, Address addr, int flags) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
        this.type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
        this.name = name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
        this.addr = addr;
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   150
        this.flags = flags;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
     public String getType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        return type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
     public String getName() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        return name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
     public Address getAddress() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
        return addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   165
     public int getOrigin() {
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   166
        return flags & 0xF;  // XXX can we get the mask bits from somewhere?
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   167
     }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   168
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
     public boolean isBool() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
        return type.equals("bool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
     public boolean getBool() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
           Assert.that(isBool(), "not a bool flag!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
        }
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   177
        return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned()) != 0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   180
     public boolean isInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   181
        return type.equals("int");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   182
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   183
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   184
     public long getInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   185
        if (Assert.ASSERTS_ENABLED) {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   186
           Assert.that(isInt(), "not an int flag!");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   187
        }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   188
        return addr.getCIntegerAt(0, intType.getSize(), false);
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   189
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   190
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   191
     public boolean isUInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   192
        return type.equals("uint");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   193
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   194
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   195
     public long getUInt() {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   196
        if (Assert.ASSERTS_ENABLED) {
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   197
           Assert.that(isUInt(), "not a uint flag!");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   198
        }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   199
        return addr.getCIntegerAt(0, uintType.getSize(), false);
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   200
     }
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   201
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
     public boolean isIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
        return type.equals("intx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
     public long getIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
        if (Assert.ASSERTS_ENABLED) {
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   208
           Assert.that(isIntx(), "not an intx flag!");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
        return addr.getCIntegerAt(0, intxType.getSize(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
     public boolean isUIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
        return type.equals("uintx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
     public long getUIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
           Assert.that(isUIntx(), "not a uintx flag!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
        return addr.getCIntegerAt(0, uintxType.getSize(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   224
     public boolean isSizet() {
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   225
        return type.equals("size_t");
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   226
     }
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   227
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   228
     public long getSizet() {
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   229
        if (Assert.ASSERTS_ENABLED) {
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   230
           Assert.that(isSizet(), "not a size_t flag!");
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   231
        }
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   232
        return addr.getCIntegerAt(0, sizetType.getSize(), true);
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   233
     }
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   234
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
     public String getValue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        if (isBool()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   237
           return Boolean.toString(getBool());
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   238
        } else if (isInt()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   239
           return Long.toString(getInt());
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   240
        } else if (isUInt()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   241
           return Long.toString(getUInt());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
        } else if (isIntx()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   243
           return Long.toString(getIntx());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
        } else if (isUIntx()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   245
           return Long.toString(getUIntx());
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   246
        } else if (isSizet()) {
35064
f1770c7f39bf 8145061: Too many instances of java.lang.Boolean created in Java application (hotspot repo)
sebastian
parents: 31236
diff changeset
   247
            return Long.toString(getSizet());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
           return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  private static void checkVMVersion(String vmRelease) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
     if (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        // read sa build version.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        String versionProp = "sun.jvm.hotspot.runtime.VM.saBuildVersion";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
        String saVersion = saProps.getProperty(versionProp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
        if (saVersion == null)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
           throw new RuntimeException("Missing property " + versionProp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
        // Strip nonproduct VM version substring (note: saVersion doesn't have it).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        String vmVersion = vmRelease.replaceAll("(-fastdebug)|(-debug)|(-jvmg)|(-optimized)|(-profiled)","");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        if (saVersion.equals(vmVersion)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
           // Exact match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
           return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
        if (saVersion.indexOf('-') == saVersion.lastIndexOf('-') &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
            vmVersion.indexOf('-') == vmVersion.lastIndexOf('-')) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
           // Throw exception if different release versions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
           // <major>.<minor>-b<n>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
           throw new VMVersionMismatchException(saVersion, vmRelease);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
           // Otherwise print warning to allow mismatch not release versions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
           // during development.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
           System.err.println("WARNING: Hotspot VM version " + vmRelease +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
                              " does not match with SA version " + saVersion +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
                              "." + " You may see unexpected results. ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
     } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        System.err.println("WARNING: You have disabled SA and VM version check. You may be "  +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
                           "using incompatible version of SA and you may see unexpected " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
                           "results.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   288
  private static final boolean disableDerivedPointerTableCheck;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  private static final Properties saProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
     saProps = new Properties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
     URL url = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
     try {
30284
909da3c92522 8078519: Can't run SA tools from a non-images build
sla
parents: 29704
diff changeset
   295
       saProps.load(VM.class.getResourceAsStream("/sa.properties"));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
     } catch (Exception e) {
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   297
       System.err.println("Unable to load properties  " +
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
                                  (url == null ? "null" : url.toString()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
                                  ": " + e.getMessage());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   302
     disableDerivedPointerTableCheck = System.getProperty("sun.jvm.hotspot.runtime.VM.disableDerivedPointerTableCheck") != null;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    this.db          = db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    this.debugger    = debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    this.isBigEndian = isBigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    // Note that we don't construct universe, heap, threads,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    // interpreter, or stubRoutines here (any more).  The current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    // initialization mechanisms require that the VM be completely set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    // up (i.e., out of its constructor, with soleInstance assigned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    // before their static initializers are run.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    if (db.getAddressSize() == 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      logAddressSize = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    } else if (db.getAddressSize() == 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      logAddressSize = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      throw new RuntimeException("Address size " + db.getAddressSize() + " not yet supported");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    // read VM version info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
       Type vmVersion = db.lookupType("Abstract_VM_Version");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
       Address releaseAddr = vmVersion.getAddressField("_s_vm_release").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
       vmRelease = CStringUtilities.getString(releaseAddr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
       Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
       vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr);
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   331
38220
8d86b82e0ac7 8153340: Disallow misconfiguration and improve the consistency of allocation prefetching
zmajo
parents: 35217
diff changeset
   332
       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
   333
       CIntegerType intType = (CIntegerType) db.lookupType("int");
38220
8d86b82e0ac7 8153340: Disallow misconfiguration and improve the consistency of allocation prefetching
zmajo
parents: 35217
diff changeset
   334
       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
   335
       reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    } catch (Exception exp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
       throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    checkVMVersion(vmRelease);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    stackBias    = db.lookupIntConstant("STACK_BIAS").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   345
    // 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
   346
    {
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   347
      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
   348
      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
   349
        isJvmtiSupported = false;
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   350
      } else {
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   351
        isJvmtiSupported = true;
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   352
      }
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   353
    }
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   354
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    // We infer the presence of C1 or C2 from a couple of fields we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    // already have present in the type database
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   358
      Type type = db.lookupType("Method");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
      if (type.getField("_from_compiled_entry", false, false) == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        // Neither C1 nor C2 is present
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        usingClientCompiler = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        usingServerCompiler = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        // Determine whether C2 is present
10552
4c615382f246 7090654: nightly failures after 7086585
never
parents: 10547
diff changeset
   365
        if (db.lookupType("Matcher", false) != null) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
          usingServerCompiler = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
          usingClientCompiler = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
      isLP64 = debugger.getMachineDescription().isLP64();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   377
    bytesPerWord = db.lookupIntConstant("BytesPerWord").intValue();
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   378
    heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   379
    oopSize  = db.lookupIntConstant("oopSize").intValue();
47816
ac0af7750da9 8189798: SA cleanup - part 1
jgeorge
parents: 47216
diff changeset
   380
    IndexSetSize = db.lookupIntConstant("CompactibleFreeListSpace::IndexSetSize").intValue();
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   381
31236
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   382
    intType = db.lookupType("int");
d4d3011aa98e 8080947: Add uint as a valid VM flag type
david
parents: 30284
diff changeset
   383
    uintType = db.lookupType("uint");
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   384
    intxType = db.lookupType("intx");
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   385
    uintxType = db.lookupType("uintx");
29704
2a1a74472bfd 8076012: SA don't support flags of type size_t
jwilhelm
parents: 26705
diff changeset
   386
    sizetType = db.lookupType("size_t");
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   387
    boolType = (CIntegerType) db.lookupType("bool");
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   388
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   389
    minObjAlignmentInBytes = getObjectAlignmentInBytes();
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   390
    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
   391
      logMinObjAlignmentInBytes = 3;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   392
    } 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
   393
      logMinObjAlignmentInBytes = 4;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   394
    } else {
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   395
      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
   396
    }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   397
2739
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   398
    if (isCompressedOopsEnabled()) {
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   399
      // Size info for oops within java objects is fixed
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   400
      heapOopSize = (int)getIntSize();
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   401
    } else {
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   402
      heapOopSize = (int)getOopSize();
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   403
    }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   404
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   405
    if (isCompressedKlassPointersEnabled()) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   406
      klassPtrSize = (int)getIntSize();
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   407
    } else {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   408
      klassPtrSize = (int)getOopSize(); // same as an oop
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   409
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  /** This could be used by a reflective runtime system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  public static void initialize(TypeDataBase db, boolean isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    if (soleInstance != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      throw new RuntimeException("Attempt to initialize VM twice");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    soleInstance = new VM(db, null, isBigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  /** This is used by the debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  public static void initialize(TypeDataBase db, JVMDebugger debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    if (soleInstance != null) {
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   426
      // 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
   427
      return;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
2356
81a6245db120 6822407: heapOopSize lookup is incorrect in Serviceability Agent.
poonam
parents: 2267
diff changeset
   430
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    }
2262
51ebd610829b 6812971: SA: re-attaching to process fails
poonam
parents: 1135
diff changeset
   434
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   435
    debugger.putHeapConst(soleInstance.getHeapOopSize(), soleInstance.getKlassPtrSize(),
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   436
                          Universe.getNarrowOopBase(), Universe.getNarrowOopShift(),
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   437
                          Universe.getNarrowKlassBase(), Universe.getNarrowKlassShift());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  /** This is used by the debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  public static void shutdown() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    soleInstance = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  /** This is used by both the debugger and any runtime system. It is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
      the basic mechanism by which classes which mimic underlying VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      functionality cause themselves to be initialized. The given
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      observer will be notified (with arguments (null, null)) when the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      VM is re-initialized, as well as when it registers itself with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      the VM. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  public static void registerVMInitializedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    vmInitializedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    o.update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  /** This is the primary accessor used by both the debugger and any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
      potential runtime system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  public static VM getVM() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    if (soleInstance == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
      throw new RuntimeException("VM.initialize() was not yet called");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    return soleInstance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  /** This is only used by the debugging system. The given observer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
      will be notified if the underlying VM resumes execution. NOTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
      that the given observer is not triggered if the VM is currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
      running and therefore differs in behavior from {@link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
      #registerVMInitializedObserver} (because of the possibility of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
      race conditions if the observer is added while the VM is being
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
      suspended or resumed).  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  public void registerVMResumedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
    vmResumedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  /** This is only used by the debugging system. The given observer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
      will be notified if the underlying VM suspends execution. NOTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
      that the given observer is not triggered if the VM is currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
      suspended and therefore differs in behavior from {@link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
      #registerVMInitializedObserver} (because of the possibility of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
      race conditions if the observer is added while the VM is being
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
      suspended or resumed).  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  public void registerVMSuspendedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    vmSuspendedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  /** This is only used by the debugging system. Informs all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
      registered resumption observers that the VM has been resumed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
      The application is responsible for actually having performed the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
      resumption. No OopHandles must be used after this point, as they
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
      may move in the target address space due to garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
      collection. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  public void fireVMResumed() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    for (Iterator iter = vmResumedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  /** This is only used by the debugging system. Informs all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
      registered suspension observers that the VM has been suspended.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
      The application is responsible for actually having performed the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
      suspension. Garbage collection must be forbidden at this point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
      for example, a JPDA-level suspension is not adequate since the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
      VM thread may still be running. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  public void fireVMSuspended() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    for (Iterator iter = vmSuspendedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  /** Returns the OS this VM is running on. Notice that by delegating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
      to the debugger we can transparently support remote
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
      debugging. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  public String getOS() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
      return debugger.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    return PlatformInfo.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  /** Returns the CPU this VM is running on. Notice that by delegating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      to the debugger we can transparently support remote
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      debugging. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  public String getCPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      return debugger.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
    return PlatformInfo.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  public Type lookupType(String cTypeName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    return db.lookupType(cTypeName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  public Integer lookupIntConstant(String name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
    return db.lookupIntConstant(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
13873
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   539
  // Convenience function for conversions
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   540
  static public long getAddressValue(Address addr) {
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   541
    return VM.getVM().getDebugger().getAddressValue(addr);
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   542
  }
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 13728
diff changeset
   543
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  public long getAddressSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    return db.getAddressSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  public long getOopSize() {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   549
    return oopSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  public long getLogAddressSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
    return logAddressSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   556
  public long getIntSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   557
    return db.getJIntType().getSize();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   558
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   559
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  /** NOTE: this offset is in BYTES in this system! */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  public long getStackBias() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    return stackBias;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  /** Indicates whether the underlying machine supports the LP64 data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
      model. This is needed for conditionalizing code in a few places */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  public boolean isLP64() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
      Assert.that(isDebugging(), "Debugging system only for now");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    return isLP64;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  /** Get bytes-per-long == long/double natural alignment. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  public int getBytesPerLong() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    return bytesPerLong;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   579
  public int getBytesPerWord() {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   580
    return bytesPerWord;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   581
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   582
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  /** Get minimum object alignment in bytes. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  public int getMinObjAlignmentInBytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    return minObjAlignmentInBytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   587
  public int getLogMinObjAlignmentInBytes() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   588
    return logMinObjAlignmentInBytes;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   589
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   591
  public int getHeapWordSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   592
    return heapWordSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   593
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   594
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   595
  public int getHeapOopSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   596
    return heapOopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   597
  }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   598
47816
ac0af7750da9 8189798: SA cleanup - part 1
jgeorge
parents: 47216
diff changeset
   599
  public int getIndexSetSize() {
ac0af7750da9 8189798: SA cleanup - part 1
jgeorge
parents: 47216
diff changeset
   600
    return IndexSetSize;
ac0af7750da9 8189798: SA cleanup - part 1
jgeorge
parents: 47216
diff changeset
   601
  }
ac0af7750da9 8189798: SA cleanup - part 1
jgeorge
parents: 47216
diff changeset
   602
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   603
  public int getKlassPtrSize() {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   604
    return klassPtrSize;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   605
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  /** Utility routine for getting data structure alignment correct */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  public long alignUp(long size, long alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    return (size + alignment - 1) & ~(alignment - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  /** Utility routine for getting data structure alignment correct */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  public long alignDown(long size, long alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    return size & ~(alignment - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  /** Utility routine for building an int from two "unsigned" 16-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
      shorts */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  public int buildIntFromShorts(short low, short high) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    return (((int) high) << 16) | (((int) low) & 0xFFFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  /** Utility routine for building a long from two "unsigned" 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
      ints in <b>platform-dependent</b> order */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  public long buildLongFromIntsPD(int oneHalf, int otherHalf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
    if (isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
      return (((long) otherHalf) << 32) | (((long) oneHalf) & 0x00000000FFFFFFFFL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    } else{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
      return (((long) oneHalf) << 32) | (((long) otherHalf) & 0x00000000FFFFFFFFL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  public TypeDataBase getTypeDataBase() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
    return db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  public Universe    getUniverse() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
    if (universe == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
      universe = new Universe();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    return universe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  public ObjectHeap  getObjectHeap() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    if (heap == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
      heap = new ObjectHeap(db);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    return heap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  public SymbolTable getSymbolTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    if (symbols == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
      symbols = SymbolTable.getTheTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
    return symbols;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  public SystemDictionary getSystemDictionary() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
    if (dict == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
      dict = new SystemDictionary();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    return dict;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
42889
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   664
  public ClassLoaderDataGraph getClassLoaderDataGraph() {
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   665
    if (cldGraph == null) {
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   666
      cldGraph = new ClassLoaderDataGraph();
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   667
    }
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   668
    return cldGraph;
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   669
  }
0b0ae99d8639 8159127: hprof heap dumps broken for lambda classdata
dsamersoff
parents: 42650
diff changeset
   670
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  public Threads     getThreads() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
    if (threads == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
      threads = new Threads();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
    return threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  public ObjectSynchronizer getObjectSynchronizer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    if (synchronizer == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
      synchronizer = new ObjectSynchronizer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
    return synchronizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
  public JNIHandles getJNIHandles() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    if (handles == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
      handles = new JNIHandles();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
    return handles;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  public Interpreter getInterpreter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
    if (interpreter == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
      interpreter = new Interpreter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
    return interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  public StubRoutines getStubRoutines() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
    if (stubRoutines == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
      stubRoutines = new StubRoutines();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
    return stubRoutines;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
  public VMRegImpl getVMRegImplInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
    if (vmregImpl == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
      vmregImpl = new VMRegImpl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    return vmregImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
49896
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   713
  public FileMapInfo getFileMapInfo() {
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   714
    if (!isSharingEnabled()) {
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   715
      return null;
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   716
    }
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   717
    if (fileMapInfo == null) {
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   718
      fileMapInfo = new FileMapInfo();
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   719
    }
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   720
    return fileMapInfo;
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   721
  }
ec2dd30adbc1 8174994: SA: clhsdb printmdo throws WrongTypeException when attached to a process with CDS
jgeorge
parents: 49860
diff changeset
   722
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  public Bytes getBytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
    if (bytes == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
      bytes = new Bytes(debugger.getMachineDescription());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
    return bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   730
  /** Returns true if this is a isBigEndian, false otherwise */
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   731
  public boolean isBigEndian() {
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   732
    return isBigEndian;
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   733
  }
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   734
38059
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   735
  /** 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
   736
  public boolean isJvmtiSupported() {
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   737
    return isJvmtiSupported;
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   738
  }
86ab3f0a9f87 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported
cjplummer
parents: 35217
diff changeset
   739
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  /** Returns true if this is a "core" build, false if either C1 or C2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
      is present */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  public boolean isCore() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
    return (!(usingClientCompiler || usingServerCompiler));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  /** Returns true if this is a C1 build, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  public boolean isClientCompiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    return usingClientCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  /** Returns true if this is a C2 build, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
  public boolean isServerCompiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
    return usingServerCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  /** Returns true if C2 derived pointer table should be used, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
  public boolean useDerivedPointerTable() {
18481
fa7f6ad24216 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 15741
diff changeset
   758
    return !disableDerivedPointerTableCheck;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
  /** Returns the code cache; should not be used if is core build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  public CodeCache getCodeCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
      Assert.that(!isCore(), "noncore builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
    if (codeCache == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
      codeCache = new CodeCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
    return codeCache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
  /** Should only be called for C1 builds */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  public Runtime1 getRuntime1() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
      Assert.that(isClientCompiler(), "C1 builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
    if (runtime1 == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
      runtime1 = new Runtime1();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
    return runtime1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
  /** Test to see whether we're in debugging mode (NOTE: this really
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
      should not be tested by this code; currently only used in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
      StackFrameStream) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  public boolean isDebugging() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
    return (debugger != null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  /** This is only used by the debugging (i.e., non-runtime) system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
  public JVMDebugger getDebugger() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
    if (debugger == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
      throw new RuntimeException("Attempt to use debugger in runtime system");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
    return debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
  /** Indicates whether a given program counter is in Java code. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
      includes but is not spanned by the interpreter and code cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
      Only used in the debugging system, for implementing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
      JavaThread.currentFrameGuess() on x86. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
  public boolean isJavaPCDbg(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
    // FIXME: this is not a complete enough set: must include areas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
    // like vtable stubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
    return (getInterpreter().contains(addr) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
            getCodeCache().contains(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  /** FIXME: figure out where to stick this */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  public int getInvocationEntryBCI() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
    return invocationEntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
  // FIXME: figure out where to stick this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  public boolean wizardMode() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  public ReversePtrs getRevPtrs() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
    return revPtrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  public void setRevPtrs(ReversePtrs rp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
    revPtrs = rp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  public String getVMRelease() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
    return vmRelease;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
  public String getVMInternalInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
    return vmInternalInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
15486
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   837
  public int getReserveForAllocationPrefetch() {
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   838
    return reserveForAllocationPrefetch;
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   839
  }
61b414c85d2f 8004710: NPG: jmap could throw sun.jvm.hotspot.types.WrongTypeException after PermGen removal
stefank
parents: 13969
diff changeset
   840
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  public boolean isSharingEnabled() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    if (sharingEnabled == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
      Flag flag = getCommandLineFlag("UseSharedSpaces");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
      sharingEnabled = (flag == null)? Boolean.FALSE :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
          (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
    return sharingEnabled.booleanValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   850
  public boolean isCompressedOopsEnabled() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   851
    if (compressedOopsEnabled == null) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   852
        Flag flag = getCommandLineFlag("UseCompressedOops");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   853
        compressedOopsEnabled = (flag == null) ? Boolean.FALSE:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   854
             (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
   855
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   856
    return compressedOopsEnabled.booleanValue();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   857
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   859
  public boolean isCompressedKlassPointersEnabled() {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   860
    if (compressedKlassPointersEnabled == null) {
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 18481
diff changeset
   861
        Flag flag = getCommandLineFlag("UseCompressedClassPointers");
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   862
        compressedKlassPointersEnabled = (flag == null) ? Boolean.FALSE:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   863
             (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   864
    }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 13873
diff changeset
   865
    return compressedKlassPointersEnabled.booleanValue();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   866
  }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13529
diff changeset
   867
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   868
  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
   869
    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
   870
        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
   871
        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
   872
    }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   873
    return objectAlignmentInBytes;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   874
  }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   875
15741
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   876
  /** Indicates whether Thread-Local Allocation Buffers are used */
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   877
  public boolean getUseTLAB() {
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   878
      Flag flag = getCommandLineFlag("UseTLAB");
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   879
      return (flag == null) ? false: flag.getBool();
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   880
  }
55126c3ce8e9 8007901: SA: Don't read flag values as constants
sla
parents: 15486
diff changeset
   881
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   882
  public boolean getCommandLineBooleanFlag(String name) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   883
    Flag flag = getCommandLineFlag(name);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   884
    return (flag == null) ? Boolean.FALSE:
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   885
      (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   886
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 38241
diff changeset
   887
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
  public Flag[] getCommandLineFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
    if (commandLineFlags == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
       readCommandLineFlags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
    return commandLineFlags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  public Flag getCommandLineFlag(String name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
    if (flagsMap == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
      flagsMap = new HashMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
      Flag[] flags = getCommandLineFlags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
      for (int i = 0; i < flags.length; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
        flagsMap.put(flags[i].getName(), flags[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    return (Flag) flagsMap.get(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
  private void readCommandLineFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
    // get command line flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
    TypeDataBase db = getTypeDataBase();
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49896
diff changeset
   911
    Type flagType = db.lookupType("JVMFlag");
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   912
    int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   913
    // NOTE: last flag contains null values.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   914
    commandLineFlags = new Flag[numFlags - 1];
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   915
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   916
    Address flagAddr = flagType.getAddressField("flags").getValue();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   918
    AddressField typeFld = flagType.getAddressField("_type");
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   919
    AddressField nameFld = flagType.getAddressField("_name");
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   920
    AddressField addrFld = flagType.getAddressField("_addr");
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   921
    CIntField flagsFld = new CIntField(flagType.getCIntegerField("_flags"), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   923
    long flagSize = flagType.getSize(); // sizeof(Flag)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   925
    // NOTE: last flag contains null values.
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   926
    for (int f = 0; f < numFlags - 1; f++) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   927
      String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   928
      String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   929
      Address addr = addrFld.getValue(flagAddr);
20288
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   930
      int flags = (int)flagsFld.getValue(flagAddr);
e2d549f40de9 8024545: make develop and notproduct flag values available in product builds
twisti
parents: 19979
diff changeset
   931
      commandLineFlags[f] = new Flag(type, name, addr, flags);
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   932
      flagAddr = flagAddr.addOffsetTo(flagSize);
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   933
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
10547
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   935
    // sort flags by name
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   936
    Arrays.sort(commandLineFlags, new Comparator() {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   937
        public int compare(Object o1, Object o2) {
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   938
          Flag f1 = (Flag) o1;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   939
          Flag f2 = (Flag) o2;
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   940
          return f1.getName().compareTo(f2.getName());
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   941
        }
ea4a2ec31ae2 7088955: add C2 IR support to the SA
never
parents: 10517
diff changeset
   942
      });
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
  public String getSystemProperty(String key) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
    Properties props = getSystemProperties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
    return (props != null)? props.getProperty(key) : null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  public Properties getSystemProperties() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    if (sysProps == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
       readSystemProperties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
    return sysProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
  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
   958
    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
   959
    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
   960
        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
   961
        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
   962
          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
   963
            try {
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
   964
              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
   965
            } catch (Exception e) {
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
   966
              e.printStackTrace();
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
   967
            }
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
   968
          }
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
   969
        }
a6283814032c 7031614: jmap -permstat fails with java.lang.InternalError in sun.jvm.hotspot.oops.OopField.getValue
never
parents: 8725
diff changeset
   970
      });
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
}