hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
author never
Fri, 18 Mar 2011 16:00:34 -0700
changeset 8725 8c1e3dd5fe1b
parent 7662 5f31baaff55b
child 8878 a6283814032c
permissions -rw-r--r--
7017732: move static fields into Class to prepare for perm gen removal Reviewed-by: kvn, coleenp, twisti, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7662
diff changeset
     2
 * Copyright (c) 2000, 2011, 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.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.interpreter.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
import sun.jvm.hotspot.memory.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
import sun.jvm.hotspot.oops.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
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
    39
import sun.jvm.hotspot.runtime.*;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
/** <P> This class encapsulates the global state of the VM; the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    universe, object heap, interpreter, etc. It is a Singleton and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    must be initialized with a call to initialize() before calling
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    getVM(). </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    <P> Many auxiliary classes (i.e., most of the VMObjects) keep
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    needed field offsets in the form of static Field objects. In a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    debugging system, the VM might be shutdown and re-initialized (on
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    a differently-configured build, i.e., 32- vs. 64-bit), and all old
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    cached state (including fields and field offsets) must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    flushed. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    <P> An Observer pattern is used to implement the initialization of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    such classes. Each such class, in its static initializer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    registers an Observer with the VM class via
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    VM.registerVMInitializedObserver(). This Observer is guaranteed to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    be notified whenever the VM is initialized (or re-initialized). To
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    implement the first-time initialization, the observer is also
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    notified when it registers itself with the VM. (For bootstrapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    reasons, this implies that the constructor of VM can not
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    instantiate any such objects, since VM.soleInstance will not have
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    been set yet. This is a bootstrapping issue which may have to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    revisited later.) </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
*/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
public class VM {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  private static VM    soleInstance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  private static List  vmInitializedObservers = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  private List         vmResumedObservers   = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  private List         vmSuspendedObservers = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  private TypeDataBase db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  private boolean      isBigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  /** This is only present if in a debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  private JVMDebugger  debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  private long         stackBias;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  private long         logAddressSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  private Universe     universe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  private ObjectHeap   heap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  private SymbolTable  symbols;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  private StringTable  strings;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  private SystemDictionary dict;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  private Threads      threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  private ObjectSynchronizer synchronizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  private JNIHandles   handles;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  private Interpreter  interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  private StubRoutines stubRoutines;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  private Bytes        bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  /** Flags indicating whether we are attached to a core, C1, or C2 build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  private boolean      usingClientCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  private boolean      usingServerCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  /** Flag indicating whether UseTLAB is turned on */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  private boolean      useTLAB;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  /** alignment constants */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  private boolean      isLP64;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  private int          bytesPerLong;
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
    96
  private int          objectAlignmentInBytes;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  private int          minObjAlignmentInBytes;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    98
  private int          logMinObjAlignmentInBytes;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    99
  private int          heapWordSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   100
  private int          heapOopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   101
  private int          oopSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  /** This is only present in a non-core build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  private CodeCache    codeCache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  /** This is only present in a C1 build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  private Runtime1     runtime1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  /** These constants come from globalDefinitions.hpp */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  private int          invocationEntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  private int          invalidOSREntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  private ReversePtrs  revPtrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  private VMRegImpl    vmregImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // System.getProperties from debuggee VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  private Properties   sysProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // VM version strings come from Abstract_VM_Version class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  private String       vmRelease;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  private String       vmInternalInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  private Flag[] commandLineFlags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  private Map flagsMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  private static Type intxType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  private static Type uintxType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  private static CIntegerType boolType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  private Boolean sharingEnabled;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   126
  private Boolean compressedOopsEnabled;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // command line flags supplied to VM - see struct Flag in globals.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  public static final class Flag {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
     private String type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
     private String name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
     private Address addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
     private String kind;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
     private Flag(String type, String name, Address addr, String kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
        this.type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
        this.name = name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
        this.addr = addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        this.kind = kind;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
     public String getType() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
        return type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
     public String getName() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
        return name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
     public Address getAddress() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
        return addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
     public String getKind() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
        return kind;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
     public boolean isBool() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
        return type.equals("bool");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
     public boolean getBool() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
           Assert.that(isBool(), "not a bool flag!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
        return addr.getCIntegerAt(0, boolType.getSize(), boolType.isUnsigned())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
               != 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
     public boolean isIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
        return type.equals("intx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
     public long getIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
           Assert.that(isIntx(), "not a intx flag!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
        return addr.getCIntegerAt(0, intxType.getSize(), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
     public boolean isUIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
        return type.equals("uintx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
     public long getUIntx() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
           Assert.that(isUIntx(), "not a uintx flag!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
        return addr.getCIntegerAt(0, uintxType.getSize(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
     public String getValue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
        if (isBool()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
           return new Boolean(getBool()).toString();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
        } else if (isIntx()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
           return new Long(getIntx()).toString();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
        } else if (isUIntx()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
           return new Long(getUIntx()).toString();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
           return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  private static void checkVMVersion(String vmRelease) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
     if (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
        // read sa build version.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
        String versionProp = "sun.jvm.hotspot.runtime.VM.saBuildVersion";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
        String saVersion = saProps.getProperty(versionProp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
        if (saVersion == null)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
           throw new RuntimeException("Missing property " + versionProp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
        // Strip nonproduct VM version substring (note: saVersion doesn't have it).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
        String vmVersion = vmRelease.replaceAll("(-fastdebug)|(-debug)|(-jvmg)|(-optimized)|(-profiled)","");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
        if (saVersion.equals(vmVersion)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
           // Exact match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
           return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
        if (saVersion.indexOf('-') == saVersion.lastIndexOf('-') &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
            vmVersion.indexOf('-') == vmVersion.lastIndexOf('-')) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
           // Throw exception if different release versions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
           // <major>.<minor>-b<n>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
           throw new VMVersionMismatchException(saVersion, vmRelease);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
           // Otherwise print warning to allow mismatch not release versions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
           // during development.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
           System.err.println("WARNING: Hotspot VM version " + vmRelease +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
                              " does not match with SA version " + saVersion +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
                              "." + " You may see unexpected results. ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
     } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
        System.err.println("WARNING: You have disabled SA and VM version check. You may be "  +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
                           "using incompatible version of SA and you may see unexpected " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
                           "results.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  private static final boolean disableDerivedPrinterTableCheck;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  private static final Properties saProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
     saProps = new Properties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
     URL url = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
     try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
       url = VM.class.getClassLoader().getResource("sa.properties");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
       saProps.load(new BufferedInputStream(url.openStream()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
     } catch (Exception e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
       throw new RuntimeException("Unable to load properties  " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
                                  (url == null ? "null" : url.toString()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
                                  ": " + e.getMessage());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
     disableDerivedPrinterTableCheck = System.getProperty("sun.jvm.hotspot.runtime.VM.disableDerivedPointerTableCheck") != null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    this.db          = db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    this.debugger    = debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    this.isBigEndian = isBigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    // Note that we don't construct universe, heap, threads,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    // interpreter, or stubRoutines here (any more).  The current
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    // initialization mechanisms require that the VM be completely set
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    // up (i.e., out of its constructor, with soleInstance assigned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    // before their static initializers are run.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    if (db.getAddressSize() == 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
      logAddressSize = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    } else if (db.getAddressSize() == 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
      logAddressSize = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
      throw new RuntimeException("Address size " + db.getAddressSize() + " not yet supported");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    // read VM version info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
       Type vmVersion = db.lookupType("Abstract_VM_Version");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
       Address releaseAddr = vmVersion.getAddressField("_s_vm_release").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
       vmRelease = CStringUtilities.getString(releaseAddr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
       Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
       vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    } catch (Exception exp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
       throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    checkVMVersion(vmRelease);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    stackBias    = db.lookupIntConstant("STACK_BIAS").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    invalidOSREntryBCI = db.lookupIntConstant("InvalidOSREntryBci").intValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    // We infer the presence of C1 or C2 from a couple of fields we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    // already have present in the type database
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
      Type type = db.lookupType("methodOopDesc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
      if (type.getField("_from_compiled_entry", false, false) == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
        // Neither C1 nor C2 is present
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
        usingClientCompiler = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
        usingServerCompiler = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
        // Determine whether C2 is present
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
        if (type.getField("_interpreter_invocation_count", false, false) != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
          usingServerCompiler = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
          usingClientCompiler = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    useTLAB = (db.lookupIntConstant("UseTLAB").intValue() != 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
      isLP64 = debugger.getMachineDescription().isLP64();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
5699
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   317
    heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   318
    oopSize  = db.lookupIntConstant("oopSize").intValue();
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   319
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   320
    intxType = db.lookupType("intx");
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   321
    uintxType = db.lookupType("uintx");
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   322
    boolType = (CIntegerType) db.lookupType("bool");
c864b4cae5fc 6957882: nsk/sajdi tests failed with NullPointerException
kvn
parents: 5694
diff changeset
   323
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   324
    minObjAlignmentInBytes = getObjectAlignmentInBytes();
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   325
    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
   326
      logMinObjAlignmentInBytes = 3;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   327
    } 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
   328
      logMinObjAlignmentInBytes = 4;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   329
    } else {
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   330
      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
   331
    }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   332
2739
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   333
    if (isCompressedOopsEnabled()) {
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   334
      // Size info for oops within java objects is fixed
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   335
      heapOopSize = (int)getIntSize();
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   336
    } else {
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   337
      heapOopSize = (int)getOopSize();
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   338
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  /** This could be used by a reflective runtime system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  public static void initialize(TypeDataBase db, boolean isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    if (soleInstance != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
      throw new RuntimeException("Attempt to initialize VM twice");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    soleInstance = new VM(db, null, isBigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  /** This is used by the debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  public static void initialize(TypeDataBase db, JVMDebugger debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    if (soleInstance != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
      throw new RuntimeException("Attempt to initialize VM twice");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
2356
81a6245db120 6822407: heapOopSize lookup is incorrect in Serviceability Agent.
poonam
parents: 2267
diff changeset
   358
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
    }
2262
51ebd610829b 6812971: SA: re-attaching to process fails
poonam
parents: 1135
diff changeset
   362
2739
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   363
    debugger.putHeapConst(soleInstance.getHeapOopSize(), Universe.getNarrowOopBase(),
767d5ea27cc5 6829234: Refix 6822407 and 6812971
poonam
parents: 2359
diff changeset
   364
                          Universe.getNarrowOopShift());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  /** This is used by the debugging system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  public static void shutdown() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    soleInstance = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  /** This is used by both the debugger and any runtime system. It is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
      the basic mechanism by which classes which mimic underlying VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
      functionality cause themselves to be initialized. The given
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      observer will be notified (with arguments (null, null)) when the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      VM is re-initialized, as well as when it registers itself with
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      the VM. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  public static void registerVMInitializedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    vmInitializedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    o.update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  /** This is the primary accessor used by both the debugger and any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      potential runtime system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  public static VM getVM() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    if (soleInstance == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
      throw new RuntimeException("VM.initialize() was not yet called");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    return soleInstance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  /** This is only used by the debugging system. The given observer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
      will be notified if the underlying VM resumes execution. NOTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
      that the given observer is not triggered if the VM is currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
      running and therefore differs in behavior from {@link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
      #registerVMInitializedObserver} (because of the possibility of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
      race conditions if the observer is added while the VM is being
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
      suspended or resumed).  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  public void registerVMResumedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    vmResumedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  /** This is only used by the debugging system. The given observer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
      will be notified if the underlying VM suspends execution. NOTE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
      that the given observer is not triggered if the VM is currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
      suspended and therefore differs in behavior from {@link
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
      #registerVMInitializedObserver} (because of the possibility of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
      race conditions if the observer is added while the VM is being
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
      suspended or resumed).  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  public void registerVMSuspendedObserver(Observer o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    vmSuspendedObservers.add(o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  /** This is only used by the debugging system. Informs all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
      registered resumption observers that the VM has been resumed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
      The application is responsible for actually having performed the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
      resumption. No OopHandles must be used after this point, as they
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
      may move in the target address space due to garbage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      collection. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  public void fireVMResumed() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    for (Iterator iter = vmResumedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  /** This is only used by the debugging system. Informs all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
      registered suspension observers that the VM has been suspended.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
      The application is responsible for actually having performed the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      suspension. Garbage collection must be forbidden at this point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
      for example, a JPDA-level suspension is not adequate since the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
      VM thread may still be running. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  public void fireVMSuspended() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    for (Iterator iter = vmSuspendedObservers.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
      ((Observer) iter.next()).update(null, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  /** Returns the OS this VM is running on. Notice that by delegating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      to the debugger we can transparently support remote
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      debugging. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  public String getOS() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
      return debugger.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    return PlatformInfo.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  /** Returns the CPU this VM is running on. Notice that by delegating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      to the debugger we can transparently support remote
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      debugging. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  public String getCPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    if (debugger != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
      return debugger.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    return PlatformInfo.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  public Type lookupType(String cTypeName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    return db.lookupType(cTypeName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  public Integer lookupIntConstant(String name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    return db.lookupIntConstant(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  public long getAddressSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    return db.getAddressSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  public long getOopSize() {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   471
    return oopSize;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  public long getLogAddressSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
    return logAddressSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   478
  public long getIntSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   479
    return db.getJIntType().getSize();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   480
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   481
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  /** NOTE: this offset is in BYTES in this system! */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  public long getStackBias() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    return stackBias;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  /** Indicates whether the underlying machine supports the LP64 data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
      model. This is needed for conditionalizing code in a few places */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  public boolean isLP64() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
      Assert.that(isDebugging(), "Debugging system only for now");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    return isLP64;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  /** Get bytes-per-long == long/double natural alignment. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  public int getBytesPerLong() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    return bytesPerLong;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  /** Get minimum object alignment in bytes. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  public int getMinObjAlignmentInBytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    return minObjAlignmentInBytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   505
  public int getLogMinObjAlignmentInBytes() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   506
    return logMinObjAlignmentInBytes;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   507
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   509
  public int getHeapWordSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   510
    return heapWordSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   511
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   512
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   513
  public int getHeapOopSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   514
    return heapOopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   515
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  /** Utility routine for getting data structure alignment correct */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  public long alignUp(long size, long alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    return (size + alignment - 1) & ~(alignment - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  /** Utility routine for getting data structure alignment correct */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  public long alignDown(long size, long alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    return size & ~(alignment - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  /** Utility routine for building an int from two "unsigned" 16-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
      shorts */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  public int buildIntFromShorts(short low, short high) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    return (((int) high) << 16) | (((int) low) & 0xFFFF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  /** Utility routine for building a long from two "unsigned" 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
      ints in <b>platform-dependent</b> order */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  public long buildLongFromIntsPD(int oneHalf, int otherHalf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    if (isBigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
      return (((long) otherHalf) << 32) | (((long) oneHalf) & 0x00000000FFFFFFFFL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
    } else{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
      return (((long) oneHalf) << 32) | (((long) otherHalf) & 0x00000000FFFFFFFFL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  /** Indicates whether Thread-Local Allocation Buffers are used */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  public boolean getUseTLAB() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    return useTLAB;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  public TypeDataBase getTypeDataBase() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
    return db;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  public Universe    getUniverse() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    if (universe == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
      universe = new Universe();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
    return universe;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  public ObjectHeap  getObjectHeap() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    if (heap == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
      heap = new ObjectHeap(db);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    return heap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  public SymbolTable getSymbolTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    if (symbols == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
      symbols = SymbolTable.getTheTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    return symbols;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  public StringTable getStringTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    if (strings == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
      strings = StringTable.getTheTable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    return strings;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  public SystemDictionary getSystemDictionary() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    if (dict == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
      dict = new SystemDictionary();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    return dict;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  public Threads     getThreads() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    if (threads == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
      threads = new Threads();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    return threads;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  public ObjectSynchronizer getObjectSynchronizer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    if (synchronizer == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
      synchronizer = new ObjectSynchronizer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    return synchronizer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  public JNIHandles getJNIHandles() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
    if (handles == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
      handles = new JNIHandles();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
    return handles;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  public Interpreter getInterpreter() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    if (interpreter == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
      interpreter = new Interpreter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
    return interpreter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  public StubRoutines getStubRoutines() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
    if (stubRoutines == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
      stubRoutines = new StubRoutines();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
    return stubRoutines;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  public VMRegImpl getVMRegImplInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    if (vmregImpl == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
      vmregImpl = new VMRegImpl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
    return vmregImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  public Bytes getBytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    if (bytes == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
      bytes = new Bytes(debugger.getMachineDescription());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
    return bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   635
  /** Returns true if this is a isBigEndian, false otherwise */
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   636
  public boolean isBigEndian() {
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   637
    return isBigEndian;
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   638
  }
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 670
diff changeset
   639
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  /** Returns true if this is a "core" build, false if either C1 or C2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
      is present */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  public boolean isCore() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
    return (!(usingClientCompiler || usingServerCompiler));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  /** Returns true if this is a C1 build, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  public boolean isClientCompiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    return usingClientCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  /** Returns true if this is a C2 build, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  public boolean isServerCompiler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    return usingServerCompiler;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  /** Returns true if C2 derived pointer table should be used, false otherwise */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  public boolean useDerivedPointerTable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
    return !disableDerivedPrinterTableCheck;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  /** Returns the code cache; should not be used if is core build */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
  public CodeCache getCodeCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
      Assert.that(!isCore(), "noncore builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    if (codeCache == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
      codeCache = new CodeCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
    return codeCache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  /** Should only be called for C1 builds */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  public Runtime1 getRuntime1() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
      Assert.that(isClientCompiler(), "C1 builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
    if (runtime1 == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
      runtime1 = new Runtime1();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
    return runtime1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  /** Test to see whether we're in debugging mode (NOTE: this really
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
      should not be tested by this code; currently only used in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
      StackFrameStream) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  public boolean isDebugging() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    return (debugger != null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  /** This is only used by the debugging (i.e., non-runtime) system */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  public JVMDebugger getDebugger() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
    if (debugger == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
      throw new RuntimeException("Attempt to use debugger in runtime system");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
    return debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  /** Indicates whether a given program counter is in Java code. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
      includes but is not spanned by the interpreter and code cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
      Only used in the debugging system, for implementing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
      JavaThread.currentFrameGuess() on x86. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  public boolean isJavaPCDbg(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
    // FIXME: this is not a complete enough set: must include areas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
    // like vtable stubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    return (getInterpreter().contains(addr) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
            getCodeCache().contains(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  /** FIXME: figure out where to stick this */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
  public int getInvocationEntryBCI() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
    return invocationEntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  /** FIXME: figure out where to stick this */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  public int getInvalidOSREntryBCI() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
    return invalidOSREntryBCI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  // FIXME: figure out where to stick this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  public boolean wizardMode() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
  public ReversePtrs getRevPtrs() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
    return revPtrs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
  public void setRevPtrs(ReversePtrs rp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
    revPtrs = rp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  public String getVMRelease() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    return vmRelease;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  public String getVMInternalInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
    return vmInternalInfo;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  public boolean isSharingEnabled() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
    if (sharingEnabled == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
      Flag flag = getCommandLineFlag("UseSharedSpaces");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
      sharingEnabled = (flag == null)? Boolean.FALSE :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
          (flag.getBool()? Boolean.TRUE: Boolean.FALSE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
    return sharingEnabled.booleanValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   751
  public boolean isCompressedOopsEnabled() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   752
    if (compressedOopsEnabled == null) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   753
        Flag flag = getCommandLineFlag("UseCompressedOops");
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   754
        compressedOopsEnabled = (flag == null) ? Boolean.FALSE:
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   755
             (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
   756
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   757
    return compressedOopsEnabled.booleanValue();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   758
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
5694
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   760
  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
   761
    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
   762
        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
   763
        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
   764
    }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   765
    return objectAlignmentInBytes;
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   766
  }
1e0532a6abff 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 3261
diff changeset
   767
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  // returns null, if not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
  public Flag[] getCommandLineFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
    if (commandLineFlags == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
       readCommandLineFlags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    return commandLineFlags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  public Flag getCommandLineFlag(String name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    if (flagsMap == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
      flagsMap = new HashMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
      Flag[] flags = getCommandLineFlags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
      for (int i = 0; i < flags.length; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
        flagsMap.put(flags[i].getName(), flags[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
    return (Flag) flagsMap.get(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   787
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
  private void readCommandLineFlags() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    // get command line flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
    TypeDataBase db = getTypeDataBase();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
       Type flagType = db.lookupType("Flag");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
       int numFlags = (int) flagType.getCIntegerField("numFlags").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
       // NOTE: last flag contains null values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
       commandLineFlags = new Flag[numFlags - 1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
       Address flagAddr = flagType.getAddressField("flags").getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
       AddressField typeFld = flagType.getAddressField("type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
       AddressField nameFld = flagType.getAddressField("name");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
       AddressField addrFld = flagType.getAddressField("addr");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
       AddressField kindFld = flagType.getAddressField("kind");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
       long flagSize = flagType.getSize(); // sizeof(Flag)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
       // NOTE: last flag contains null values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
       for (int f = 0; f < numFlags - 1; f++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
          String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
          String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
          Address addr = addrFld.getValue(flagAddr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
          String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
          commandLineFlags[f] = new Flag(type, name, addr, kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
          flagAddr = flagAddr.addOffsetTo(flagSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
       // sort flags by name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
       Arrays.sort(commandLineFlags, new Comparator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
                                        public int compare(Object o1, Object o2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
                                           Flag f1 = (Flag) o1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
                                           Flag f2 = (Flag) o2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
                                           return f1.getName().compareTo(f2.getName());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
                                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
                                     });
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
    } catch (Exception exp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
       // ignore. may be older version. command line flags not available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
  public String getSystemProperty(String key) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
    Properties props = getSystemProperties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
    return (props != null)? props.getProperty(key) : null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  public Properties getSystemProperties() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
    if (sysProps == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
       readSystemProperties();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
    return sysProps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  private void readSystemProperties() {
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7662
diff changeset
   842
     final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
     systemKls.iterate(new DefaultOopVisitor() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
                               ObjectReader objReader = new ObjectReader();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
                               public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
                                  if (field.getID().getName().equals("props")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
                                     try {
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 7662
diff changeset
   848
                                        sysProps = (Properties) objReader.readObject(field.getValue(systemKls.getJavaMirror()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
                                     } catch (Exception e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
                                        if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
                                           e.printStackTrace();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
                                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
                                     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
                                  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
                               }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
                        }, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
}