Exemplo n.º 1
0
 private static long headerSize(BasicType type) {
   if (Universe.elementTypeShouldBeAligned(type)) {
     return alignObjectSize(headerSizeInBytes()) / VM.getVM().getHeapWordSize();
   } else {
     return headerSizeInBytes() / VM.getVM().getHeapWordSize();
   }
 }
Exemplo n.º 2
0
 private long lengthOffsetInBytes() {
   if (lengthOffsetInBytes != 0) {
     return lengthOffsetInBytes;
   }
   if (VM.getVM().isCompressedOopsEnabled()) {
     lengthOffsetInBytes = typeSize - VM.getVM().getIntSize();
   } else {
     lengthOffsetInBytes = typeSize;
   }
   return lengthOffsetInBytes;
 }
Exemplo n.º 3
0
 private static long headerSizeInBytes() {
   if (headerSize != 0) {
     return headerSize;
   }
   if (VM.getVM().isCompressedOopsEnabled()) {
     headerSize = typeSize;
   } else {
     headerSize =
         VM.getVM().alignUp(typeSize + VM.getVM().getIntSize(), VM.getVM().getHeapWordSize());
   }
   return headerSize;
 }
  /** Only returns addresses of valid OopHandles */
  private Address getOopHandleAddress(int x) {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(x < top(), "out of bounds");
    }

    Address oopAddr = addr.addOffsetTo(handlesField.getOffset() + x * VM.getVM().getOopSize());
    OopHandle handle = oopAddr.getOopHandleAt(0);
    if (VM.getVM().getUniverse().isInReserved(handle)
        && !VM.getVM().getJNIHandles().isDeletedHandle(handle)) {
      /* the oop handle is valid only if it is not freed (i.e. reserved in heap) and is not a deleted oop */
      return oopAddr;
    } else {
      return null;
    }
  }
Exemplo n.º 5
0
 // "size helper" == instance size in words
 public long getSizeHelper() {
   int lh = getLayoutHelper();
   if (Assert.ASSERTS_ENABLED) {
     Assert.that(lh > 0, "layout helper initialized for instance class");
   }
   return lh / VM.getVM().getAddressSize();
 }
Exemplo n.º 6
0
 public int getFieldOrMethodAt(int which) {
   if (DEBUG) {
     System.err.print("ConstantPool.getFieldOrMethodAt(" + which + "): new index = ");
   }
   int i = -1;
   ConstantPoolCache cache = getCache();
   if (cache == null) {
     i = which;
   } else {
     // change byte-ordering and go via cache
     i =
         cache
             .getEntryAt(0xFFFF & VM.getVM().getBytes().swapShort((short) which))
             .getConstantPoolIndex();
   }
   if (Assert.ASSERTS_ENABLED) {
     Assert.that(getTagAt(i).isFieldOrMethod(), "Corrupted constant pool");
   }
   if (DEBUG) {
     System.err.println(i);
   }
   int res = getIntAt(i);
   if (DEBUG) {
     System.err.println("ConstantPool.getFieldOrMethodAt(" + i + "): result = " + res);
   }
   return res;
 }
