sun.jvm.hotspot.oops.Array Java Examples

The following examples show how to use sun.jvm.hotspot.oops.Array. 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: ArrayReferenceImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Array aRef) {
    super(aVm, aRef);
    length = (int) aRef.getLength();
}
 
Example #2
Source File: VirtualMachineImpl.java    From openjdk-jdk8u-backup 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 #3
Source File: VirtualMachineImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl arrayMirror(Array id) {
   return (ArrayReferenceImpl) objectMirror(id);
}
 
Example #4
Source File: StackFrameImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private ValueImpl getSlotValue(StackValueCollection values,
                   BasicType variableType, int ss) {
    ValueImpl valueImpl = null;
    OopHandle handle = null;
    ObjectHeap heap = vm.saObjectHeap();
    if (values.get(ss).getType() == BasicType.getTConflict()) {
      // Dead locals, so just represent them as a zero of the appropriate type
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = null;
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = null;
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    } else {
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = values.oopHandleAt(ss);
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = values.oopHandleAt(ss);
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    }

    return valueImpl;
}
 
Example #5
Source File: ArrayReferenceImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Array aRef) {
    super(aVm, aRef);
    length = (int) aRef.getLength();
}
 
Example #6
Source File: ArrayReferenceImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public List getValues(int index, int len) {
    if (len == -1) { // -1 means the rest of the array
       len = length() - index;
    }
    validateArrayAccess(index, len);
    List vals = new ArrayList();
    if (len == 0) {
        return vals;
    }

    sun.jvm.hotspot.oops.TypeArray typeArray = null;
    sun.jvm.hotspot.oops.ObjArray objArray = null;
    if (ref() instanceof sun.jvm.hotspot.oops.TypeArray) {
        typeArray = (sun.jvm.hotspot.oops.TypeArray)ref();
    } else if (ref() instanceof sun.jvm.hotspot.oops.ObjArray) {
        objArray = (sun.jvm.hotspot.oops.ObjArray)ref();
    } else {
        throw new RuntimeException("should not reach here");
    }

    char c = arrayType().componentSignature().charAt(0);
    BasicType variableType = BasicType.charToBasicType(c);

    final int limit = index + len;
    for (int ii = index; ii < limit; ii++) {
        ValueImpl valueImpl;
        if (variableType == BasicType.T_BOOLEAN) {
            valueImpl = (BooleanValueImpl) vm.mirrorOf(typeArray.getBooleanAt(ii));
        } else if (variableType == BasicType.T_CHAR) {
            valueImpl = (CharValueImpl) vm.mirrorOf(typeArray.getCharAt(ii));
        } else if (variableType == BasicType.T_FLOAT) {
            valueImpl = (FloatValueImpl) vm.mirrorOf(typeArray.getFloatAt(ii));
        } else if (variableType == BasicType.T_DOUBLE) {
            valueImpl =  (DoubleValueImpl) vm.mirrorOf(typeArray.getDoubleAt(ii));
        } else if (variableType == BasicType.T_BYTE) {
            valueImpl =  (ByteValueImpl) vm.mirrorOf(typeArray.getByteAt(ii));
        } else if (variableType == BasicType.T_SHORT) {
            valueImpl =  (ShortValueImpl) vm.mirrorOf(typeArray.getShortAt(ii));
        } else if (variableType == BasicType.T_INT) {
            valueImpl =  (IntegerValueImpl) vm.mirrorOf(typeArray.getIntAt(ii));
        } else if (variableType == BasicType.T_LONG) {
            valueImpl =  (LongValueImpl) vm.mirrorOf(typeArray.getLongAt(ii));
        } else if (variableType == BasicType.T_OBJECT) {
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
            // elements themselves may be arrays because every array is an Object.
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(objArray.getObjAt(ii));
        } else if (variableType == BasicType.T_ARRAY) {
            valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array) objArray.getObjAt(ii));
        } else {
            throw new RuntimeException("should not reach here");
        }
        vals.add (valueImpl);
    }
    return vals;
}
 
