sa-jdi

ookupConstInt("SA_CMD_RESUME_ALL");
    SA_CMD_TOGGLE_BREAKPOINT = lookupConstInt("SA_CMD_TOGGLE_BREAKPOINT");
    SA_CMD_BUF_SIZE = lookupConstInt("SA_CMD_BUF_SIZE");
    
    saAttached = lookupCInt("saAttached");
    saEventPending = lookupCInt("saEventPending");
    saEventKind = lookupCInt("saEventKind");
    saCmdPending = lookupCInt("saCmdPending");
    saCmdType = lookupCInt("saCmdType");
    saCmdResult = lookupCInt("saCmdResult");
    saCmdResultErrMsg = lookupCString("saCmdResultErrMsg", SA_CMD_BUF_SIZE);
    
    saCmdBkptSrcFileName = lookupCString("saCmdBkptSrcFileName", SA_CMD_BUF_SIZE);
    saCmdBkptPkgName = lookupCString("saCmdBkptPkgName", SA_CMD_BUF_SIZE);
    saCmdBkptLineNumber = lookupCInt("saCmdBkptLineNumber");
    saCmdBkptResWasError = lookupCInt("saCmdBkptResWasError");
    saCmdBkptResLineNumber = lookupCInt("saCmdBkptResLineNumber");
    saCmdBkptResBCI = lookupCInt("saCmdBkptResBCI");
    saCmdBkptResWasSet = lookupCInt("saCmdBkptResWasSet");
    saCmdBkptResMethodName = lookupCString("saCmdBkptResMethodName", SA_CMD_BUF_SIZE);
    saCmdBkptResMethodSig = lookupCString("saCmdBkptResMethodSig", SA_CMD_BUF_SIZE);
    
    lookup("saExceptionThread");
    lookup("saExceptionClass");
    lookup("saExceptionMethod");
    lookup("saExceptionLocation");
    lookup("saExceptionException");
    lookup("saExceptionCatchClass");
    lookup("saExceptionCatchMethod");
    lookup("saExceptionCatchLocation");
    lookup("saBreakpointThread");
    lookup("saBreakpointClass");
    lookup("saBreakpointMethod");
    lookup("saBreakpointLocation");
    
    saAttached.setValue(1L);
    attached = true;
  }
  
  public void detach()
  {
    saAttached.setValue(0L);
    attached = false;
    saLibName = null;
  }
  
  public void setCommandTimeout(long millis)
  {
    timeoutMillis = millis;
  }
  
  public long getCommandTimeout()
  {
    return timeoutMillis;
  }
  
  public boolean eventPending()
  {
    return saEventPending.getValue() != 0L;
  }
  
  public Event eventPoll()
  {
    if (saEventPending.getValue() == 0L) {
      return null;
    }
    int kind = (int)saEventKind.getValue();
    switch (kind)
    {
    case 4: 
      JNIHandleAccessor thread = lookupJNIHandle("saExceptionThread");
      JNIHandleAccessor clazz = lookupJNIHandle("saExceptionClass");
      JNIid method = lookupJNIid("saExceptionMethod");
      CIntegerAccessor location = lookupCInt("saExceptionLocation");
      JNIHandleAccessor exception = lookupJNIHandle("saExceptionException");
      JNIHandleAccessor catchClass = lookupJNIHandle("saExceptionCatchClass");
      JNIid catchMethod = lookupJNIid("saExceptionCatchMethod");
      CIntegerAccessor catchLocation = lookupCInt("saExceptionCatchLocation");
      return new ExceptionEvent(thread.getValue(), clazz.getValue(), method, (int)location.getValue(), exception.getValue(), catchClass.getValue(), catchMethod, (int)catchLocation.getValue());
    case 2: 
      JNIHandleAccessor thread = lookupJNIHandle("saBreakpointThread");
      JNIHandleAccessor clazz = lookupJNIHandle("saBreakpointClass");
      JNIid method = lookupJNIid("saBreakpointMethod");
      CIntegerAccessor location = lookupCInt("saBreakpointLocation");
      return new BreakpointEvent(thread.getValue(), clazz.getValue(), method, (int)location.getValue());
    }
    throw new DebuggerException("Unsupported event type " + kind);
  }
  
  public void eventContinue()
  {
    saEventPending.setValue(0L);
  }
  
  public void suspend()
  {
    saCmdType.setValue(SA_CMD_SUSPEND_ALL);
    saCmdPending.setValue(1L);
    waitForCommandCompletion();
    suspended = true;
  }
  
  public void resume()
  {
    saCmdType.setValue(SA_CMD_RESUME_ALL);
    saCmdPending.setValue(1L);
    waitForCommandCompletion();
    suspended = false;
  }
  
  public boolean isSuspended()
  {
    return suspended;
  }
  
  public static class BreakpointToggleResult
  {
    private boolean success;
    private String errMsg;
    private int lineNumber;
    private int bci;
    private boolean wasSet;
    private String methodName;
    private String methodSig;
    
    public BreakpointToggleResult(int lineNumber, int bci, boolean wasSet, String methodName, String methodSig)
    {
      this.lineNumber = lineNumber;
      this.bci = bci;
      this.wasSet = wasSet;
      this.methodName = methodName;
      this.methodSig = methodSig;
      success = true;
    }
    
    public BreakpointToggleResult(String errMsg)
    {
      this.errMsg = errMsg;
      success = false;
    }
    
    public boolean getSuccess()
    {
      return success;
    }
    
    public String getErrMsg()
    {
      return errMsg;
    }
    
    public int getLineNumber()
    {
      return lineNumber;
    }
    
    public int getBCI()
    {
      return bci;
    }
    
    public boolean getWasSet()
    {
      return wasSet;
    }
    
    public String getMethodName()
    {
      return methodName;
    }
    
    public String getMethodSignature()
    {
      return methodSig;
    }
  }
  
  public BreakpointToggleResult toggleBreakpoint(String srcFileName, String pkgName, int lineNo)
  {
    saCmdBkptSrcFileName.setValue(srcFileName);
    saCmdBkptPkgName.setValue(pkgName);
    saCmdBkptLineNumber.setValue(lineNo);
    saCmdType.setValue(SA_CMD_TOGGLE_BREAKPOINT);
    saCmdPending.setValue(1L);
    if (waitForCommandCompletion(true)) {
      return new BreakpointToggleResult((int)saCmdBkptResLineNumber.getValue(), (int)saCmdBkptResBCI.getValue(), saCmdBkptResWasSet.getValue() != 0L, saCmdBkptResMethodName.getValue(), saCmdBkptResMethodSig.getValue());
    }
    return new BreakpointToggleResult(saCmdResultErrMsg.getValue());
  }
  
  private CIntegerAccessor lookupCInt(String symbolName)
  {
    return new CIntegerAccessor(lookup(symbolName), 4L, false);
  }
  
  private CStringAccessor lookupCString(String symbolName, int bufLen)
  {
    return new CStringAccessor(lookup(symbolName), bufLen);
  }
  
  private JNIHandleAccessor lookupJNIHandle(String symbolName)
  {
    return new JNIHandleAccessor(lookup(symbolName), VM.getVM().getObjectHeap());
  }
  
  private JNIid lookupJNIid(String symbolName)
  {
    Address idAddr = lookup(symbolName).getAddressAt(0L);
    if (idAddr == null) {
      return null;
    }
    return new JNIid(idAddr, VM.getVM().getObjectHeap());
  }
  
  private int lookupConstInt(String symbolName)
  {
    Address addr = lookup(symbolName);
    return (int)addr.getCIntegerAt(0L, 4L, false);
  }
  
  private boolean setupLookup(String symbolName)
  {
    if (saLibName == null)
    {
      for (int i = 0; i < saLibNames.length; i++)
      {
        Address addr = dbg.lookup(saLibNames[i], symbolName);
        if (addr != null)
        {
          saLibName = saLibNames[i];
          return true;
        }
      }
      return false;
    }
    return true;
  }
  
  private Address lookup(String symbolName)
  {
    if (saLibName == null)
    {
      for (int i = 0; i < saLibNames.length; i++)
      {
        Address addr = dbg.lookup(saLibNames[i], symbolName);
        if (addr != null)
        {
          saLibName = saLibNames[i];
          return addr;
        }
      }
      throw new DebuggerException("Unable to find symbol " + symbolName + " in any of the known names for the SA");
    }
    Address addr = dbg.lookup(saLibName, symbolName);
    if (addr == null) {
      throw new DebuggerException("Unable to find symbol " + symbolName + " in " + saLibName);
    }
    return addr;
  }
  
  private void waitForCommandCompletion()
  {
    waitForCommandCompletion(false);
  }
  
  private boolean waitForCommandCompletion(boolean forBreakpoint)
  {
    long start = System.currentTimeMillis();
    long cur = start;
    while ((saCmdPending.getValue() != 0L) && (cur - start < timeoutMillis))
    {
      try
      {
        Thread.currentThread();Thread.sleep(10L);
      }
      catch (InterruptedException e) {}
      cur = System.currentTimeMillis();
    }
    if (saCmdPending.getValue() != 0L)
    {
      detach();
      throw new DebuggerException("VM appears to have died");
    }
    boolean succeeded = saCmdResult.getValue() == 0L;
    if ((!succeeded) && ((!forBreakpoint) || (saCmdBkptResWasError.getValue() != 0L)))
    {
      String err = saCmdResultErrMsg.getValue();
      throw new DebuggerException("Error executing JVMDI command: " + err);
    }
    return succeeded;
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class BinaryTreeDictionary
  extends VMObject
{
  private static CIntegerField totalSizeField;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        BinaryTreeDictionary.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("BinaryTreeDictionary");
    totalSizeField = type.getCIntegerField("_totalSize");
  }
  
  public long size()
  {
    return totalSizeField.getValue(addr);
  }
  
  public BinaryTreeDictionary(Address addr)
  {
    super(addr);
  }
}

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