Exemplo n.º 7
0
  private static void initialize(TypeDataBase db) {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(!VM.getVM().isCore(), "Debug info not used in core build");
    }

    OFFSET_MASK = db.lookupIntConstant("Location::OFFSET_MASK").intValue();
    OFFSET_SHIFT = db.lookupIntConstant("Location::OFFSET_SHIFT").intValue();
    TYPE_MASK = db.lookupIntConstant("Location::TYPE_MASK").intValue();
    TYPE_SHIFT = db.lookupIntConstant("Location::TYPE_SHIFT").intValue();
    WHERE_MASK = db.lookupIntConstant("Location::WHERE_MASK").intValue();
    WHERE_SHIFT = db.lookupIntConstant("Location::WHERE_SHIFT").intValue();

    // Location::Type constants
    TYPE_NORMAL = db.lookupIntConstant("Location::normal").intValue();
    TYPE_OOP = db.lookupIntConstant("Location::oop").intValue();
    TYPE_NARROWOOP = db.lookupIntConstant("Location::narrowoop").intValue();
    TYPE_INT_IN_LONG = db.lookupIntConstant("Location::int_in_long").intValue();
    TYPE_LNG = db.lookupIntConstant("Location::lng").intValue();
    TYPE_FLOAT_IN_DBL = db.lookupIntConstant("Location::float_in_dbl").intValue();
    TYPE_DBL = db.lookupIntConstant("Location::dbl").intValue();
    TYPE_ADDR = db.lookupIntConstant("Location::addr").intValue();
    TYPE_INVALID = db.lookupIntConstant("Location::invalid").intValue();

    // Location::Where constants
    WHERE_ON_STACK = db.lookupIntConstant("Location::on_stack").intValue();
    WHERE_IN_REGISTER = db.lookupIntConstant("Location::in_register").intValue();
  }
Exemplo n.º 8
0
 private static void initialize(TypeDataBase db) {
   if (VM.getVM().isServerCompiler()) {
     Type type = db.lookupType("Matcher");
     Field f = type.getField("_regEncode");
     matcherRegEncodeAddr = f.getStaticFieldAddress();
   }
 }
Exemplo n.º 9
0
 public long getLongAt(long index) {
   int oneHalf = getHandle().getJIntAt(indexOffset(index + 1));
   int otherHalf = getHandle().getJIntAt(indexOffset(index));
   // buildLongFromIntsPD accepts higher address value, lower address value
   // in that order.
   return VM.getVM().buildLongFromIntsPD(oneHalf, otherHalf);
 }
Exemplo n.º 10
0
 private long getElementSize() {
   if (elementSize != 0) {
     return elementSize;
   } else {
     elementSize = VM.getVM().getOopSize();
   }
   return elementSize;
 }
Exemplo n.º 11
0
 static {
   VM.registerVMInitializedObserver(
       new Observer() {
         public void update(Observable o, Object data) {
           initialize(VM.getVM().getTypeDataBase());
         }
       });
 }
Exemplo n.º 12
0
 /** Convenience routine taking Strings; lookup is done in SymbolTable. */
 public Method findMethod(String name, String sig) {
   SymbolTable syms = VM.getVM().getSymbolTable();
   Symbol nameSym = syms.probe(name);
   Symbol sigSym = syms.probe(sig);
   if (nameSym == null || sigSym == null) {
     return null;
   }
   return findMethod(nameSym, sigSym);
 }
Exemplo n.º 13
0
  private static void initialize(TypeDataBase db) {
    Type type = db.lookupType("oopDesc");

    if (VM.getVM().isCompressedOopsEnabled()) {
      klassField = type.getNarrowOopField("_metadata._compressed_klass");
    } else {
      klassField = type.getOopField("_metadata._klass");
    }
  }
Exemplo n.º 14
0
  public ThreadProxy getThreadProxy(Address addr) {
    // Addr is the address of the JavaThread.
    // Fetch the OSThread (for now and for simplicity, not making a
    // separate "OSThread" class in this package)
    Address osThreadAddr = osThreadField.getValue(addr);
    // Get the address of the _thread_id from the OSThread
    Address threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());

    JVMDebugger debugger = VM.getVM().getDebugger();
    return debugger.getThreadForIdentifierAddress(threadIdAddr);
  }
Exemplo n.º 15
0
 public static boolean oopLooksValid(OopHandle oop) {
   if (oop == null) {
     return false;
   }
   if (!VM.getVM().getUniverse().isIn(oop)) {
     return false;
   }
   try {
     for (int i = 0; i < 4; ++i) {
       OopHandle next = klassField.getValue(oop);
       if (next == null) {
         return false;
       }
       if (next.equals(oop)) {
         return true;
       }
       oop = next;
     }
     return false;
   } catch (AddressException e) {
     return false;
   }
 }
