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; }
// // Verify that, after replacing a hole and the highest-offset extent in a // two entry map with one that leaves a byte of the replaced extent // protruding: // - The resulting map has the correct number of entries. // - The protrusion from the high end of the map properly appears in // the resulting map. // // This test recreates the circumstances of a bug observed while testing // the BufferCache class. // @Test public final void testReplaceExtentsR0() { ByteBuffer b00_01 = ByteBuffer.wrap("0".getBytes()); ByteBuffer b02_04 = ByteBuffer.wrap("23".getBytes()); ExtentBuffer eb00_01 = new ExtentBuffer(0L, b00_01); ExtentBuffer eb02_04 = new ExtentBuffer(2L, b02_04); ExtentBufferMap m00_04 = new ExtentBufferMap(); m00_04.put(eb00_01); m00_04.put(eb02_04); ByteBuffer b01_03 = ByteBuffer.wrap("ab".getBytes()); ExtentBuffer eb01_03 = new ExtentBuffer(1L, b01_03); m00_04.replaceExtents(eb01_03); assertEquals("resulting map should have 3 extents", m00_04.size(), 3); assertEquals( "the extent starting at offset 1 in the result " + " should be the one given as the replacement", m00_04.get(1L), eb01_03); // // XXX: Verify tail's contents as well as its bounds? // Extent tail = m00_04.get(m00_04.lastKey()); assertTrue( "resulting map should have an extent for protrusion", tail.getStartOffset() == 3L && tail.getEndOffset() == 4L); }
/** * 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); }
public void delete() { begin(); Extent extent = db().getExtent(JB4.class, false); Iterator it = extent.iterator(); while (it.hasNext()) { db().deletePersistent(it.next()); addToCheckSum(5); } extent.closeAll(); commit(); }
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); }
/** * Indicates whether a specified {@link Extent} intersects this frustum. * * @param extent the Extent to test. * @return true if the extent intersects this frustum, otherwise false. * @throws IllegalArgumentException if the extent is null. */ public boolean intersects(Extent extent) { if (extent == null) { String msg = Logging.getMessage("nullValue.ExtentIsNull"); Logging.error(msg); throw new IllegalArgumentException(msg); } return extent.intersects(this); }
/** * Extent declarations are inherited from parent Layers. Any Extent declarations in the child with * the same name attribute as one inherited from the parent replaces the value declared by the * parent. A Layer shall not declare an Extent unless a Dimension with the same name has been * declared or inherited earlier in the Capabilities XML. * * @return the extents */ public Extent[] getExtent() { HashMap<String, Extent> list = new HashMap<String, Extent>(); if (parent != null) { Extent[] pEx = parent.getExtent(); for (int i = 0; i < pEx.length; i++) { list.put(pEx[i].getName(), pEx[i]); } } for (int i = 0; i < extent.size(); i++) { Extent ex = extent.get(i); list.put(ex.getName(), ex); } return list.values().toArray(new Extent[list.size()]); }
/** * 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(); }
public static List betterAllocateRows(int horizonStart, int horizonEnd, List extents) { ArrayList source = new ArrayList(extents); ArrayList rows = new ArrayList(); rows.add(new Row(0)); Collections.sort(source, new ExtentComparator()); Iterator extentIterator = source.listIterator(); while (extentIterator.hasNext()) { Extent e = (Extent) extentIterator.next(); int i, n; for (i = 0, n = rows.size(); i < n; i++) { if (e.getStart() > ((Row) rows.get(i)).getLatestEnd()) { ((Row) rows.get(i)).add(e); break; } } if (i == rows.size()) { Row newRow = new Row(rows.size()); newRow.add(e); rows.add(newRow); } System.err.println("[" + e.getStart() + ".." + e.getEnd() + "]: " + e.getRow()); } return source; }
public int compare(Object obj1, Object obj2) { Extent e1 = (Extent) obj1; Extent e2 = (Extent) obj2; if (e1.getStart() < e2.getStart()) { return -1; } else if (e1.getStart() > e2.getStart()) { return 1; } else { return 0; } }
/** * 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); }
/** * Will allocate a row number to every extent in the list that may overlap the horizon. Row * numbers are assumed to begin at 0. This algorithm ensures that no temporal overlap occurs on * any given row and that the minimum number of rows are required. Extents whcih do not overlap * the horizon defined by horizonStart and horizonEnd will be given a row of -1. * * @param horizonStart Will ignore rows that cannot occur at or after this time. * @param horizonEnd Will ignore rows that cannot occur at or before this time. * @param extents A list of objects implementing the Extent interface whose rows are to be set * (thus may be changed) * @return A susbet of extents which intersected the time horizon, and for which rows have been * assigned. */ public static List allocateRows(int horizonStart, int horizonEnd, List extents) { List results = new ArrayList(); LinkedList source = new LinkedList(extents); Collections.sort(source, new ExtentComparator()); // Check the sort worked if (DEBUG_ON) { System.out.println("Debug version"); int max = 0; // Not safe for negative horizon start value. for (Iterator it = source.iterator(); it.hasNext(); ) { Extent extent = (Extent) it.next(); if (max > extent.getStart()) { System.out.println("Bad sort"); System.exit(-1); } max = extent.getStart(); } } int lastCount = extents.size(); int rowCount = 0; while (source.size() > 0) { boolean passedHorizon = false; int currentTime = horizonStart; Iterator it = source.iterator(); while (currentTime <= horizonEnd && it.hasNext()) { Extent extent = (Extent) it.next(); // If it is totally outside the horizon - ret rid of it and set row to NO_ROW if (extent.getEnd() < horizonStart || extent.getStart() > horizonEnd) { System.out.println("Removing element " + extent.toString() + " - outside horizon"); System.out.println( " start " + extent.getStart() + " end " + extent.getEnd() + " horizonStart " + horizonStart + " horizonEnd " + horizonEnd); extent.setRow(NO_ROW); it.remove(); continue; } // If it overlaps already placed extents, then just skip it if (extent.getStart() < currentTime && passedHorizon) // Also check to make sure it is not initial entry continue; // Otherwise, we will insert it in this row, and remove it from further consideration extent.setRow(rowCount); results.add(extent); it.remove(); // Update currentTime currentTime = extent.getEnd(); // Indicate we have inserted something and thus passed the Horizon passedHorizon = true; } rowCount++; if (DEBUG_ON) { if (source.size() >= lastCount) { System.out.println("Bug in the loop - should be converging but isn't"); System.exit(-1); } lastCount = source.size(); } } return results; }
public void add(Extent e) { e.setRow(n); latestEnd = e.getEnd(); }
protected Vec4 computeReferenceCenter(DrawContext dc) { Extent extent = this.getExtent(dc); return extent != null ? extent.getCenter() : null; }
public double getWidth() { return extent.getWidth(); }
private static final void assertAligned(Extent value) { assertAligned(value.toWord()); }
public double getHeight() { return extent.getHeight(); }