private boolean acquireRecyclableLines(int bytes, int align, int offset) { while (line < LINES_IN_BLOCK || acquireRecyclableBlock()) { line = space.getNextAvailableLine(markTable, line); if (line < LINES_IN_BLOCK) { int endLine = space.getNextUnavailableLine(markTable, line); cursor = recyclableBlock.plus(Extent.fromIntSignExtend(line << LOG_BYTES_IN_LINE)); limit = recyclableBlock.plus(Extent.fromIntSignExtend(endLine << LOG_BYTES_IN_LINE)); if (SANITY_CHECK_LINE_MARKS) { Address tmp = cursor; while (tmp.LT(limit)) { if (tmp.loadByte() != (byte) 0) { Log.write("cursor: "); Log.writeln(cursor); Log.write(" limit: "); Log.writeln(limit); Log.write("current: "); Log.write(tmp); Log.write(" value: "); Log.write(tmp.loadByte()); Log.write(" line: "); Log.write(line); Log.write("endline: "); Log.write(endLine); Log.write(" chunk: "); Log.write(Chunk.align(cursor)); Log.write(" hw: "); Log.write(Chunk.getHighWater(Chunk.align(cursor))); Log.writeln(" values: "); Address tmp2 = cursor; while (tmp2.LT(limit)) { Log.write(tmp2.loadByte()); Log.write(" "); } Log.writeln(); } VM.assertions._assert(tmp.loadByte() == (byte) 0); tmp = tmp.plus(1); } } if (VM.VERIFY_ASSERTIONS && bytes <= BYTES_IN_LINE) { Address start = alignAllocationNoFill(cursor, align, offset); Address end = start.plus(bytes); VM.assertions._assert(end.LE(limit)); } VM.memory.zero(cursor, limit.diff(cursor).toWord().toExtent()); if (VM.VERIFY_ASSERTIONS && Options.verbose.getValue() >= 9) { Log.write("Z["); Log.write(cursor); Log.write("->"); Log.write(limit); Log.writeln("]"); } line = endLine; if (VM.VERIFY_ASSERTIONS && copy) VM.assertions._assert(!Block.isDefragSource(cursor)); return true; } } return false; }
/** * Zero 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) */ public static void zero(Address start, Extent bytes) throws InlinePragma { if (Assert.VERIFY_ASSERTIONS) { assertAligned(start); assertAligned(bytes); } if (bytes.GT(Extent.fromIntZeroExtend(SMALL_REGION_THRESHOLD))) org.mmtk.vm.Memory.zero(start, bytes); else zeroSmall(start, bytes); }
private void zeroBlock(Address block) { // FIXME: efficiency check here! if (VM.VERIFY_ASSERTIONS) VM.assertions._assert( block.toWord().and(Word.fromIntSignExtend(BYTES_IN_BLOCK - 1)).isZero()); VM.memory.zero(block, Extent.fromIntZeroExtend(BYTES_IN_BLOCK)); }
/** * Allows access to an area of virtual memory. * * @param start the address of the start of the area to be mapped * @param size the size, in bytes, of the area to be mapped * @return <code>true</code> if successful, otherwise <code>false</code> */ public final boolean munprotect(Address start, int size) { return org.jikesrvm.runtime.Memory.mprotect( start, Extent.fromIntZeroExtend(size), org.jikesrvm.runtime.Memory.PROT_READ | org.jikesrvm.runtime.Memory.PROT_WRITE | org.jikesrvm.runtime.Memory.PROT_EXEC); }
/** * Demand zero mmaps an area of virtual memory. * * @param start the address of the start of the area to be mapped * @param size the size, in bytes, of the area to be mapped * @return 0 if successful, otherwise the system errno */ public final int dzmmap(Address start, int size) { Address result = org.jikesrvm.runtime.Memory.dzmmap(start, Extent.fromIntZeroExtend(size)); if (result.EQ(start)) return 0; if (result.GT(Address.fromIntZeroExtend(127))) { VM.sysWrite("demand zero mmap with MAP_FIXED on ", start); VM.sysWriteln(" returned some other address", result); VM.sysFail("mmap with MAP_FIXED has unexpected behavior"); } return result.toInt(); }
/** * Protects access to an area of virtual memory. * * @param start the address of the start of the area to be mapped * @param size the size, in bytes, of the area to be mapped * @return <code>true</code> if successful, otherwise <code>false</code> */ public final boolean mprotect(Address start, int size) { return org.jikesrvm.runtime.Memory.mprotect( start, Extent.fromIntZeroExtend(size), org.jikesrvm.runtime.Memory.PROT_NONE); }
private static final void assertAligned(Extent value) { assertAligned(value.toWord()); }