import sun.jvm.hotspot.debugger.Address;

public abstract class CardGeneration
  extends Generation
{
  public CardGeneration(Address addr)
  {
    super(addr);
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.runtime.VirtualSpace;
import sun.jvm.hotspot.types.AddressField;
import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.Field;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.utilities.BitMap;

public class CMSBitMap
  extends VMObject
{
  private static AddressField bmStartWordField;
  private static CIntegerField bmWordSizeField;
  private static CIntegerField shifterField;
  private static long virtualSpaceFieldOffset;
  
  public CMSBitMap(Address addr)
  {
    super(addr);
  }
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CMSBitMap.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("CMSBitMap");
    bmStartWordField = type.getAddressField("_bmStartWord");
    bmWordSizeField = type.getCIntegerField("_bmWordSize");
    shifterField = type.getCIntegerField("_shifter");
    
    virtualSpaceFieldOffset = type.getField("_virtual_space").getOffset();
  }
  
  public void printAll()
  {
    System.out.println("bmStartWord(): " + bmStartWord());
    System.out.println("bmWordSize(): " + bmWordSize());
    System.out.println("shifter(): " + shifter());
  }
  
  public Address bmStartWord()
  {
    return bmStartWordField.getValue(addr);
  }
  
  public long bmWordSize()
  {
    return bmWordSizeField.getValue(addr);
  }
  
  public long shifter()
  {
    return shifterField.getValue(addr);
  }
  
  public VirtualSpace virtualSpace()
  {
    return (VirtualSpace)VMObjectFactory.newObject(VirtualSpace.class, addr.addOffsetTo(virtualSpaceFieldOffset));
  }
  
  public BitMap bm()
  {
    BitMap bitMap = new BitMap((int)(bmWordSize() >> (int)shifter()));
    VirtualSpace vs = virtualSpace();
    bitMap.set_map(vs.low());
    return bitMap;
  }
  
  public Address getNextMarkedWordAddress(Address addr)
  {
    Address endWord = bmStartWord().addOffsetTo(bmWordSize());
    int nextOffset = bm().getNextOneOffset(heapWordToOffset(addr), heapWordToOffset(endWord));
    Address nextAddr = offsetToHeapWord(nextOffset);
    return nextAddr;
  }
  
  int heapWordToOffset(Address addr)
  {
    int temp = (int)addr.minus(bmStartWord()) / (int)VM.getVM().getAddressSize();
    int ret_val = temp >> (int)shifter();
    return ret_val;
  }
  
  Address offsetToHeapWord(int offset)
  {
    int temp = offset << (int)shifter();
    return bmStartWord().addOffsetTo(temp * VM.getVM().getAddressSize());
  }
  
  boolean isMarked(Address addr)
  {
    BitMap bm = bm();
    return bm.at(heapWordToOffset(addr));
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.types.Field;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class CMSCollector
  extends VMObject
{
  private static long markBitMapFieldOffset;
  
  public CMSCollector(Address addr)
  {
    super(addr);
  }
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CMSCollector.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("CMSCollector");
    markBitMapFieldOffset = type.getField("_markBitMap").getOffset();
  }
  
  public CMSBitMap markBitMap()
  {
    return (CMSBitMap)VMObjectFactory.newObject(CMSBitMap.class, addr.addOffsetTo(markBitMapFieldOffset));
  }
  
  public long blockSizeUsingPrintezisBits(Address addr)
  {
    CMSBitMap markBitMap = markBitMap();
    long addressSize = VM.getVM().getAddressSize();
    if ((markBitMap.isMarked(addr)) && (markBitMap.isMarked(addr.addOffsetTo(1L * addressSize))))
    {
      System.err.println("Printezis bits are set...");
      Address nextOneAddr = markBitMap.getNextMarkedWordAddress(addr.addOffsetTo(2L * addressSize));
      
      long size = nextOneAddr.addOffsetTo(1L * addressSize).minus(addr);
      return size;
    }
    System.err.println("Missing Printszis marks...");
    return -1L;
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

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

public class CMSPermGen
  extends PermGen
{
  private static AddressField genField;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CMSPermGen.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("CMSPermGen");
    genField = type.getAddressField("_gen");
  }
  
  public CMSPermGen(Address addr)
  {
    super(addr);
  }
  
  public Generation asGen()
  {
    return GenerationFactory.newObject(genField.getValue(addr));
  }
}

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

import sun.jvm.hotspot.debugger.Address;

public class CMSPermGenGen
  extends ConcurrentMarkSweepGeneration
{
  public CMSPermGenGen(Address addr)
  {
    super(addr);
  }
  
  public String name()
  {
    return "concurrent-mark-sweep perm gen";
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.runtime.VirtualSpace;
import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.Field;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class CodeHeap
  extends VMObject
{
  private static Field memoryField;
  private static Field segmapField;
  private static CIntegerField log2SegmentSizeField;
  private VirtualSpace memory;
  private VirtualSpace segmentMap;
  private int log2SegmentSize;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CodeHeap.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("CodeHeap");
    
    memoryField = type.getField("_memory");
    segmapField = type.getField("_segmap");
    log2SegmentSizeField = type.getCIntegerField("_log2_segment_size");
  }
  
  public CodeHeap(Address addr)
  {
    super(addr);
    log2SegmentSize = ((int)log2SegmentSizeField.getValue(addr));
    segmentMap = new VirtualSpace(addr.addOffsetTo(segmapField.getOffset()));
    memory = new VirtualSpace(addr.addOffsetTo(memoryField.getOffset()));
  }
  
  public Address begin()
  {
    return getMemory().low();
  }
  
  public Address end()
  {
    return getMemory().high();
  }
  
  public boolean contains(Address p)
  {
    return (begin().lessThanOrEqual(p)) && (end().greaterThan(p));
  }
  
  public Address findStart(Address p)
  {
    if (!contains(p)) {
      return null;
    }
    HeapBlock h = blockStart(p);
    if ((h == null) || (h.isFree())) {
      return null;
    }
    return h.getAllocatedSpace();
  }
  
  public Address nextBlock(Address ptr)
  {
    Address base = blockBase(ptr);
    if (base == null) {
      return null;
    }
    HeapBlock block = getBlockAt(base);
    return base.addOffsetTo(block.getLength() * (1 << getLog2SegmentSize()));
  }
  
  private VirtualSpace getMemory()
  {
    return memory;
  }
  
  private VirtualSpace getSegmentMap()
  {
    return segmentMap;
  }
  
  private long segmentFor(Address p)
  {
    return p.minus(getMemory().low()) >> getLog2SegmentSize();
  }
  
  private int getLog2SegmentSize()
  {
    return log2SegmentSize;
  }
  
  private HeapBlock getBlockAt(Address addr)
  {
    return (HeapBlock)VMObjectFactory.newObject(HeapBlock.class, addr);
  }
  
  private HeapBlock blockStart(Address p)
  {
    Address base = blockBase(p);
    if (base == null) {
      return null;
    }
    return getBlockAt(base);
  }
  
  private Address blockBase(Address p)
  {
    long i = segmentFor(p);
    Address b = getSegmentMap().low();
    if (b.getCIntegerAt(i, 1L, true) == 255L) {
      return null;
    }
    while (b.getCIntegerAt(i, 1L, true) > 0L) {
      i -= b.getCIntegerAt(i, 1L, true);
    }
    return getMemory().low().addOffsetTo(i << getLog2SegmentSize());
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.Debugger;
import sun.jvm.hotspot.oops.ObjectHeap;
import sun.jvm.hotspot.oops.Oop;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.types.AddressField;
import sun.jvm.hotspot.types.Field;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;
import sun.jvm.hotspot.utilities.Assert;

public class CompactibleFreeListSpace
  extends CompactibleSpace
{
  private static AddressField collectorField;
  private static AddressField indexedFreeListField;
  private static AddressField dictionaryField;
  private static long smallLinearAllocBlockFieldOffset;
  private static long indexedFreeListSizeOf;
  private int heapWordSize;
  private int IndexSetStart;
  private int IndexSetSize;
  private int IndexSetStride;
  private static long MinChunkSizeInBytes;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CompactibleFreeListSpace.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    long sizeofFreeChunk = db.lookupType("FreeChunk").getSize();
    VM vm = VM.getVM();
    MinChunkSizeInBytes = numQuanta(sizeofFreeChunk, vm.getMinObjAlignmentInBytes()) * vm.getMinObjAlignmentInBytes();
    
    Type type = db.lookupType("CompactibleFreeListSpace");
    collectorField = type.getAddressField("_collector");
    collectorField = type.getAddressField("_collector");
    dictionaryField = type.getAddressField("_dictionary");
    indexedFreeListField = type.getAddressField("_indexedFreeList[0]");
    smallLinearAllocBlockFieldOffset = type.getField("_smallLinearAllocBlock").getOffset();
  }
  
  public CompactibleFreeListSpace(Address addr)
  {
    super(addr);
    VM vm = VM.getVM();
    heapWordSize = vm.getHeapWordSize();
    IndexSetStart = (vm.getMinObjAlignmentInBytes() / heapWordSize);
    IndexSetStride = IndexSetStart;
    IndexSetSize = 257;
  }
  
  public CMSCollector collector()
  {
    return (CMSCollector)VMObjectFactory.newObject(CMSCollector.class, collectorField.getValue(addr));
  }
  
  public long free0()
  {
    return capacity() - used0();
  }
  
  public long used()
  {
    return capacity() - free();
  }
  
  public long used0()
  {
    List regions = getLiveRegions();
    long usedSize = 0L;
    for (Iterator itr = regions.iterator(); itr.hasNext();)
    {
      MemRegion mr = (MemRegion)itr.next();
      usedSize += mr.byteSize();
    }
    return usedSize;
  }
  
  public long free()
  {
    long size = 0L;
    Address cur = addr.addOffsetTo(indexedFreeListField.getOffset());
    cur = cur.addOffsetTo(IndexSetStart * FreeList.sizeOf());
    for (int i = IndexSetStart; i < IndexSetSize; i += IndexSetStride)
    {
      FreeList freeList = (FreeList)VMObjectFactory.newObject(FreeList.class, cur);
      size += i * freeList.count();
      cur = cur.addOffsetTo(IndexSetStride * FreeList.sizeOf());
    }
    BinaryTreeDictionary bfbd = (BinaryTreeDictionary)VMObjectFactory.newObject(BinaryTreeDictionary.class, dictionaryField.getValue(addr));
    
    size += bfbd.size();
    
    LinearAllocBlock lab = (LinearAllocBlock)VMObjectFactory.newObject(LinearAllocBlock.class, addr.addOffsetTo(smallLinearAllocBlockFieldOffset));
    
    size += lab.word_size();
    
    return size * heapWordSize;
  }
  
  public void printOn(PrintStream tty)
  {
    tty.print("free-list-space");
    tty.print("[ " + bottom() + " , " + end() + " ) ");
    long cap = capacity();
    long used_size = used();
    long free_size = free();
    int used_perc = (int)(used_size / cap * 100.0D);
    tty.print("space capacity = " + cap + " used(" + used_perc + "%)= " + used_size + " ");
    tty.print("free= " + free_size);
    tty.print("\n");
  }
  
  public Address skipBlockSizeUsingPrintezisBits(Address pos)
  {
    CMSCollector collector = collector();
    long size = 0L;
    Address addr = null;
    if (collector != null)
    {
      size = collector.blockSizeUsingPrintezisBits(pos);
      if (size >= 3L) {
        addr = pos.addOffsetTo(adjustObjectSizeInBytes(size));
      }
    }
    return addr;
  }
  
  public List getLiveRegions()
  {
    List res = new ArrayList();
    VM vm = VM.getVM();
    Debugger dbg = vm.getDebugger();
    ObjectHeap heap = vm.getObjectHeap();
    Address cur = bottom();
    Address regionStart = cur;
    Address limit = end();
    long addressSize = vm.getAddressSize();
    while (cur.lessThan(limit))
    {
      Address klassOop = cur.getAddressAt(addressSize);
      if (FreeChunk.indicatesFreeChunk(cur))
      {
        if (!cur.equals(regionStart)) {
          res.add(new MemRegion(regionStart, cur));
        }
        FreeChunk fc = (FreeChunk)VMObjectFactory.newObject(FreeChunk.class, cur);
        long chunkSize = fc.size();
        if (Assert.ASSERTS_ENABLED) {
          Assert.that(chunkSize > 0L, "invalid FreeChunk size");
        }
        cur = cur.addOffsetTo(chunkSize * addressSize);
        regionStart = cur;
      }
      else if (klassOop != null)
      {
        Oop obj = heap.newOop(cur.addOffsetToAsOopHandle(0L));
        long objectSize = obj.getObjectSize();
        cur = cur.addOffsetTo(adjustObjectSizeInBytes(objectSize));
      }
      else
      {
        long size = collector().blockSizeUsingPrintezisBits(cur);
        if (size == -1L)
        {
          System.err.println("Printezis bits not set...");
          break;
        }
        cur = cur.addOffsetTo(adjustObjectSizeInBytes(size));
      }
    }
    return res;
  }
  
  private static long numQuanta(long x, long y)
  {
    return (x + y - 1L) / y;
  }
  
  public static long adjustObjectSizeInBytes(long sizeInBytes)
  {
    return Oop.alignObjectSize(Math.max(sizeInBytes, MinChunkSizeInBytes));
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

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

public abstract class CompactibleSpace
  extends Space
{
  private static AddressField compactionTopField;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CompactibleSpace.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("CompactibleSpace");
    
    compactionTopField = type.getAddressField("_compaction_top");
  }
  
  public CompactibleSpace(Address addr)
  {
    super(addr);
  }
  
  public Address compactionTop()
  {
    return compactionTopField.getValue(addr);
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

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

public class CompactingPermGen
  extends PermGen
{
  private static AddressField genField;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CompactingPermGen.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("CompactingPermGen");
    
    genField = type.getAddressField("_gen");
  }
  
  public CompactingPermGen(Address addr)
  {
    super(addr);
  }
  
  public Generation asGen()
  {
    return GenerationFactory.newObject(genField.getValue(addr));
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.types.AddressField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class CompactingPermGenGen
  extends OneContigSpaceCardGeneration
{
  private static AddressField unsharedBottomField;
  private static AddressField unsharedEndField;
  private static AddressField sharedBottomField;
  private static AddressField sharedEndField;
  private static AddressField readOnlyBottomField;
  private static AddressField readOnlyEndField;
  private static AddressField readWriteBottomField;
  private static AddressField readWriteEndField;
  private static AddressField roSpaceField;
  private static AddressField rwSpaceField;
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        CompactingPermGenGen.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("CompactingPermGenGen");
    unsharedBottomField = type.getAddressField("unshared_bottom");
    unsharedEndField = type.getAddressField("unshared_end");
    sharedBottomField = type.getAddressField("shared_bottom");
    sharedEndField = type.getAddressField("shared_end");
    readOnlyBottomField = type.getAddressField("readonly_bottom");
    readOnlyEndField = type.getAddressField("readonly_end");
    readWriteBottomField = type.getAddressField("readwrite_bottom");
    readWriteEndField = type.getAddressField("readwrite_end");
    roSpaceField = type.getAddressField("_ro_space");
    rwSpaceField = type.getAddressField("_rw_space");
  }
  
  public boolean isSharingEnabled()
  {
    return VM.getVM().isSharingEnabled();
  }
  
  public CompactingPermGenGen(Address addr)
  {
    super(addr);
  }
  
  public OffsetTableContigSpace roSpace()
  {
    return newOffsetTableContigSpace(roSpaceField.getValue(addr));
  }
  
  public OffsetTableContigSpace rwSpace()
  {
    return newOffsetTableContigSpace(rwSpaceField.getValue(addr));
  }
  
  public String name()
  {
    return "compacting permanent generation";
  }
  
  public static Address unsharedBottom()
  {
    return unsharedBottomField.getValue();
  }
  
  public static Address unsharedEnd()
  {
    return unsharedEndField.getValue();
  }
  
  public static Address sharedBottom()
  {
    return sharedBottomField.getValue();
  }
  
  public static Address sharedEnd()
  {
    return sharedEndField.getValue();
  }
  
  public static Address readOnlyBottom()
  {
    return readOnlyBottomField.getValue();
  }
  
  public static Address readOnlyEnd()
  {
    return readOnlyEndField.getValue();
  }
  
  public static Address readWriteBottom()
  {
    return readWriteBottomField.getValue();
  }
  
  public static Address readWriteEnd()
  {
    return readWriteEndField.getValue();
  }
  
  public static boolean isShared(Address p)
  {
    return (sharedBottom().lessThanOrEqual(p)) && (sharedEnd().greaterThan(p));
  }
  
  public static boolean isSharedReadOnly(Address p)
  {
    return (readOnlyBottom().lessThanOrEqual(p)) && (readOnlyEnd().greaterThan(p));
  }
  
  public static boolean isSharedReadWrite(Address p)
  {
    return (readWriteBottom().lessThanOrEqual(p)) && (readWriteEnd().greaterThan(p));
  }
  
  public boolean isIn(Address p)
  {
    return (unsharedBottom().lessThanOrEqual(p)) && (sharedEnd().greaterThan(p));
  }
  
  public void spaceIterate(SpaceClosure blk, boolean usedOnly)
  {
    super.spaceIterate(blk, usedOnly);
    if (isSharingEnabled())
    {
      blk.doSpace(roSpace());
      blk.doSpace(rwSpace());
    }
  }
  
  public void printOn(PrintStream tty)
  {
    tty.print("  perm");
    theSpace().printOn(tty);
    if (isSharingEnabled())
    {
      tty.print("  ro space: ");
      roSpace().printOn(tty);
      tty.print(", rw space: ");
      rwSpace().printOn(tty);
    }
  }
  
  private OffsetTableContigSpace newOffsetTableContigSpace(Address addr)
  {
    return (OffsetTableContigSpace)VMObjectFactory.newObject(OffsetTableContigSpace.class, addr);
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

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

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

import java.io.PrintStream;
import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.types.AddressField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class ConcurrentMarkSweepGeneration
  extends CardGeneration
{
  private static AddressField cmsSpaceField;
  
  public ConcurrentMarkSweepGeneration(Address addr)
  {
    super(addr);
  }
  
  static
  {
    VM.registerVMInitializedObserver(new Observer()
    {
      public void update(Observable o, Object data)
      {
        ConcurrentMarkSweepGeneration.initialize(VM.getVM().getTypeDataBase());
      }
    });
  }
  
  private static synchronized void initialize(TypeDataBase db)
  {
    Type type = db.lookupType("ConcurrentMarkSweepGeneration");
    cmsSpaceField = type.getAddressField("_cmsSpace");
  }
  
  public CompactibleFreeListSpace cmsSpace()
  {
    return (CompactibleFreeListSpace)VMObjectFactory.newObject(CompactibleFreeListSpace.class, cmsSpaceField.getValue(addr));
  }
  
  public long capacity()
  {
    return cmsSpace().capacity();
  }
  
  public long used()
  {
    return cmsSpace().used();
  }
  
  public long free()
  {
    return cmsSpace().free();
  }
  
  public long contiguousAvailable()
  {
    throw new RuntimeException("not yet implemented");
  }
  
  public boolean contains(Address p)
  {
    return cmsSpace().contains(p);
  }
  
  public void spaceIterate(SpaceClosure blk, boolean usedOnly)
  {
    blk.doSpace(cmsSpace());
  }
  
  public Generation.Name kind()
  {
    return Generation.Name.CONCURRENT_MARK_SWEEP;
  }
  
  public String name()
  {
    return "concurrent mark-sweep generation";
  }
  
  public void printOn(PrintStream tty)
  {
    tty.println(name());
    cmsSpace().printOn(tty);
  }
}

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

import sun.jvm.hotspot.debugger.Address;

public class ContigPermSpace
  extends OffsetTableContigSpace
{
  public ContigPermSpace(Address addr)
  {
    super(addr);
  }
}

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

import java.util.Observable;
import java.util.Observer;
import sun.jvm.hotspot.runtime.VM;

final class ContiguousSpace$1
  implements Observer
{
  public void update(Observable o, Object data)
  {
    ContiguousSpac
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