Example #7
Source File: VirtualMachineImpl.java    From hottub 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 #8
Source File: VirtualMachineImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl arrayMirror(Array id) {
   return (ArrayReferenceImpl) objectMirror(id);
}
 
Example #9
Source File: StackFrameImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private ValueImpl getSlotValue(StackValueCollection values,
                   BasicType variableType, int ss) {
    ValueImpl valueImpl = null;
    OopHandle handle = null;
    ObjectHeap heap = vm.saObjectHeap();
    if (values.get(ss).getType() == BasicType.getTConflict()) {
      // Dead locals, so just represent them as a zero of the appropriate type
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = null;
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = null;
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    } else {
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = values.oopHandleAt(ss);
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = values.oopHandleAt(ss);
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    }

    return valueImpl;
}
 
Example #10
Source File: ArrayReferenceImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public List getValues(int index, int len) {
    if (len == -1) { // -1 means the rest of the array
       len = length() - index;
    }
    validateArrayAccess(index, len);
    List vals = new ArrayList();
    if (len == 0) {
        return vals;
    }

    sun.jvm.hotspot.oops.TypeArray typeArray = null;
    sun.jvm.hotspot.oops.ObjArray objArray = null;
    if (ref() instanceof sun.jvm.hotspot.oops.TypeArray) {
        typeArray = (sun.jvm.hotspot.oops.TypeArray)ref();
    } else if (ref() instanceof sun.jvm.hotspot.oops.ObjArray) {
        objArray = (sun.jvm.hotspot.oops.ObjArray)ref();
    } else {
        throw new RuntimeException("should not reach here");
    }

    char c = arrayType().componentSignature().charAt(0);
    BasicType variableType = BasicType.charToBasicType(c);

    final int limit = index + len;
    for (int ii = index; ii < limit; ii++) {
        ValueImpl valueImpl;
        if (variableType == BasicType.T_BOOLEAN) {
            valueImpl = (BooleanValueImpl) vm.mirrorOf(typeArray.getBooleanAt(ii));
        } else if (variableType == BasicType.T_CHAR) {
            valueImpl = (CharValueImpl) vm.mirrorOf(typeArray.getCharAt(ii));
        } else if (variableType == BasicType.T_FLOAT) {
            valueImpl = (FloatValueImpl) vm.mirrorOf(typeArray.getFloatAt(ii));
        } else if (variableType == BasicType.T_DOUBLE) {
            valueImpl =  (DoubleValueImpl) vm.mirrorOf(typeArray.getDoubleAt(ii));
        } else if (variableType == BasicType.T_BYTE) {
            valueImpl =  (ByteValueImpl) vm.mirrorOf(typeArray.getByteAt(ii));
        } else if (variableType == BasicType.T_SHORT) {
            valueImpl =  (ShortValueImpl) vm.mirrorOf(typeArray.getShortAt(ii));
        } else if (variableType == BasicType.T_INT) {
            valueImpl =  (IntegerValueImpl) vm.mirrorOf(typeArray.getIntAt(ii));
        } else if (variableType == BasicType.T_LONG) {
            valueImpl =  (LongValueImpl) vm.mirrorOf(typeArray.getLongAt(ii));
        } else if (variableType == BasicType.T_OBJECT) {
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
            // elements themselves may be arrays because every array is an Object.
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(objArray.getObjAt(ii));
        } else if (variableType == BasicType.T_ARRAY) {
            valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array) objArray.getObjAt(ii));
        } else {
            throw new RuntimeException("should not reach here");
        }
        vals.add (valueImpl);
    }
    return vals;
}
 
