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;
  }
Beispiel #2
0
 /**
  * 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);
 }
Beispiel #3
0
 /**
  * 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);
 }