Java Code Examples for sun.jvm.hotspot.utilities.Assert#ASSERTS_ENABLED

The following examples show how to use sun.jvm.hotspot.utilities.Assert#ASSERTS_ENABLED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StackFrameImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ObjectReference thisObject() {
    validateStackFrame();
    MethodImpl currentMethod = (MethodImpl)location.method();
    if (currentMethod.isStatic() || currentMethod.isNative()) {
        return null;
    }
    if (thisObject == null) {
        StackValueCollection values = saFrame.getLocals();
        if (Assert.ASSERTS_ENABLED) {
            Assert.that(values.size() > 0, "this is missing");
        }
        // 'this' at index 0.
        if (values.get(0).getType() == BasicType.getTConflict()) {
          return null;
        }
        OopHandle handle = values.oopHandleAt(0);
        ObjectHeap heap = vm.saObjectHeap();
        thisObject = vm.objectMirror(heap.newOop(handle));
    }
    return thisObject;
}
 
Example 2
Source File: VirtualMachineImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static public VirtualMachineImpl createVirtualMachineForServer(VirtualMachineManager mgr,
                                                            String server,
                                                            int sequenceNumber)
    throws Exception {
    if (Assert.ASSERTS_ENABLED) {
        Assert.that(server != null, "SA VirtualMachineImpl: DebugServer = null is not yet implemented");
    }

    VirtualMachineImpl myvm = new VirtualMachineImpl(mgr, sequenceNumber);
    try {
        myvm.saAgent.attach(server);
        myvm.init();
    } catch (Exception ee) {
        myvm.saAgent.detach();
        throw ee;
    }
    return myvm;
}
 
Example 3
Source File: BasicCDebugInfoDataBase.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Intended only to be usd by the BasicSym implementation. */
public Sym resolveSym(Sym containingSymbol, Sym targetSym, ResolveListener listener, String detail) {
  if (targetSym == null) return null;
  BasicSym basicTargetSym = (BasicSym) targetSym;
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == CONSTRUCTION_STATE, "wrong state");
  }
  if (basicTargetSym.isLazy()) {
    BasicSym resolved = (BasicSym) lazySymMap.get(((LazyBlockSym) targetSym).getKey());
    // FIXME: would like to have an assert here that the target is
    // non-null, but apparently have bugs here
    if (resolved == null) {
      listener.resolveFailed(containingSymbol, (LazyBlockSym) targetSym, detail);
      return targetSym;
    }
    if (resolved.isLazy()) {
      listener.resolveFailed(containingSymbol, (LazyBlockSym) targetSym, detail);
    }
    return resolved;
  }
  return targetSym;
}
 
Example 4
Source File: VirtualMachineImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static public VirtualMachineImpl createVirtualMachineForCorefile(VirtualMachineManager mgr,
                                                                 String javaExecutableName,
                                                                 String coreFileName,
                                                                 int sequenceNumber)
    throws Exception {
    if (Assert.ASSERTS_ENABLED) {
        Assert.that(coreFileName != null, "SA VirtualMachineImpl: core filename = null is not yet implemented");
    }
    if (Assert.ASSERTS_ENABLED) {
        Assert.that(javaExecutableName != null, "SA VirtualMachineImpl: java executable = null is not yet implemented");
    }

    VirtualMachineImpl myvm = new VirtualMachineImpl(mgr, sequenceNumber);
    try {
        myvm.saAgent.attach(javaExecutableName, coreFileName);
        myvm.init();
    } catch (Exception ee) {
        myvm.saAgent.detach();
        throw ee;
    }
    return myvm;
}
 
Example 5
Source File: COFFFileParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public int getLGProcEndOffset() {
  symSeek(4);
  int offs = readInt();
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(offs != 0, "should not have null end offset for procedure symbols");
  }
  return base + offs;
}
 