Example #11
Source File: ArrayReferenceImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public List getValues(int index, int len) {
    if (len == -1) { // -1 means the rest of the array
       len = length() - index;
    }
    validateArrayAccess(index, len);
    List vals = new ArrayList();
    if (len == 0) {
        return vals;
    }

    sun.jvm.hotspot.oops.TypeArray typeArray = null;
    sun.jvm.hotspot.oops.ObjArray objArray = null;
    if (ref() instanceof sun.jvm.hotspot.oops.TypeArray) {
        typeArray = (sun.jvm.hotspot.oops.TypeArray)ref();
    } else if (ref() instanceof sun.jvm.hotspot.oops.ObjArray) {
        objArray = (sun.jvm.hotspot.oops.ObjArray)ref();
    } else {
        throw new RuntimeException("should not reach here");
    }

    char c = arrayType().componentSignature().charAt(0);
    BasicType variableType = BasicType.charToBasicType(c);

    final int limit = index + len;
    for (int ii = index; ii < limit; ii++) {
        ValueImpl valueImpl;
        if (variableType == BasicType.T_BOOLEAN) {
            valueImpl = (BooleanValueImpl) vm.mirrorOf(typeArray.getBooleanAt(ii));
        } else if (variableType == BasicType.T_CHAR) {
            valueImpl = (CharValueImpl) vm.mirrorOf(typeArray.getCharAt(ii));
        } else if (variableType == BasicType.T_FLOAT) {
            valueImpl = (FloatValueImpl) vm.mirrorOf(typeArray.getFloatAt(ii));
        } else if (variableType == BasicType.T_DOUBLE) {
            valueImpl =  (DoubleValueImpl) vm.mirrorOf(typeArray.getDoubleAt(ii));
        } else if (variableType == BasicType.T_BYTE) {
            valueImpl =  (ByteValueImpl) vm.mirrorOf(typeArray.getByteAt(ii));
        } else if (variableType == BasicType.T_SHORT) {
            valueImpl =  (ShortValueImpl) vm.mirrorOf(typeArray.getShortAt(ii));
        } else if (variableType == BasicType.T_INT) {
            valueImpl =  (IntegerValueImpl) vm.mirrorOf(typeArray.getIntAt(ii));
        } else if (variableType == BasicType.T_LONG) {
            valueImpl =  (LongValueImpl) vm.mirrorOf(typeArray.getLongAt(ii));
        } else if (variableType == BasicType.T_OBJECT) {
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
            // elements themselves may be arrays because every array is an Object.
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(objArray.getObjAt(ii));
        } else if (variableType == BasicType.T_ARRAY) {
            valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array) objArray.getObjAt(ii));
        } else {
            throw new RuntimeException("should not reach here");
        }
        vals.add (valueImpl);
    }
    return vals;
}
 
Example #12
Source File: VirtualMachineImpl.java    From openjdk-8-source 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 #13
Source File: VirtualMachineImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl arrayMirror(Array id) {
   return (ArrayReferenceImpl) objectMirror(id);
}
 
Example #14
Source File: StackFrameImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private ValueImpl getSlotValue(StackValueCollection values,
                   BasicType variableType, int ss) {
    ValueImpl valueImpl = null;
    OopHandle handle = null;
    ObjectHeap heap = vm.saObjectHeap();
    if (values.get(ss).getType() == BasicType.getTConflict()) {
      // Dead locals, so just represent them as a zero of the appropriate type
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = null;
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = null;
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    } else {
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = values.oopHandleAt(ss);
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = values.oopHandleAt(ss);
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    }

    return valueImpl;
}
 
Example #15
Source File: ArrayReferenceImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Array aRef) {
    super(aVm, aRef);
    length = (int) aRef.getLength();
}
 
