sa-jdi

s();
      } else if (cpu.equals("amd64")) {
        access = new Win32AMD64JavaThreadPDAccess();
      } else if (cpu.equals("ia64")) {
        access = new Win32IA64JavaThreadPDAccess();
      }
    }
    else if (os.equals("linux")) {
      if (cpu.equals("x86")) {
        access = new LinuxX86JavaThreadPDAccess();
      } else if (cpu.equals("ia64")) {
        access = new LinuxIA64JavaThreadPDAccess();
      } else if (cpu.equals("amd64")) {
        access = new LinuxAMD64JavaThreadPDAccess();
      } else if (cpu.equals("sparc")) {
        access = new LinuxSPARCJavaThreadPDAccess();
      }
    }
    if (access == null) {
      throw new RuntimeException("OS/CPU combination " + os + "/" + cpu + " not yet supported");
    }
    virtualConstructor = new VirtualConstructor(db);
    
    virtualConstructor.addMapping("JavaThread", JavaThread.class);
    if (!VM.getVM().isCore()) {
      virtualConstructor.addMapping("CompilerThread", CompilerThread.class);
    }
    virtualConstructor.addMapping("SurrogateLockerThread", JavaThread.class);
    virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class);
    virtualConstructor.addMapping("LowMemoryDetectorThread", LowMemoryDetectorThread.class);
  }
  
  public JavaThread first()
  {
    Address threadAddr = threadListField.getValue();
    if (threadAddr == null) {
      return null;
    }
    return createJavaThreadWrapper(threadAddr);
  }
  
  public JavaThread createJavaThreadWrapper(Address threadAddr)
  {
    try
    {
      JavaThread thread = (JavaThread)virtualConstructor.instantiateWrapperFor(threadAddr);
      thread.setThreadPDAccess(access);
      return thread;
    }
    catch (Exception e)
    {
      throw new RuntimeException("Unable to deduce type of thread from address " + threadAddr + " (expected type JavaThread, CompilerThread, LowMemoryDetectorThread, JvmtiAgentThread, or SurrogateLockerThread)", e);
    }
  }
  
  public void oopsDo(AddressVisitor oopVisitor)
  {
    for (JavaThread thread = first(); thread != null; thread = thread.next()) {
      thread.oopsDo(oopVisitor);
    }
  }
  
  public JavaThread owningThreadFromMonitor(Address o)
  {
    if (o == null) {
      return null;
    }
    for (JavaThread thread = first(); thread != null; thread = thread.next()) {
      if (o.equals(thread.threadObjectAddress())) {
        return thread;
      }
    }
    for (JavaThread thread = first(); thread != null; thread = thread.next()) {
      if (thread.isLockOwned(o)) {
        return thread;
      }
    }
    return null;
  }
  
  public JavaThread owningThreadFromMonitor(ObjectMonitor monitor)
  {
    return owningThreadFromMonitor(monitor.owner());
  }
  
  public List getPendingThreads(ObjectMonitor monitor)
  {
    List pendingThreads = new ArrayList();
    for (JavaThread thread = first(); thread != null; thread = thread.next()) {
      if (!thread.isCompilerThread())
      {
        ObjectMonitor pending = thread.getCurrentPendingMonitor();
        if (monitor.equals(pending)) {
          pendingThreads.add(thread);
        }
      }
    }
    return pendingThreads;
  }
  
  public List getWaitingThreads(ObjectMonitor monitor)
  {
    List pendingThreads = new ArrayList();
    for (JavaThread thread = first(); thread != null; thread = thread.next())
    {
      ObjectMonitor waiting = thread.getCurrentWaitingMonitor();
      if (monitor.equals(waiting)) {
        pendingThreads.add(thread);
      }
    }
    return pendingThreads;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.Threads
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.io.PrintStream;
import sun.jvm.hotspot.code.CodeBlob;
import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.code.NMethod;
import sun.jvm.hotspot.code.ScopeDesc;
import sun.jvm.hotspot.utilities.Assert;

public class VFrame
{
  protected Frame fr;
  protected RegisterMap regMap;
  protected JavaThread thread;
  
  protected VFrame(Frame f, RegisterMap regMap, JavaThread thread)
  {
    this.regMap = ((RegisterMap)regMap.clone());
    if (f != null) {
      fr = ((Frame)f.clone());
    }
    this.thread = thread;
  }
  
  public static VFrame newVFrame(Frame f, RegisterMap regMap, JavaThread thread, boolean unsafe, boolean mayBeImprecise)
  {
    if (f.isInterpretedFrame()) {
      return new InterpretedVFrame(f, regMap, thread);
    }
    if (!VM.getVM().isCore())
    {
      CodeBlob cb;
      CodeBlob cb;
      if (unsafe) {
        cb = VM.getVM().getCodeCache().findBlobUnsafe(f.getPC());
      } else {
        cb = VM.getVM().getCodeCache().findBlob(f.getPC());
      }
      if (cb != null)
      {
        if (cb.isNMethod())
        {
          NMethod nm = (NMethod)cb;
          
          ScopeDesc scope = null;
          if ((mayBeImprecise) || (VM.getVM().isDebugging())) {
            scope = nm.getScopeDescNearDbg(f.getPC());
          } else {
            scope = nm.getScopeDescAt(f.getPC());
          }
          return new CompiledVFrame(f, regMap, thread, scope, mayBeImprecise);
        }
        if (f.isGlueFrame())
        {
          RegisterMap tempMap = regMap.copy();
          Frame s = f.sender(tempMap);
          return newVFrame(s, tempMap, thread, unsafe, false);
        }
      }
    }
    return new ExternalVFrame(f, regMap, thread, mayBeImprecise);
  }
  
  public static VFrame newVFrame(Frame f, RegisterMap regMap, JavaThread thread)
  {
    return newVFrame(f, regMap, thread, false, false);
  }
  
  public Frame getFrame()
  {
    return fr;
  }
  
  public RegisterMap getRegisterMap()
  {
    return regMap;
  }
  
  public JavaThread getThread()
  {
    return thread;
  }
  
  public VFrame sender()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isTop(), "just checking");
    }
    return sender(false);
  }
  
  public VFrame sender(boolean mayBeImprecise)
  {
    RegisterMap tempMap = (RegisterMap)getRegisterMap().clone();
    if (fr.isFirstFrame()) {
      return null;
    }
    Frame s = fr.realSender(tempMap);
    if (s == null)
    {
      Assert.that(VM.getVM().getCPU().equals("ia64"), "Only ia64 should have null here");
      return null;
    }
    if (s.isFirstFrame()) {
      return null;
    }
    return newVFrame(s, tempMap, getThread(), VM.getVM().isDebugging(), mayBeImprecise);
  }
  
  public JavaVFrame javaSender()
  {
    boolean imprecise = false;
    if ((VM.getVM().isDebugging()) && 
      (!isJavaFrame())) {
      imprecise = mayBeImpreciseDbg();
    }
    VFrame f = sender(imprecise);
    while (f != null)
    {
      if (f.isJavaFrame()) {
        return (JavaVFrame)f;
      }
      f = f.sender(imprecise);
    }
    return null;
  }
  
  public boolean isTop()
  {
    return true;
  }
  
  public VFrame top()
  {
    VFrame vf = this;
    while (!vf.isTop()) {
      vf = vf.sender();
    }
    return vf;
  }
  
  public boolean isEntryFrame()
  {
    return false;
  }
  
  public boolean isJavaFrame()
  {
    return false;
  }
  
  public boolean isInterpretedFrame()
  {
    return false;
  }
  
  public boolean isCompiledFrame()
  {
    return false;
  }
  
  public boolean isDeoptimized()
  {
    return false;
  }
  
  public boolean mayBeImpreciseDbg()
  {
    return false;
  }
  
  public void print()
  {
    printOn(System.out);
  }
  
  public void printOn(PrintStream tty)
  {
    if (VM.getVM().wizardMode()) {
      fr.printValueOn(tty);
    }
  }
  
  public void printValue()
  {
    printValueOn(System.out);
  }
  
  public void printValueOn(PrintStream tty)
  {
    printOn(tty);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VFrame
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.debugger.cdbg.CDebugger;
import sun.jvm.hotspot.debugger.cdbg.ClosestSymbol;
import sun.jvm.hotspot.debugger.cdbg.LoadObject;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.types.WrongTypeException;

public class VirtualConstructor
{
  private TypeDataBase db;
  private Map map;
  
  public VirtualConstructor(TypeDataBase db)
  {
    this.db = db;
    map = new HashMap();
  }
  
  public boolean addMapping(String cTypeName, Class clazz)
  {
    if (map.get(cTypeName) != null) {
      return false;
    }
    map.put(cTypeName, clazz);
    return true;
  }
  
  public VMObject instantiateWrapperFor(Address addr)
    throws WrongTypeException
  {
    if (addr == null) {
      return null;
    }
    for (Iterator iter = map.keySet().iterator(); iter.hasNext();)
    {
      String typeName = (String)iter.next();
      if (db.addressTypeIsEqualToType(addr, db.lookupType(typeName))) {
        return (VMObject)VMObjectFactory.newObject((Class)map.get(typeName), addr);
      }
    }
    String message = "No suitable match for type of address " + addr;
    CDebugger cdbg = VM.getVM().getDebugger().getCDebugger();
    if (cdbg != null)
    {
      Address vtblPtr = addr.getAddressAt(0L);
      LoadObject lo = cdbg.loadObjectContainingPC(vtblPtr);
      if (lo != null)
      {
        ClosestSymbol symbol = lo.closestSymbolToPC(vtblPtr);
        if (symbol != null) {
          message = message + " (nearest symbol is " + symbol.getName() + ")";
        }
      }
    }
    throw new WrongTypeException(message);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VirtualConstructor
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.util.Observable;
import java.util.Observer;

final class VirtualSpace$1
  implements Observer
{
  public void update(Observable o, Object data)
  {
    VirtualSpace.access$000(VM.getVM().getTypeDataBase());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VirtualSpace.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.types.AddressField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class VirtualSpace
  extends VMObject
{
  private static AddressField lowField;
  private static AddressField highField;
  private static AddressField lowBoundaryField;
  private static AddressField highBoundaryField;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        VirtualSpace.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("VirtualSpace");
    
    lowField = type.getAddressField("_low");
    highField = type.getAddressField("_high");
    lowBoundaryField = type.getAddressField("_low_boundary");
    highBoundaryField = type.getAddressField("_high_boundary");
  }
  
  public VirtualSpace(Address addr)
  {
    super(addr);
  }
  
  public Address low()
  {
    return lowField.getValue(addr);
  }
  
  public Address high()
  {
    return highField.getValue(addr);
  }
  
  public Address lowBoundary()
  {
    return lowBoundaryField.getValue(addr);
  }
  
  public Address highBoundary()
  {
    return highBoundaryField.getValue(addr);
  }
  
  public long committedSize()
  {
    return high().minus(low());
  }
  
  public long reservedSize()
  {
    return highBoundary().minus(lowBoundary());
  }
  
  public long uncommittedSize()
  {
    return reservedSize() - committedSize();
  }
  
  public boolean contains(Address addr)
  {
    return (low().lessThanOrEqual(addr)) && (addr.lessThan(high()));
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VirtualSpace
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.util.Comparator;

final class VM$1
  implements Comparator
{
  private final VM this$0;
  
  VM$1(VM paramVM) {}
  
  public int compare(Object o1, Object o2)
  {
    VM.Flag f1 = (VM.Flag)o1;
    VM.Flag f2 = (VM.Flag)o2;
    return f1.getName().compareTo(f2.getName());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VM.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.util.Properties;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.utilities.Assert;
import sun.jvm.hotspot.utilities.ObjectReader;

final class VM$2
  extends DefaultOopVisitor
{
  ObjectReader objReader = new ObjectReader();
  private final VM this$0;
  
  VM$2(VM paramVM) {}
  
  public void doOop(OopField field, boolean isVMField)
  {
    if (field.getID().getName().equals("props")) {
      try
      {
        VM.access$402(this$0, (Properties)objReader.readObject(field.getValue(getObj())));
      }
      catch (Exception e)
      {
        if (Assert.ASSERTS_ENABLED) {
          e.printStackTrace();
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VM.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.types.CIntegerType;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.utilities.Assert;

public final class VM$Flag
{
  private String type;
  private String name;
  private Address addr;
  private String kind;
  
  VM$Flag(String x0, String x1, Address x2, String x3, VM.1 x4)
  {
    this(x0, x1, x2, x3);
  }
  
  private VM$Flag(String type, String name, Address addr, String kind)
  {
    this.type = type;
    this.name = name;
    this.addr = addr;
    this.kind = kind;
  }
  
  public String getType()
  {
    return type;
  }
  
  public String getName()
  {
    return name;
  }
  
  public Address getAddress()
  {
    return addr;
  }
  
  public String getKind()
  {
    return kind;
  }
  
  public boolean isBool()
  {
    return type.equals("bool");
  }
  
  public boolean getBool()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isBool(), "not a bool flag!");
    }
    return addr.getCIntegerAt(0L, VM.access$000().getSize(), VM.access$000().isUnsigned()) != 0L;
  }
  
  public boolean isIntx()
  {
    return type.equals("intx");
  }
  
  public long getIntx()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isIntx(), "not a intx flag!");
    }
    return addr.getCIntegerAt(0L, VM.access$100().getSize(), false);
  }
  
  public boolean isUIntx()
  {
    return type.equals("uintx");
  }
  
  public long getUIntx()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isUIntx(), "not a uintx flag!");
    }
    return addr.getCIntegerAt(0L, VM.access$200().getSize(), true);
  }
  
  public String getValue()
  {
    if (isBool()) {
      return new Boolean(getBool()).toString();
    }
    if (isIntx()) {
      return new Long(getIntx()).toString();
    }
    if (isUIntx()) {
      return new Long(getUIntx()).toString();
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VM.Flag
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.io.BufferedInputStream;
import java.io.PrintStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Observer;
import java.util.Properties;
import sun.jvm.hotspot.c1.Runtime1;
import sun.jvm.hotspot.code.CodeCache;
import sun.jvm.hotspot.code.VMRegImpl;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.JVMDebugger;
import sun.jvm.hotspot.debugger.MachineDescription;
import sun.jvm.hotspot.interpreter.Interpreter;
import sun.jvm.hotspot.memory.StringTable;
import sun.jvm.hotspot.memory.SymbolTable;
import sun.jvm.hotspot.memory.SystemDictionary;
import sun.jvm.hotspot.memory.Universe;
import sun.jvm.hotspot.oops.DefaultOopVisitor;
import sun.jvm.hotspot.oops.FieldIdentifier;
import sun.jvm.hotspot.oops.InstanceKlass;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.OopField;
import sun.jvm.hotspot.types.AddressField;
import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.CIntegerType;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.utilities.Assert;
import sun.jvm.hotspot.utilities.CStringUtilities;
import sun.jvm.hotspot.utilities.ObjectReader;
import sun.jvm.hotspot.utilities.PlatformInfo;
import sun.jvm.hotspot.utilities.ReversePtrs;

public class VM
{
  private static List vmInitializedObservers = new ArrayList();
  private List vmResumedObservers = new ArrayList();
  private List vmSuspendedObservers = new ArrayList();
  
  public static final class Flag
  {
    private String type;
    private String name;
    private Address addr;
    private String kind;
    
    Flag(String x0, String x1, Address x2, String x3, VM.1 x4)
    {
      this(x0, x1, x2, x3);
    }
    
    private Flag(String type, String name, Address addr, String kind)
    {
      this.type = type;
      this.name = name;
      this.addr = addr;
      this.kind = kind;
    }
    
    public String getType()
    {
      return type;
    }
    
    public String getName()
    {
      return name;
    }
    
    public Address getAddress()
    {
      return addr;
    }
    
    public String getKind()
    {
      return kind;
    }
    
    public boolean isBool()
    {
      return type.equals("bool");
    }
    
    public boolean getBool()
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(isBool(), "not a bool flag!");
      }
      return addr.getCIntegerAt(0L, VM.boolType.getSize(), VM.boolType.isUnsigned()) != 0L;
    }
    
    public boolean isIntx()
    {
      return type.equals("intx");
    }
    
    public long getIntx()
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(isIntx(), "not a intx flag!");
      }
      return addr.getCIntegerAt(0L, VM.intxType.getSize(), false);
    }
    
    public boolean isUIntx()
    {
      return type.equals("uintx");
    }
    
    public long getUIntx()
    {
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(isUIntx(), "not a uintx flag!");
      }
      return addr.getCIntegerAt(0L, VM.uintxType.getSize(), true);
    }
    
    public String getValue()
    {
      if (isBool()) {
        return new Boolean(getBool()).toString();
      }
      if (isIntx()) {
        return new Long(getIntx()).toString();
      }
      if (isUIntx()) {
        return new Long(getUIntx()).toString();
      }
      return null;
    }
  }
  
  private static void checkVMVersion(String vmRelease)
  {
    if (System.getProperty("sun.jvm.hotspot.runtime.VM.disableVersionCheck") == null)
    {
      String versionProp = "sun.jvm.hotspot.runtime.VM.saBuildVersion";
      String saVersion = saProps.getProperty(versionProp);
      if (saVersion == null) {
        throw new RuntimeException("Missing property " + versionProp);
      }
      String vmVersion = vmRelease.replaceAll("(-fastdebug)|(-debug)|(-jvmg)|(-optimized)|(-profiled)", "");
      if (saVersion.equals(vmVersion)) {
        return;
      }
      if ((saVersion.indexOf('-') == saVersion.lastIndexOf('-')) && (vmVersion.indexOf('-') == vmVersion.lastIndexOf('-'))) {
        throw new VMVersionMismatchException(saVersion, vmRelease);
      }
      System.err.println("WARNING: Hotspot VM version " + vmRelease + " does not match with SA version " + saVersion + "." + " You may see unexpected results. ");
    }
    else
    {
      System.err.println("WARNING: You have disabled SA and VM version check. You may be using incompatible version of SA and you may see unexpected results.");
    }
  }
  
  private static final Properties saProps = new Properties();
  
  static
  {
    URL url = null;
    try
    {
      url = VM.class.getClassLoader().getResource("sa.properties");
      saProps.load(new BufferedInputStream(url.openStream()));
    }
    catch (Exception e)
    {
      throw new RuntimeException("Unable to load properties  " + (url == null ? "null" : url.toString()) + ": " + e.getMessage());
    }
  }
  
  private static final boolean disableDerivedPrinterTableCheck = System.getProperty("sun.jvm.hotspot.runtime.VM.disableDerivedPointerTableCheck") != null;
  private static VM soleInstance;
  private TypeDataBase db;
  private boolean isBigEndian;
  private JVMDebugger debugger;
  private long stackBias;
  private long logAddressSize;
  private Universe universe;
  private ObjectHeap heap;
  private SymbolTable symbols;
  private StringTable strings;
  private SystemDictionary dict;
  private Threads threads;
  private ObjectSynchronizer synchronizer;
  private JNIHandles handles;
  private Interpreter interpreter;
  private StubRoutines stubRoutines;
  private Bytes bytes;
  private boolean usingClientCompiler;
  private boolean usingServerCompiler;
  private boolean useTLAB;
  private boolean isLP64;
  private int bytesPerLong;
  private int objectAlignmentInBytes;
  private int minObjAlignmentInBytes;
  private int logMinObjAlignmentInBytes;
  private int heapWordSize;
  private int heapOopSize;
  private int oopSize;
  private CodeCache codeCache;
  private Runtime1 runtime1;
  private int invocationEntryBCI;
  private int invalidOSREntryBCI;
  private ReversePtrs revPtrs;
  private VMRegImpl vmregImpl;
  private Properties sysProps;
  private String vmRelease;
  private String vmInternalInfo;
  private Flag[] commandLineFlags;
  private Map flagsMap;
  private static Type intxType;
  private static Type uintxType;
  private static CIntegerType boolType;
  private Boolean sharingEnabled;
  private Boolean compressedOopsEnabled;
  
  private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian)
  {
    this.db = db;
    this.debugger = debugger;
    this.isBigEndian = isBigEndian;
    if (db.getAddressSize() == 4L) {
      logAddressSize = 2L;
    } else if (db.getAddressSize() == 8L) {
      logAddressSize = 3L;
    } else {
      throw new RuntimeException("Address size " + db.getAddressSize() + " not yet supported");
    }
    try
    {
      Type vmVersion = db.lookupType("Abstract_VM_Version");
      Address releaseAddr = vmVersion.getAddressField("_s_vm_release").getValue();
      vmRelease = CStringUtilities.getString(releaseAddr);
      Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue();
      vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr);
    }
    catch (Exception exp)
    {
      throw new RuntimeException("can't determine target's VM version : " + exp.getMessage());
    }
    checkVMVersion(vmRelease);
    
    stackBias = db.lookupIntConstant("STACK_BIAS").intValue();
    invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue();
    invalidOSREntryBCI = db.lookupIntConstant("InvalidOSREntryBci").intValue();
    
    Type type = db.lookupType("methodOopDesc");
    if (type.getField("_from_compiled_entry", false, false) == null)
    {
      usingClientCompiler = false;
      usingServerCompiler = false;
    }
    else if (type.getField("_interpreter_invocation_count", false, false) != null)
    {
      usingServerCompiler = true;
    }
    else
    {
      usingClientCompiler = true;
    }
    useTLAB = (db.lookupIntConstant("UseTLAB").intValue() != 0);
    if (debugger != null) {
      isLP64 = debugger.getMachineDescription().isLP64();
    }
    bytesPerLong = db.lookupIntConstant("BytesPerLong").intValue();
    heapWordSize = db.lookupIntConstant("HeapWordSize").intValue();
    oopSize = db.lookupIntConstant("oopSize").intValue();
    
    intxType = db.lookupType("intx");
    uintxType = db.lookupType("uintx");
    boolType = (CIntegerType)db.lookupType("bool");
    
    minObjAlignmentInBytes = getObjectAlignmentInBytes();
    if (minObjAlignmentInBytes == 8) {
      logMinObjAlignmentInBytes = 3;
    } else if (minObjAlignmentInBytes == 16) {
      logMinObjAlignmentInBytes = 4;
    } else {
      throw new RuntimeException("Object alignment " + minObjAlignmentInBytes + " not yet supported");
    }
    if (isCompressedOopsEnabled()) {
      heapOopSize = ((int)getIntSize());
    } else {
      heapOopSize = ((int)getOopSize());
    }
  }
  
  public static void initialize(TypeDataBase db, boolean isBigEndian)
  {
    if (soleInstance != null) {
      throw new RuntimeException("Attempt to initialize VM twice");
    }
    soleInstance = new VM(db, null, isBigEndian);
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext();) {
      ((Observer)iter.next()).update(null, null);
    }
  }
  
  public static void initialize(TypeDataBase db, JVMDebugger debugger)
  {
    if (soleInstance != null) {
      throw new RuntimeException("Attempt to initialize VM twice");
    }
    soleInstance = new VM(db, debugger, debugger.getMachineDescription().isBigEndian());
    for (Iterator iter = vmInitializedObservers.iterator(); iter.hasNext();) {
      ((Observer)iter.next()).update(null, null);
    }
    debugger.putHeapConst(soleInstance.getHeapOopSize(), Universe.getNarrowOopBase(), Universe.getNarrowOopShift());
  }
  
  public static void shutdown()
  {
    soleInstance = null;
  }
  
  public static void registerVMInitializedObserver(Observer o)
  {
    vmInitializedObservers.add(o);
    o.update(null, null);
  }
  
  public static VM getVM()
  {
    if (soleInstance == null) {
      throw new RuntimeException("VM.initialize() was not yet called");
    }
    return soleInstance;
  }
  
  public void registerVMResumedObserver(Observer o)
  {
    vmResumedObservers.add(o);
  }
  
  public void registerVMSuspendedObserver(Observer o)
  {
    vmSuspendedObservers.add(o);
  }
  
  public void fireVMResumed()
  {
    for (Iterator iter = vmResumedObservers.iterator(); iter.hasNext();) {
      ((Observer)iter.next()).update(null, null);
    }
  }
  
  public void fireVMSuspended()
  {
    for (Iterator iter = vmSuspendedObservers.iterator(); iter.hasNext();) {
      ((Observer)iter.next()).update(null, null);
    }
  }
  
  public String getOS()
  {
    if (debugger != null) {
      return debugger.getOS();
    }
    return PlatformInfo.getOS();
  }
  
  public String getCPU()
  {
    if (debugger != null) {
      return debugger.getCPU();
    }
    return PlatformInfo.getCPU();
  }
  
  public Type lookupType(String cTypeName)
  {
    return db.lookupType(cTypeName);
  }
  
  public Integer lookupIntConstant(String name)
  {
    return db.lookupIntConstant(name);
  }
  
  public long getAddressSize()
  {
    return db.getAddressSize();
  }
  
  public long getOopSize()
  {
    return oopSize;
  }
  
  public long getLogAddressSize()
  {
    return logAddressSize;
  }
  
  public long getIntSize()
  {
    return db.getJIntType().getSize();
  }
  
  public long getStackBias()
  {
    return stackBias;
  }
  
  public boolean isLP64()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isDebugging(), "Debugging system only for now");
    }
    return isLP64;
  }
  
  public int getBytesPerLong()
  {
    return bytesPerLong;
  }
  
  public int getMinObjAlignmentInBytes()
  {
    return minObjAlignmentInBytes;
  }
  
  public int getLogMinObjAlignmentInBytes()
  {
    return logMinObjAlignmentInBytes;
  }
  
  public int getHeapWordSize()
  {
    return heapWordSize;
  }
  
  public int getHeapOopSize()
  {
    return heapOopSize;
  }
  
  public long alignUp(long size, long alignment)
  {
    return size + alignment - 1L & (alignment - 1L ^ 0xFFFFFFFFFFFFFFFF);
  }
  
  public long alignDown(long size, long alignment)
  {
    return size & (alignment - 1L ^ 0xFFFFFFFFFFFFFFFF);
  }
  
  public int buildIntFromShorts(short low, short high)
  {
    return high << 16 | low & 0xFFFF;
  }
  
  public long buildLongFromIntsPD(int oneHalf, int otherHalf)
  {
    if (isBigEndian) {
      return otherHalf << 32 | oneHalf & 0xFFFFFFFF;
    }
    return oneHalf << 32 | otherHalf & 0xFFFFFFFF;
  }
  
  public boolean getUseTLAB()
  {
    return useTLAB;
  }
  
  public TypeDataBase getTypeDataBase()
  {
    return db;
  }
  
  public Universe getUniverse()
  {
    if (universe == null) {
      universe = new Universe();
    }
    return universe;
  }
  
  public ObjectHeap getObjectHeap()
  {
    if (heap == null) {
      heap = new ObjectHeap(db);
    }
    return heap;
  }
  
  public SymbolTable getSymbolTable()
  {
    if (symbols == null) {
      symbols = SymbolTable.getTheTable();
    }
    return symbols;
  }
  
  public StringTable getStringTable()
  {
    if (strings == null) {
      strings = StringTable.getTheTable();
    }
    return strings;
  }
  
  public SystemDictionary getSystemDictionary()
  {
    if (dict == null) {
      dict = new SystemDictionary();
    }
    return dict;
  }
  
  public Threads getThreads()
  {
    if (threads == null) {
      threads = new Threads();
    }
    return threads;
  }
  
  public ObjectSynchronizer getObjectSynchronizer()
  {
    if (synchronizer == null) {
      synchronizer = new ObjectSynchronizer();
    }
    return synchronizer;
  }
  
  public JNIHandles getJNIHandles()
  {
    if (handles == null) {
      handles = new JNIHandles();
    }
    return handles;
  }
  
  public Interpreter getInterpreter()
  {
    if (interpreter == null) {
      interpreter = new Interpreter();
    }
    return interpreter;
  }
  
  public StubRoutines getStubRoutines()
  {
    if (stubRoutines == null) {
      stubRoutines = new StubRoutines();
    }
    return stubRoutines;
  }
  
  public VMRegImpl getVMRegImplInfo()
  {
    if (vmregImpl == null) {
      vmregImpl = new VMRegImpl();
    }
    return vmregImpl;
  }
  
  public Bytes getBytes()
  {
    if (bytes == null) {
      bytes = new Bytes(debugger.getMachineDescription());
    }
    return bytes;
  }
  
  public boolean isBigEndian()
  {
    return isBigEndian;
  }
  
  public boolean isCore()
  {
    return (!usingClientCompiler) && (!usingServerCompiler);
  }
  
  public boolean isClientCompiler()
  {
    return usingClientCompiler;
  }
  
  public boolean isServerCompiler()
  {
    return usingServerCompiler;
  }
  
  public boolean useDerivedPointerTable()
  {
    return !disableDerivedPrinterTableCheck;
  }
  
  public CodeCache getCodeCache()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(!isCore(), "noncore builds only");
    }
    if (codeCache == null) {
      codeCache = new CodeCache();
    }
    return codeCache;
  }
  
  public Runtime1 getRuntime1()
  {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(isClientCompiler(), "C1 builds only");
    }
    if (runtime1 == null) {
      runtime1 = new Runtime1();
    }
    return runtime1;
  }
  
  public boolean isDebugging()
  {
    return debugger != null;
  }
  
  public JVMDebugger getDebugger()
  {
    if (debugger == null) {
      throw new RuntimeException("Attempt to use debugger in runtime system");
    }
    return debugger;
  }
  
  public boolean isJavaPCDbg(Address addr)
  {
    return (getInterpreter().contains(addr)) || (getCodeCache().contains(addr));
  }
  
  public int getInvocationEntryBCI()
  {
    return invocationEntryBCI;
  }
  
  public int getInvalidOSREntryBCI()
  {
    return invalidOSREntryBCI;
  }
  
  public boolean wizardMode()
  {
    return true;
  }
  
  public ReversePtrs getRevPtrs()
  {
    return revPtrs;
  }
  
  public void setRevPtrs(ReversePtrs rp)
  {
    revPtrs = rp;
  }
  
  public String getVMRelease()
  {
    return vmRelease;
  }
  
  public String getVMInternalInfo()
  {
    return vmInternalInfo;
  }
  
  public boolean isSharingEnabled()
  {
    if (sharingEnabled == null)
    {
      Flag flag = getCommandLineFlag("UseSharedSpaces");
      sharingEnabled = (flag.getBool() ? Boolean.TRUE : flag == null ? Boolean.FALSE : Boolean.FALSE);
    }
    return sharingEnabled.booleanValue();
  }
  
  public boolean isCompressedOopsEnabled()
  {
    if (compressedOopsEnabled == null)
    {
      Flag flag = getCommandLineFlag("UseCompressedOops");
      compressedOopsEnabled = (flag.getBool() ? Boolean.TRUE : flag == null ? Boolean.FALSE : Boolean.FALSE);
    }
    return compressedOopsEnabled.booleanValue();
  }
  
  public int getObjectAlignmentInBytes()
  {
    if (objectAlignmentInBytes == 0)
    {
      Flag flag = getCommandLineFlag("ObjectAlignmentInBytes");
      objectAlignmentInBytes = (flag == null ? 8 : (int)flag.getIntx());
    }
    return objectAlignmentInBytes;
  }
  
  public Flag[] getCommandLineFlags()
  {
    if (commandLineFlags == null) {
      readCommandLineFlags();
    }
    return commandLineFlags;
  }
  
  public Flag getCommandLineFlag(String name)
  {
    if (flagsMap == null)
    {
      flagsMap = new HashMap();
      Flag[] flags = getCommandLineFlags();
      for (int i = 0; i < flags.length; i++) {
        flagsMap.put(flags[i].getName(), flags[i]);
      }
    }
    return (Flag)flagsMap.get(name);
  }
  
  private void readCommandLineFlags()
  {
    TypeDataBase db = getTypeDataBase();
    try
    {
      Type flagType = db.lookupType("Flag");
      int numFlags = (int)flagType.getCIntegerField("numFlags").getValue();
      
      commandLineFlags = new Flag[numFlags - 1];
      
      Address flagAddr = flagType.getAddressField("flags").getValue();
      
      AddressField typeFld = flagType.getAddressField("type");
      AddressField nameFld = flagType.getAddressField("name");
      AddressField addrFld = flagType.getAddressField("addr");
      AddressField kindFld = flagType.getAddressField("kind");
      
      long flagSize = flagType.getSize();
      for (int f = 0; f < numFlags - 1; f++)
      {
        String type = CStringUtilities.getString(typeFld.getValue(flagAddr));
        String name = CStringUtilities.getString(nameFld.getValue(flagAddr));
        Address addr = addrFld.getValue(flagAddr);
        String kind = CStringUtilities.getString(kindFld.getValue(flagAddr));
        commandLineFlags[f] = new Flag(type, name, addr, kind, null);
        flagAddr = flagAddr.addOffsetTo(flagSize);
      }
      Arrays.sort(commandLineFlags, new Comparator()
      {
        public int compare(Object o1, Object o2)
        {
          VM.Flag f1 = (VM.Flag)o1;
          VM.Flag f2 = (VM.Flag)o2;
          return f1.getName().compareTo(f2.getName());
        }
      });
    }
    catch (Exception exp) {}
  }
  
  public String getSystemProperty(String key)
  {
    Properties props = getSystemProperties();
    return props != null ? props.getProperty(key) : null;
  }
  
  public Properties getSystemProperties()
  {
    if (sysProps == null) {
      readSystemProperties();
    }
    return sysProps;
  }
  
  private void readSystemProperties()
  {
    getSystemDictionary();InstanceKlass systemKls = SystemDictionary.getSystemKlass();
    systemKls.iterate(new DefaultOopVisitor()
    {
      ObjectReader objReader = new ObjectReader();
      
      public void doOop(OopField field, boolean isVMField)
      {
        if (field.getID().getName().equals("props")) {
          try
          {
            sysProps = ((Properties)objReader.readObject(field.getValue(getObj())));
          }
          catch (Exception e)
          {
            if (Assert.ASSERTS_ENABLED) {
              e.printStackTrace();
            }
          }
        }
      }
    }, false);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VM
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import sun.jvm.hotspot.debugger.Address;

public class VMObject
{
  protected Address addr;
  
  public VMObject(Address addr)
  {
    this.addr = addr;
  }
  
  public String toString()
  {
    return getClass().getName() + "@" + addr;
  }
  
  public boolean equals(Object arg)
  {
    if (arg == null) {
      return false;
    }
    if (!getClass().equals(arg.getClass())) {
      return false;
    }
    VMObject obj = (VMObject)arg;
    if (!addr.equals(addr)) {
      return false;
    }
    return true;
  }
  
  public int hashCode()
  {
    return addr.hashCode();
  }
  
  public Address getAddress()
  {
    return addr;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VMObject
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.lang.reflect.Constructor;
import sun.jvm.hotspot.debugger.Address;

public class VMObjectFactory
{
  public static Object newObject(Class clazz, Address addr)
    throws ConstructionException
  {
    try
    {
      if (addr == null) {
        return null;
      }
      Constructor c = clazz.getConstructor(new Class[] { Address.class });
      
      return c.newInstance(new Object[] { addr });
    }
    catch (Exception e)
    {
      throw new ConstructionException(e);
    }
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VMObjectFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.util.Observable;
import java.util.Observer;

final class VMReg$1
  implements Observer
{
  public void update(Observable o, Object data)
  {
    VMReg.access$000(VM.getVM().getTypeDataBase());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VMReg.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.types.Field;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class VMReg
{
  private int value;
  public static Address matcherRegEncodeAddr;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        VMReg.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static void initialize(TypeDataBase db)
  {
    if (VM.getVM().isServerCompiler())
    {
      Type type = db.lookupType("Matcher");
      Field f = type.getField("_regEncode");
      matcherRegEncodeAddr = f.getStaticFieldAddress();
    }
  }
  
  public VMReg(int i)
  {
    value = i;
  }
  
  public int getValue()
  {
    return value;
  }
  
  public int regEncode()
  {
    if (matcherRegEncodeAddr != null) {
      return (int)matcherRegEncodeAddr.getCIntegerAt(value, 1L, true);
    }
    return value;
  }
  
  public boolean equals(Object arg)
  {
    if ((arg != null) || (!(arg instanceof VMReg))) {
      return false;
    }
    return value == value;
  }
  
  public boolean lessThan(VMReg arg)
  {
    return value < value;
  }
  
  public boolean lessThanOrEqual(VMReg arg)
  {
    return value <= value;
  }
  
  public boolean greaterThan(VMReg arg)
  {
    return value > value;
  }
  
  public boolean greaterThanOrEqual(VMReg arg)
  {
    return value >= value;
  }
  
  public int minus(VMReg arg)
  {
    return value - value;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.runtime.VMReg
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.runtime;

public class VMVersionMismatchException
  extends RuntimeException
{
  private String supportedVersions;
  private String targetVersion;
  
  public VMVersionMismatchException(String supported, String target)
  {
    supportedVersions = supported;
    targetVersion = target;
  }
  
  public String getMessage()
  {
    StringBuffer msg = new StringBuffer();
    msg.append("Supported versions are ");
    msg.append(supportedVersions);
    msg.append(". Target VM i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd