/** * Copy numbytes from src to dst. Assumption either the ranges are non overlapping, or src >= dst * + 4. Also, src and dst are 4 byte aligned and numBytes is a multiple of 4. * * @param dst the destination addr * @param src the source addr * @param numBytes the number of bytes top copy */ @Inline public static void aligned32Copy(Address dst, Address src, Offset numBytes) { if (USE_NATIVE && numBytes.sGT(Offset.fromIntSignExtend(NATIVE_THRESHOLD))) { memcopy(dst, src, numBytes.toWord().toExtent()); } else { if (VM.BuildFor64Addr) { Word wordMask = Word.one().lsh(LOG_BYTES_IN_ADDRESS).minus(Word.one()); Word srcAlignment = src.toWord().and(wordMask); if (srcAlignment.EQ(dst.toWord().and(wordMask))) { Offset i = Offset.zero(); if (srcAlignment.EQ(Word.fromIntZeroExtend(BYTES_IN_INT))) { dst.store(src.loadInt(i), i); i = i.plus(BYTES_IN_INT); } Word endAlignment = srcAlignment.plus(numBytes).and(Word.fromIntSignExtend(BYTES_IN_ADDRESS - 1)); numBytes = numBytes.minus(endAlignment.toOffset()); for (; i.sLT(numBytes); i = i.plus(BYTES_IN_ADDRESS)) { dst.store(src.loadWord(i), i); } if (!endAlignment.isZero()) { dst.store(src.loadInt(i), i); } return; } } // normal case: 32 bit or (64 bit not aligned) for (Offset i = Offset.zero(); i.sLT(numBytes); i = i.plus(BYTES_IN_INT)) { dst.store(src.loadInt(i), i); } } }
/** * Copy copyBytes from src to dst. Assumption: either the ranges are non overlapping, or {@code * src >= dst + 4}. Also, src and dst are 4 byte aligned and numBytes is a multiple of 4. * * @param dst the destination addr * @param src the source addr * @param copyBytes the number of bytes top copy */ public static void aligned32Copy(Address dst, Address src, int copyBytes) { if (VM.VerifyAssertions) { VM._assert(copyBytes >= 0); VM._assert((copyBytes & (BYTES_IN_INT - 1)) == 0); VM._assert(src.toWord().and(Word.fromIntZeroExtend(BYTES_IN_INT - 1)).isZero()); VM._assert(dst.toWord().and(Word.fromIntZeroExtend(BYTES_IN_INT - 1)).isZero()); VM._assert(src.plus(copyBytes).LE(dst) || src.GE(dst.plus(BYTES_IN_INT))); } if (USE_NATIVE && copyBytes > NATIVE_THRESHOLD) { memcopy(dst, src, copyBytes); } else { Offset numBytes = Offset.fromIntSignExtend(copyBytes); if (BYTES_IN_COPY == 8 && copyBytes != 0) { Word wordMask = Word.fromIntZeroExtend(BYTES_IN_COPY - 1); Word srcAlignment = src.toWord().and(wordMask); if (srcAlignment.EQ(dst.toWord().and(wordMask))) { Offset i = Offset.zero(); if (srcAlignment.EQ(Word.fromIntZeroExtend(BYTES_IN_INT))) { copy4Bytes(dst.plus(i), src.plus(i)); i = i.plus(BYTES_IN_INT); } Word endAlignment = srcAlignment.plus(numBytes).and(wordMask); numBytes = numBytes.minus(endAlignment.toOffset()); for (; i.sLT(numBytes); i = i.plus(BYTES_IN_COPY)) { copy8Bytes(dst.plus(i), src.plus(i)); } if (!endAlignment.isZero()) { copy4Bytes(dst.plus(i), src.plus(i)); } return; } } // normal case: 32 bit or (64 bit not aligned) for (Offset i = Offset.zero(); i.sLT(numBytes); i = i.plus(BYTES_IN_INT)) { copy4Bytes(dst.plus(i), src.plus(i)); } } }
/** * Trace a reference during GC. This involves determining which collection policy applies and * calling the appropriate <code>trace</code> method. * * @param target The object the interior edge points within. * @param slot The location of the interior edge. * @param root True if this is a root edge. */ public final void processInteriorEdge(ObjectReference target, Address slot, boolean root) { Address interiorRef = slot.loadAddress(); Offset offset = interiorRef.diff(target.toAddress()); ObjectReference newTarget = traceObject(target, root); if (VM.VERIFY_ASSERTIONS) { if (offset.sLT(Offset.zero()) || offset.sGT(Offset.fromIntSignExtend(1 << 24))) { // There is probably no object this large Log.writeln("ERROR: Suspiciously large delta to interior pointer"); Log.write(" object base = "); Log.writeln(target); Log.write(" interior reference = "); Log.writeln(interiorRef); Log.write(" delta = "); Log.writeln(offset); VM.assertions._assert(false); } } slot.store(newTarget.toAddress().plus(offset)); }