Example #16
Source File: ArrayReferenceImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public List getValues(int index, int len) {
    if (len == -1) { // -1 means the rest of the array
       len = length() - index;
    }
    validateArrayAccess(index, len);
    List vals = new ArrayList();
    if (len == 0) {
        return vals;
    }

    sun.jvm.hotspot.oops.TypeArray typeArray = null;
    sun.jvm.hotspot.oops.ObjArray objArray = null;
    if (ref() instanceof sun.jvm.hotspot.oops.TypeArray) {
        typeArray = (sun.jvm.hotspot.oops.TypeArray)ref();
    } else if (ref() instanceof sun.jvm.hotspot.oops.ObjArray) {
        objArray = (sun.jvm.hotspot.oops.ObjArray)ref();
    } else {
        throw new RuntimeException("should not reach here");
    }

    char c = arrayType().componentSignature().charAt(0);
    BasicType variableType = BasicType.charToBasicType(c);

    final int limit = index + len;
    for (int ii = index; ii < limit; ii++) {
        ValueImpl valueImpl;
        if (variableType == BasicType.T_BOOLEAN) {
            valueImpl = (BooleanValueImpl) vm.mirrorOf(typeArray.getBooleanAt(ii));
        } else if (variableType == BasicType.T_CHAR) {
            valueImpl = (CharValueImpl) vm.mirrorOf(typeArray.getCharAt(ii));
        } else if (variableType == BasicType.T_FLOAT) {
            valueImpl = (FloatValueImpl) vm.mirrorOf(typeArray.getFloatAt(ii));
        } else if (variableType == BasicType.T_DOUBLE) {
            valueImpl =  (DoubleValueImpl) vm.mirrorOf(typeArray.getDoubleAt(ii));
        } else if (variableType == BasicType.T_BYTE) {
            valueImpl =  (ByteValueImpl) vm.mirrorOf(typeArray.getByteAt(ii));
        } else if (variableType == BasicType.T_SHORT) {
            valueImpl =  (ShortValueImpl) vm.mirrorOf(typeArray.getShortAt(ii));
        } else if (variableType == BasicType.T_INT) {
            valueImpl =  (IntegerValueImpl) vm.mirrorOf(typeArray.getIntAt(ii));
        } else if (variableType == BasicType.T_LONG) {
            valueImpl =  (LongValueImpl) vm.mirrorOf(typeArray.getLongAt(ii));
        } else if (variableType == BasicType.T_OBJECT) {
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
            // elements themselves may be arrays because every array is an Object.
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(objArray.getObjAt(ii));
        } else if (variableType == BasicType.T_ARRAY) {
            valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array) objArray.getObjAt(ii));
        } else {
            throw new RuntimeException("should not reach here");
        }
        vals.add (valueImpl);
    }
    return vals;
}
 
Example #17
Source File: VirtualMachineImpl.java    From openjdk-8 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 #18
Source File: VirtualMachineImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl arrayMirror(Array id) {
   return (ArrayReferenceImpl) objectMirror(id);
}
 
Example #19
Source File: VirtualMachineImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl arrayMirror(Array id) {
   return (ArrayReferenceImpl) objectMirror(id);
}
 
Example #20
Source File: ArrayReferenceImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Array aRef) {
    super(aVm, aRef);
    length = (int) aRef.getLength();
}
 
