コード例 #1
0
  static int newGlobalRef(Object referent) {
    if (VM.VerifyAssertions)
      VM._assert(MemoryManager.validRef(ObjectReference.fromObject(referent)));

    if (free >= JNIGlobalRefs.length()) {
      AddressArray newGlobalRefs = AddressArray.create(JNIGlobalRefs.length() * 2);
      copyAndReplaceGlobalRefs(newGlobalRefs);
    }

    JNIGlobalRefs.set(free, Magic.objectAsAddress(referent));
    return -free++;
  }
コード例 #2
0
 @Uninterruptible
 private static void copyAndReplaceGlobalRefs(AddressArray newGlobalRefs) {
   for (int i = 0; i < JNIGlobalRefs.length(); i++) {
     newGlobalRefs.set(i, JNIGlobalRefs.get(i));
   }
   JNIGlobalRefs = newGlobalRefs;
 }