Exemplo n.º 16
0
 // Creates new field from index in fields TypeArray
 private Field newField(int index) {
   TypeArray fields = getFields();
   short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
   FieldType type = new FieldType((Symbol) getConstants().getObjAt(signatureIndex));
   if (type.isOop()) {
     if (VM.getVM().isCompressedOopsEnabled()) {
       return new NarrowOopField(this, index);
     } else {
       return new OopField(this, index);
     }
   }
   if (type.isByte()) {
     return new ByteField(this, index);
   }
   if (type.isChar()) {
     return new CharField(this, index);
   }
   if (type.isDouble()) {
     return new DoubleField(this, index);
   }
   if (type.isFloat()) {
     return new FloatField(this, index);
   }
   if (type.isInt()) {
     return new IntField(this, index);
   }
   if (type.isLong()) {
     return new LongField(this, index);
   }
   if (type.isShort()) {
     return new ShortField(this, index);
   }
   if (type.isBoolean()) {
     return new BooleanField(this, index);
   }
   throw new RuntimeException("Illegal field type at index " + index);
 }
Exemplo n.º 17
0
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
    Type type = db.lookupType("methodOopDesc");
    constMethod = new OopField(type.getOopField("_constMethod"), 0);
    constants = new OopField(type.getOopField("_constants"), 0);
    methodSize = new CIntField(type.getCIntegerField("_method_size"), 0);
    maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0);
    maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0);
    sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
    accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
    code = type.getAddressField("_code");
    vtableIndex = new CIntField(type.getCIntegerField("_vtable_index"), 0);
    if (!VM.getVM().isCore()) {
      invocationCounter = new CIntField(type.getCIntegerField("_invocation_counter"), 0);
    }
    bytecodeOffset = type.getSize();

    /*
    interpreterEntry           = type.getAddressField("_interpreter_entry");
    fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point");

    */
    objectInitializerName = null;
    classInitializerName = null;
  }
Exemplo n.º 18
0
 private static Symbol javaLangCloneableName() {
   if (javaLangCloneableName == null) {
     javaLangCloneableName = VM.getVM().getSymbolTable().probe("java/lang/Cloneable");
   }
   return javaLangCloneableName;
 }
Exemplo n.º 19
0
 private static Symbol objectInitializerName() {
   if (objectInitializerName == null) {
     objectInitializerName = VM.getVM().getSymbolTable().probe("<init>");
   }
   return objectInitializerName;
 }
Exemplo n.º 20
0
 public int getStackOffset() {
   if (Assert.ASSERTS_ENABLED) {
     Assert.that(getWhere() == Where.ON_STACK, "wrong Where");
   }
   return getOffset() * (int) VM.getVM().getIntSize();
 }
Exemplo n.º 21
0
 public Klass getJavaSuper() {
   SystemDictionary sysDict = VM.getVM().getSystemDictionary();
   return sysDict.getObjectKlass();
 }
Exemplo n.º 22
0
 public long getInvocationCounter() {
   if (Assert.ASSERTS_ENABLED) {
     Assert.that(!VM.getVM().isCore(), "must not be used in core build");
   }
   return invocationCounter.getValue(this);
 }
Exemplo n.º 23
0
 public static long baseOffsetInBytes(BasicType type) {
   return headerSize(type) * VM.getVM().getHeapWordSize();
 }