Example #21
Source File: ArrayReferenceImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public List getValues(int index, int len) {
    if (len == -1) { // -1 means the rest of the array
       len = length() - index;
    }
    validateArrayAccess(index, len);
    List vals = new ArrayList();
    if (len == 0) {
        return vals;
    }

    sun.jvm.hotspot.oops.TypeArray typeArray = null;
    sun.jvm.hotspot.oops.ObjArray objArray = null;
    if (ref() instanceof sun.jvm.hotspot.oops.TypeArray) {
        typeArray = (sun.jvm.hotspot.oops.TypeArray)ref();
    } else if (ref() instanceof sun.jvm.hotspot.oops.ObjArray) {
        objArray = (sun.jvm.hotspot.oops.ObjArray)ref();
    } else {
        throw new RuntimeException("should not reach here");
    }

    char c = arrayType().componentSignature().charAt(0);
    BasicType variableType = BasicType.charToBasicType(c);

    final int limit = index + len;
    for (int ii = index; ii < limit; ii++) {
        ValueImpl valueImpl;
        if (variableType == BasicType.T_BOOLEAN) {
            valueImpl = (BooleanValueImpl) vm.mirrorOf(typeArray.getBooleanAt(ii));
        } else if (variableType == BasicType.T_CHAR) {
            valueImpl = (CharValueImpl) vm.mirrorOf(typeArray.getCharAt(ii));
        } else if (variableType == BasicType.T_FLOAT) {
            valueImpl = (FloatValueImpl) vm.mirrorOf(typeArray.getFloatAt(ii));
        } else if (variableType == BasicType.T_DOUBLE) {
            valueImpl =  (DoubleValueImpl) vm.mirrorOf(typeArray.getDoubleAt(ii));
        } else if (variableType == BasicType.T_BYTE) {
            valueImpl =  (ByteValueImpl) vm.mirrorOf(typeArray.getByteAt(ii));
        } else if (variableType == BasicType.T_SHORT) {
            valueImpl =  (ShortValueImpl) vm.mirrorOf(typeArray.getShortAt(ii));
        } else if (variableType == BasicType.T_INT) {
            valueImpl =  (IntegerValueImpl) vm.mirrorOf(typeArray.getIntAt(ii));
        } else if (variableType == BasicType.T_LONG) {
            valueImpl =  (LongValueImpl) vm.mirrorOf(typeArray.getLongAt(ii));
        } else if (variableType == BasicType.T_OBJECT) {
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
            // elements themselves may be arrays because every array is an Object.
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(objArray.getObjAt(ii));
        } else if (variableType == BasicType.T_ARRAY) {
            valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array) objArray.getObjAt(ii));
        } else {
            throw new RuntimeException("should not reach here");
        }
        vals.add (valueImpl);
    }
    return vals;
}
 
Example #22
Source File: VirtualMachineImpl.java    From TencentKona-8 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 #23
Source File: VirtualMachineImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl arrayMirror(Array id) {
   return (ArrayReferenceImpl) objectMirror(id);
}
 
Example #24
Source File: StackFrameImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private ValueImpl getSlotValue(StackValueCollection values,
                   BasicType variableType, int ss) {
    ValueImpl valueImpl = null;
    OopHandle handle = null;
    ObjectHeap heap = vm.saObjectHeap();
    if (values.get(ss).getType() == BasicType.getTConflict()) {
      // Dead locals, so just represent them as a zero of the appropriate type
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = null;
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = null;
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    } else {
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = values.oopHandleAt(ss);
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = values.oopHandleAt(ss);
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    }

    return valueImpl;
}
 
Example #25
Source File: ArrayReferenceImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Array aRef) {
    super(aVm, aRef);
    length = (int) aRef.getLength();
}
 
