/** * Test whether a memory range is set to a given integer value * * @param start The address to start checking at * @param bytes The size of the region to check, in bytes * @param verbose If true, produce verbose output * @param value The value to which the memory should be set */ private static boolean isSet(Address start, int bytes, boolean verbose, int value) /* Inlining this loop into the uninterruptible code can * cause/encourage the GCP into moving a get_obj_tib into the * interruptible region where the tib is being installed via an * int_store */ throws NoInlinePragma { if (Assert.VERIFY_ASSERTIONS) assertAligned(bytes); for (int i = 0; i < bytes; i += BYTES_IN_INT) if (start.loadInt(Offset.fromInt(i)) != value) { if (verbose) { Log.prependThreadId(); Log.write("Memory range does not contain only value "); Log.writeln(value); Log.write("Non-zero range: "); Log.write(start); Log.write(" .. "); Log.writeln(start.add(bytes)); Log.write("First bad value at "); Log.writeln(start.add(i)); dumpMemory(start, 0, bytes); } return false; } return true; }
/** * Set a region of memory * * @param start The start of the region to be zeroed (must be 4-byte aligned) * @param bytes The number of bytes to be zeroed (must be 4-byte aligned) * @param value The value to which the integers in the region should be set */ public static void set(Address start, int bytes, int value) throws InlinePragma { if (Assert.VERIFY_ASSERTIONS) { assertAligned(start); assertAligned(bytes); } Address end = start.add(bytes); for (Address addr = start; addr.LT(end); addr = addr.add(BYTES_IN_INT)) addr.store(value); }
/** * Zero a small region of memory * * @param start The start of the region to be zeroed (must be 4-byte aligned) * @param bytes The number of bytes to be zeroed (must be 4-byte aligned) */ public static void zeroSmall(Address start, Extent bytes) throws InlinePragma { if (Assert.VERIFY_ASSERTIONS) { assertAligned(start); assertAligned(bytes); } Address end = start.add(bytes); for (Address addr = start; addr.LT(end); addr = addr.add(BYTES_IN_INT)) addr.store(0); }