Exemplo n.º 24
0
  private static synchronized void initialize(TypeDataBase db) {
    Type type = db.lookupType("Threads");

    threadListField = type.getAddressField("_thread_list");
    numOfThreadsField = type.getCIntegerField("_number_of_threads");

    // Instantiate appropriate platform-specific JavaThreadFactory
    String os = VM.getVM().getOS();
    String cpu = VM.getVM().getCPU();

    access = null;
    // FIXME: find the platform specific PD class by reflection?
    if (os.equals("solaris")) {
      if (cpu.equals("sparc")) {
        access = new SolarisSPARCJavaThreadPDAccess();
      } else if (cpu.equals("x86")) {
        access = new SolarisX86JavaThreadPDAccess();
      } else if (cpu.equals("amd64")) {
        access = new SolarisAMD64JavaThreadPDAccess();
      }
    } else if (os.equals("win32")) {
      if (cpu.equals("x86")) {
        access = new Win32X86JavaThreadPDAccess();
      } else if (cpu.equals("amd64")) {
        access = new Win32AMD64JavaThreadPDAccess();
      }
    } else if (os.equals("linux")) {
      if (cpu.equals("x86")) {
        access = new LinuxX86JavaThreadPDAccess();
      } else if (cpu.equals("amd64")) {
        access = new LinuxAMD64JavaThreadPDAccess();
      } else if (cpu.equals("sparc")) {
        access = new LinuxSPARCJavaThreadPDAccess();
      } else if (cpu.equals("ppc64")) {
        access = new LinuxPPC64JavaThreadPDAccess();
      } else if (cpu.equals("aarch64")) {
        access = new LinuxAARCH64JavaThreadPDAccess();
      } else {
        try {
          access =
              (JavaThreadPDAccess)
                  Class.forName(
                          "sun.jvm.hotspot.runtime.linux_"
                              + cpu.toLowerCase()
                              + ".Linux"
                              + cpu.toUpperCase()
                              + "JavaThreadPDAccess")
                      .newInstance();
        } catch (Exception e) {
          throw new RuntimeException("OS/CPU combination " + os + "/" + cpu + " not yet supported");
        }
      }
    } else if (os.equals("bsd")) {
      if (cpu.equals("x86")) {
        access = new BsdX86JavaThreadPDAccess();
      } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
        access = new BsdAMD64JavaThreadPDAccess();
      }
    } else if (os.equals("darwin")) {
      if (cpu.equals("amd64") || cpu.equals("x86_64")) {
        access = new BsdAMD64JavaThreadPDAccess();
      }
    }

    if (access == null) {
      throw new RuntimeException("OS/CPU combination " + os + "/" + cpu + " not yet supported");
    }

    virtualConstructor = new VirtualConstructor(db);
    // Add mappings for all known thread types
    virtualConstructor.addMapping("JavaThread", JavaThread.class);
    if (!VM.getVM().isCore()) {
      virtualConstructor.addMapping("CompilerThread", CompilerThread.class);
      virtualConstructor.addMapping("CodeCacheSweeperThread", CodeCacheSweeperThread.class);
    }
    virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class);
    virtualConstructor.addMapping("ServiceThread", ServiceThread.class);
  }
Exemplo n.º 25
0
 // Accessor
 public Oop loader() {
   return VM.getVM().getObjectHeap().newOop(loaderField.getValue(addr));
 }
Exemplo n.º 26
0
 private static Symbol javaLangObjectName() {
   if (javaLangObjectName == null) {
     javaLangObjectName = VM.getVM().getSymbolTable().probe("java/lang/Object");
   }
   return javaLangObjectName;
 }
Exemplo n.º 27
0
 private static Symbol javaIoSerializableName() {
   if (javaIoSerializableName == null) {
     javaIoSerializableName = VM.getVM().getSymbolTable().probe("java/io/Serializable");
   }
   return javaIoSerializableName;
 }
Exemplo n.º 28
0
 private static Symbol classInitializerName() {
   if (classInitializerName == null) {
     classInitializerName = VM.getVM().getSymbolTable().probe("<clinit>");
   }
   return classInitializerName;
 }
Exemplo n.º 29
0
 public String toString() {
   Address handleBase = addr.addOffsetTo(handlesField.getOffset());
   Address handleEnd =
       addr.addOffsetTo(handlesField.getOffset() + top() * VM.getVM().getOopSize());
   return "JNIHandleBlock [" + handleBase + ", " + handleEnd + ")";
 }
Exemplo n.º 30
0
 // Accessors for declared fields
 public long getLength() {
   boolean isUnsigned = true;
   return this.getHandle()
       .getCIntegerAt(lengthOffsetInBytes(), VM.getVM().getIntSize(), isUnsigned);
 }