Example #26
Source File: ArrayReferenceImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public List getValues(int index, int len) {
    if (len == -1) { // -1 means the rest of the array
       len = length() - index;
    }
    validateArrayAccess(index, len);
    List vals = new ArrayList();
    if (len == 0) {
        return vals;
    }

    sun.jvm.hotspot.oops.TypeArray typeArray = null;
    sun.jvm.hotspot.oops.ObjArray objArray = null;
    if (ref() instanceof sun.jvm.hotspot.oops.TypeArray) {
        typeArray = (sun.jvm.hotspot.oops.TypeArray)ref();
    } else if (ref() instanceof sun.jvm.hotspot.oops.ObjArray) {
        objArray = (sun.jvm.hotspot.oops.ObjArray)ref();
    } else {
        throw new RuntimeException("should not reach here");
    }

    char c = arrayType().componentSignature().charAt(0);
    BasicType variableType = BasicType.charToBasicType(c);

    final int limit = index + len;
    for (int ii = index; ii < limit; ii++) {
        ValueImpl valueImpl;
        if (variableType == BasicType.T_BOOLEAN) {
            valueImpl = (BooleanValueImpl) vm.mirrorOf(typeArray.getBooleanAt(ii));
        } else if (variableType == BasicType.T_CHAR) {
            valueImpl = (CharValueImpl) vm.mirrorOf(typeArray.getCharAt(ii));
        } else if (variableType == BasicType.T_FLOAT) {
            valueImpl = (FloatValueImpl) vm.mirrorOf(typeArray.getFloatAt(ii));
        } else if (variableType == BasicType.T_DOUBLE) {
            valueImpl =  (DoubleValueImpl) vm.mirrorOf(typeArray.getDoubleAt(ii));
        } else if (variableType == BasicType.T_BYTE) {
            valueImpl =  (ByteValueImpl) vm.mirrorOf(typeArray.getByteAt(ii));
        } else if (variableType == BasicType.T_SHORT) {
            valueImpl =  (ShortValueImpl) vm.mirrorOf(typeArray.getShortAt(ii));
        } else if (variableType == BasicType.T_INT) {
            valueImpl =  (IntegerValueImpl) vm.mirrorOf(typeArray.getIntAt(ii));
        } else if (variableType == BasicType.T_LONG) {
            valueImpl =  (LongValueImpl) vm.mirrorOf(typeArray.getLongAt(ii));
        } else if (variableType == BasicType.T_OBJECT) {
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
            // elements themselves may be arrays because every array is an Object.
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(objArray.getObjAt(ii));
        } else if (variableType == BasicType.T_ARRAY) {
            valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array) objArray.getObjAt(ii));
        } else {
            throw new RuntimeException("should not reach here");
        }
        vals.add (valueImpl);
    }
    return vals;
}
 
Example #27
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 #28
Source File: StackFrameImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private ValueImpl getSlotValue(StackValueCollection values,
                   BasicType variableType, int ss) {
    ValueImpl valueImpl = null;
    OopHandle handle = null;
    ObjectHeap heap = vm.saObjectHeap();
    if (values.get(ss).getType() == BasicType.getTConflict()) {
      // Dead locals, so just represent them as a zero of the appropriate type
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = null;
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = null;
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    } else {
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = values.oopHandleAt(ss);
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = values.oopHandleAt(ss);
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    }

    return valueImpl;
}
 
Example #29
Source File: StackFrameImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private ValueImpl getSlotValue(StackValueCollection values,
                   BasicType variableType, int ss) {
    ValueImpl valueImpl = null;
    OopHandle handle = null;
    ObjectHeap heap = vm.saObjectHeap();
    if (values.get(ss).getType() == BasicType.getTConflict()) {
      // Dead locals, so just represent them as a zero of the appropriate type
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = null;
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = null;
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    } else {
      if (variableType == BasicType.T_BOOLEAN) {
        valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
      } else if (variableType == BasicType.T_CHAR) {
        valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
      } else if (variableType == BasicType.T_FLOAT) {
        valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
      } else if (variableType == BasicType.T_DOUBLE) {
        valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
      } else if (variableType == BasicType.T_BYTE) {
        valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
      } else if (variableType == BasicType.T_SHORT) {
        valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
      } else if (variableType == BasicType.T_INT) {
        valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
      } else if (variableType == BasicType.T_LONG) {
        valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
      } else if (variableType == BasicType.T_OBJECT) {
        // we may have an [Ljava/lang/Object; - i.e., Object[] with the
        // elements themselves may be arrays because every array is an Object.
        handle = values.oopHandleAt(ss);
        valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
      } else if (variableType == BasicType.T_ARRAY) {
        handle = values.oopHandleAt(ss);
        valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
      } else if (variableType == BasicType.T_VOID) {
        valueImpl = new VoidValueImpl(vm);
      } else {
        throw new RuntimeException("Should not read here");
      }
    }

    return valueImpl;
}
 
Example #30
Source File: ArrayReferenceImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
ArrayReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Array aRef) {
    super(aVm, aRef);
    length = (int) aRef.getLength();
}