Java Code Examples for sun.jvm.hotspot.utilities.Assert#that()

The following examples show how to use sun.jvm.hotspot.utilities.Assert#that() . 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: BasicCDebugInfoDataBase.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Supports lazy instantiation and references between types and
    symbols via insertion using arbitrary Object keys that are
    wrapped by LazyTypes. Once the database has been fully
    constructed and all types are present, one should call
    resolveTypes(), which will resolve all LazyTypes down to
    concrete types (and signal an error if some lazy types were
    unresolved). */
public void beginConstruction() {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == INITIALIZED_STATE, "wrong state");
  }
  state   = CONSTRUCTION_STATE;

  // Types
  lazyTypeMap  = new HashMap();
  types        = new ArrayList();

  // Symbols
  lazySymMap   = new HashMap();
  blocks       = new ArrayList();
  nameToSymMap = new HashMap();

  // Line numbers
  lineNumbers  = new BasicLineNumberMapping();
}
 
Example 3
Source File: BasicCDebugInfoDataBase.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** Supports lazy instantiation and references between types and
    symbols via insertion using arbitrary Object keys that are
    wrapped by LazyTypes. Once the database has been fully
    constructed and all types are present, one should call
    resolveTypes(), which will resolve all LazyTypes down to
    concrete types (and signal an error if some lazy types were
    unresolved). */
public void beginConstruction() {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == INITIALIZED_STATE, "wrong state");
  }
  state   = CONSTRUCTION_STATE;

  // Types
  lazyTypeMap  = new HashMap();
  types        = new ArrayList();

  // Symbols
  lazySymMap   = new HashMap();
  blocks       = new ArrayList();
  nameToSymMap = new HashMap();

  // Line numbers
  lineNumbers  = new BasicLineNumberMapping();
}
 
Example 4
Source File: Method.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** Fetch the original non-breakpoint bytecode at the specified
    bci. It is required that there is currently a bytecode at this
    bci. */
public int getOrigBytecodeAt(int bci) {
  BreakpointInfo bp = getMethodHolder().getBreakpoints();
  for (; bp != null; bp = bp.getNext()) {
    if (bp.match(this, bci)) {
      return bp.getOrigBytecode();
    }
  }
  System.err.println("Requested bci " + bci);
  for (; bp != null; bp = bp.getNext()) {
    System.err.println("Breakpoint at bci " + bp.getBCI() + ", bytecode " +
                       bp.getOrigBytecode());
  }
  Assert.that(false, "Should not reach here");
  return -1; // not reached
}
 
Example 5
Source File: StackFrameImpl.java    From jdk8u60 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 6
Source File: BasicCDebugInfoDataBase.java    From openjdk-jdk8u 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 7
Source File: BasicCDebugInfoDataBase.java    From TencentKona-8 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 8
Source File: BasicCDebugInfoDataBase.java    From TencentKona-8 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 9
Source File: BasicCDebugInfoDataBase.java    From TencentKona-8 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 10
Source File: BasicCDebugInfoDataBase.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void iterate(TypeVisitor v) {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == COMPLETE_STATE, "wrong state");
  }
  for (Iterator iter = types.iterator(); iter.hasNext(); ) {
    BasicType t = (BasicType) iter.next();
    t.visit(v);
  }
}
 
Example 11
Source File: BasicCDebugInfoDataBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void iterate(TypeVisitor v) {
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(state == COMPLETE_STATE, "wrong state");
  }
  for (Iterator iter = types.iterator(); iter.hasNext(); ) {
    BasicType t = (BasicType) iter.next();
    t.visit(v);
  }
}
 
Example 12
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 13
Source File: BasicCompoundType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private BasicCompoundType(String name, int size, CompoundTypeKind kind, int cvAttributes) {
  super(name, size, cvAttributes);
  if (Assert.ASSERTS_ENABLED) {
    Assert.that(kind != null, "null kind");
  }
  this.kind = kind;
}
 
Example 14
Source File: COFFFileParser.java    From jdk8u60 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 15
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 16
Source File: BasicEnumType.java    From jdk8u60 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 enum type");
  if (Assert.ASSERTS_ENABLED) {
    BasicType b = (BasicType) underlyingType;
    Assert.that(b.isLazy() || b.isInt(),
                "Underlying type of enum must be integer type (or unresolved due to error)");
  }
  return this;
}
 
Example 17
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 18
Source File: VirtualMachineImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void notifyDispose() {
    if (Assert.ASSERTS_ENABLED) {
        Assert.that(disposeObserver != null, "null VM.dispose observer");
    }
    disposeObserver.update(null, null);
}
 
Example 19
Source File: ObjectReferenceImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void computeMonitorInfo() {
    monitorInfoCached = true;
    Mark mark = saObject.getMark();
    ObjectMonitor mon = null;
    Address owner = null;
    // check for heavyweight monitor
    if (! mark.hasMonitor()) {
        // check for lightweight monitor
        if (mark.hasLocker()) {
            owner = mark.locker().getAddress(); // save the address of the Lock word
        }
        // implied else: no owner
    } else {
        // this object has a heavyweight monitor
        mon = mark.monitor();

        // The owner field of a heavyweight monitor may be NULL for no
        // owner, a JavaThread * or it may still be the address of the
        // Lock word in a JavaThread's stack. A monitor can be inflated
        // by a non-owning JavaThread, but only the owning JavaThread
        // can change the owner field from the Lock word to the
        // JavaThread * and it may not have done that yet.
        owner = mon.owner();
    }

    // find the owning thread
    if (owner != null) {
        owningThread = vm.threadMirror(owningThreadFromMonitor(owner));
    }

    // compute entryCount
    if (owningThread != null) {
        if (owningThread.getJavaThread().getAddress().equals(owner)) {
            // the owner field is the JavaThread *
            if (Assert.ASSERTS_ENABLED) {
                Assert.that(false, "must have heavyweight monitor with JavaThread * owner");
            }
            entryCount = (int) mark.monitor().recursions() + 1;
        } else {
            // The owner field is the Lock word on the JavaThread's stack
            // so the recursions field is not valid. We have to count the
            // number of recursive monitor entries the hard way.
            entryCount = countLockedObjects(owningThread.getJavaThread(), saObject);
        }
    }

    // find the contenders & waiters
    waitingThreads = new ArrayList();
    if (mon != null) {
        // this object has a heavyweight monitor. threads could
        // be contenders or waiters
        // add all contenders
        List pendingThreads = getPendingThreads(mon);
        // convert the JavaThreads to ThreadReferenceImpls
        for (Iterator itrPend = pendingThreads.iterator(); itrPend.hasNext();) {
            waitingThreads.add(vm.threadMirror((JavaThread) itrPend.next()));
        }

        // add all waiters (threads in Object.wait())
        // note that we don't do this JVMTI way. To do it JVMTI way,
        // we would need to access ObjectWaiter list maintained in
        // ObjectMonitor::_queue. But we don't have this struct exposed
        // in vmStructs. We do waiters list in a way similar to getting
        // pending threads list
        List objWaitingThreads = getWaitingThreads(mon);
        // convert the JavaThreads to ThreadReferenceImpls
        for (Iterator itrWait = objWaitingThreads.iterator(); itrWait.hasNext();) {
            waitingThreads.add(vm.threadMirror((JavaThread) itrWait.next()));
        }
    }
}
 
Example 20
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;
    }