Example 6
Source File: BasicCDebugInfoDataBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void endConstruction() {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == RESOLVED_STATE, "wrong state");
  }
  // Move all types to type list
  for (Iterator iter = lazyTypeMap.values().iterator(); iter.hasNext(); ) {
    types.add(iter.next());
  }
  // Build name-to-type map
  nameToTypeMap = new HashMap();
  for (Iterator iter = types.iterator(); iter.hasNext(); ) {
    Type t = (Type) iter.next();
    if (!t.isConst() && !t.isVolatile()) {
      nameToTypeMap.put(t.getName(), t);
    }
  }
  // Lose lazy maps
  lazyTypeMap = null;
  lazySymMap  = null;
  // Sort and finish line number information
  lineNumbers.sort();
  // FIXME: on some platforms it might not be necessary to call
  // recomputeEndPCs(). Will have to see what stabs information
  // looks like. Should make configurable whether we make this call
  // or not.
  lineNumbers.recomputeEndPCs();

  state = COMPLETE_STATE;
}
 
Example 7
Source File: COFFFileParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public int getBlockEndOffset() {
  symSeek(4);
  int offs = readInt();
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(offs != 0, "should not have null end offset for block symbols");
  }
  return base + offs;
}
 
Example 8
Source File: COFFFileParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public int getBlockEndOffset() {
  symSeek(4);
  int offs = readInt();
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(offs != 0, "should not have null end offset for block symbols");
  }
  return base + offs;
}
 
Example 9
Source File: BasicCDebugInfoDataBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void resolve(ResolveListener listener) {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == CONSTRUCTION_STATE, "wrong state");
  }
  // Go through all types in lazyTypeMap and types.
  // Resolve all LazyTypes.
  resolveLazyMap(listener);
  for (ListIterator iter = types.listIterator(); iter.hasNext(); ) {
    BasicType t = (BasicType) iter.next();
    BasicType t2 = (BasicType) t.resolveTypes(this, listener);
    if (t != t2) {
      iter.set(t2);
    }
  }
  // Go through all symbols and resolve references to types and
  // references to other symbols
  for (Iterator iter = blocks.iterator(); iter.hasNext(); ) {
    ((BasicSym) iter.next()).resolve(this, listener);
  }
  for (Iterator iter = nameToSymMap.values().iterator(); iter.hasNext(); ) {
    ((BasicSym) iter.next()).resolve(this, listener);
  }

  // Sort blocks in ascending order of starting address (but do not
  // change ordering among blocks with the same starting address)
  Collections.sort(blocks, new Comparator() {
      public int compare(Object o1, Object o2) {
        BlockSym b1 = (BlockSym) o1;
        BlockSym b2 = (BlockSym) o2;
        Address a1 = b1.getAddress();
        Address a2 = b2.getAddress();
        if (AddressOps.lt(a1, a2)) { return -1; }
        if (AddressOps.gt(a1, a2)) { return 1; }
        return 0;
      }
    });

  state = RESOLVED_STATE;
}
 
Example 10
Source File: BasicCDebugInfoDataBase.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Intended only to be usd by the BasicSym implementation. */
public Type resolveType(Sym containingSymbol, Type targetType, ResolveListener listener, String detail) {
  BasicType basicTargetType = (BasicType) targetType;
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == CONSTRUCTION_STATE, "wrong state");
  }
  if (basicTargetType.isLazy()) {
    BasicType resolved = (BasicType) lazyTypeMap.get(((LazyType) targetType).getKey());
    // FIXME: would like to have an assert here that the target is
    // non-null, but apparently have bugs here
    if (resolved == null) {
      listener.resolveFailed(containingSymbol, (LazyType) targetType, detail);
      return targetType;
    }
    if (resolved.isLazy()) {
      // Might happen for const/var variants for forward references
      if (resolved.isConst() || resolved.isVolatile()) {
        resolved = (BasicType) resolved.resolveTypes(this, listener);
      }
      if (resolved.isLazy()) {
        listener.resolveFailed(containingSymbol, (LazyType) targetType, detail);
      }
    }
    return resolved;
  }
  return targetType;
}
 
Example 11
Source File: BasicCDebugInfoDataBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Add a BlockSym to the debug information database. The given
    BlockSym may be referred to by a LazyBlockSym wrapping the given
    Object key, which must be non-null. Any references to other
    blocks (for example, the parent scope) should be made with
    LazyBlockSyms. These references will be resolved after the
    database is built. */
public void addBlock(Object key, BlockSym block) {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(key != null, "key must be non-null");
  }
  lazySymMap.put(key, block);
  blocks.add(block);
}
 
Example 12
Source File: BasicCDebugInfoDataBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Type lookupType(String name, int cvAttributes) {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == COMPLETE_STATE, "wrong state");
  }
  BasicType t = (BasicType) nameToTypeMap.get(name);
  if (t != null) {
    if (cvAttributes != 0) {
      t = (BasicType) t.getCVVariant(cvAttributes);
    }
  }
  return t;
}
 
Example 13
Source File: COFFFileParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void advanceToEntryThisSymbol() {
  seek(pos + 4);
  int tmpSymSize = readShort();
  int tmpSymType = readShort();
  if (Assert.ASSERTS_ENABLED) {
    // Make sure that ends of inner and outer symbols line
    // up, otherwise need more work
    Assert.that(pos + curSymSize + 2 == pos + 4 + tmpSymSize,
                "advanceToEntryThisSymbol needs more work");
  }
  pos += 4;
  curSymSize = tmpSymSize;
  curSymType = tmpSymType;
}
 
Example 14
Source File: COFFFileParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void advanceToEntryThisSymbol() {
  seek(pos + 4);
  int tmpSymSize = readShort();
  int tmpSymType = readShort();
  if (Assert.ASSERTS_ENABLED) {
    // Make sure that ends of inner and outer symbols line
    // up, otherwise need more work
    Assert.that(pos + curSymSize + 2 == pos + 4 + tmpSymSize,
                "advanceToEntryThisSymbol needs more work");
  }
  pos += 4;
  curSymSize = tmpSymSize;
  curSymType = tmpSymType;
}
 
Example 15
Source File: BasicCDebugInfoDataBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Add a BlockSym to the debug information database. The given
    BlockSym may be referred to by a LazyBlockSym wrapping the given
    Object key, which must be non-null. Any references to other
    blocks (for example, the parent scope) should be made with
    LazyBlockSyms. These references will be resolved after the
    database is built. */
public void addBlock(Object key, BlockSym block) {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(key != null, "key must be non-null");
  }
  lazySymMap.put(key, block);
  blocks.add(block);
}
 
Example 16
Source File: BasicBitType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
Type resolveTypes(BasicCDebugInfoDataBase db, ResolveListener listener) {
  super.resolveTypes(db, listener);
  underlyingType = db.resolveType(this, underlyingType, listener, "resolving bit type");
  setName(underlyingType.getName());
  if (Assert.ASSERTS_ENABLED) {
    BasicType b = (BasicType) underlyingType;
    Assert.that(b.isLazy() || b.isInt(),
                "Underlying type of bitfield must be integer type (or unresolved due to error)");
  }
  return this;
}
 
Example 17
Source File: BasicCDebugInfoDataBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Intended only to be usd by the BasicSym implementation. */
public Type resolveType(Sym containingSymbol, Type targetType, ResolveListener listener, String detail) {
  BasicType basicTargetType = (BasicType) targetType;
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == CONSTRUCTION_STATE, "wrong state");
  }
  if (basicTargetType.isLazy()) {
    BasicType resolved = (BasicType) lazyTypeMap.get(((LazyType) targetType).getKey());
    // FIXME: would like to have an assert here that the target is
    // non-null, but apparently have bugs here
    if (resolved == null) {
      listener.resolveFailed(containingSymbol, (LazyType) targetType, detail);
      return targetType;
    }
    if (resolved.isLazy()) {
      // Might happen for const/var variants for forward references
      if (resolved.isConst() || resolved.isVolatile()) {
        resolved = (BasicType) resolved.resolveTypes(this, listener);
      }
      if (resolved.isLazy()) {
        listener.resolveFailed(containingSymbol, (LazyType) targetType, detail);
      }
    }
    return resolved;
  }
  return targetType;
}
 
Example 18
Source File: BasicBitType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
Type resolveTypes(BasicCDebugInfoDataBase db, ResolveListener listener) {
  super.resolveTypes(db, listener);
  underlyingType = db.resolveType(this, underlyingType, listener, "resolving bit type");
  setName(underlyingType.getName());
  if (Assert.ASSERTS_ENABLED) {
    BasicType b = (BasicType) underlyingType;
    Assert.that(b.isLazy() || b.isInt(),
                "Underlying type of bitfield must be integer type (or unresolved due to error)");
  }
  return this;
}
 
Example 19
Source File: VirtualMachineImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }
 
Example 20
Source File: VirtualMachineImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
synchronized ObjectReferenceImpl objectMirror(Oop key) {

        // Handle any queue elements that are not strongly reachable
        processQueue();

        if (key == null) {
            return null;
        }
        ObjectReferenceImpl object = null;

        /*
         * Attempt to retrieve an existing object object reference
         */
        SoftObjectReference ref = (SoftObjectReference)objectsByID.get(key);
        if (ref != null) {
            object = ref.object();
        }

        /*
         * If the object wasn't in the table, or it's soft reference was
         * cleared, create a new instance.
         */
        if (object == null) {
            if (key instanceof Instance) {
                // look for well-known classes
                Symbol className = key.getKlass().getName();
                if (Assert.ASSERTS_ENABLED) {
                    Assert.that(className != null, "Null class name");
                }
                Instance inst = (Instance) key;
                if (className.equals(javaLangString)) {
                    object = new StringReferenceImpl(this, inst);
                } else if (className.equals(javaLangThread)) {
                    object = new ThreadReferenceImpl(this, inst);
                } else if (className.equals(javaLangThreadGroup)) {
                    object = new ThreadGroupReferenceImpl(this, inst);
                } else if (className.equals(javaLangClass)) {
                    object = new ClassObjectReferenceImpl(this, inst);
                } else if (className.equals(javaLangClassLoader)) {
                    object = new ClassLoaderReferenceImpl(this, inst);
                } else {
                    // not a well-known class. But the base class may be
                    // one of the known classes.
                    Klass kls = key.getKlass().getSuper();
                    while (kls != null) {
                       className = kls.getName();
                       // java.lang.Class and java.lang.String are final classes
                       if (className.equals(javaLangThread)) {
                          object = new ThreadReferenceImpl(this, inst);
                          break;
                       } else if(className.equals(javaLangThreadGroup)) {
                          object = new ThreadGroupReferenceImpl(this, inst);
                          break;
                       } else if (className.equals(javaLangClassLoader)) {
                          object = new ClassLoaderReferenceImpl(this, inst);
                          break;
                       }
                       kls = kls.getSuper();
                    }

                    if (object == null) {
                       // create generic object reference
                       object = new ObjectReferenceImpl(this, inst);
                    }
                }
            } else if (key instanceof TypeArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else if (key instanceof ObjArray) {
                object = new ArrayReferenceImpl(this, (Array) key);
            } else {
                throw new RuntimeException("unexpected object type " + key);
            }
            ref = new SoftObjectReference(key, object, referenceQueue);

            /*
             * If there was no previous entry in the table, we add one here
             * If the previous entry was cleared, we replace it here.
             */
            objectsByID.put(key, ref);
        } else {
            ref.incrementCount();
        }

        return object;
    }