/** * 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; }
@Override public TextPosition getPreTranslationPosition(TextPosition source) { // find the most recent change to the offset and add it to the // position Offset offset = null; if (offsetMap.containsKey(source)) { // offset change starts at the specified position offset = offsetMap.get(source); } else { SortedMap<TextPosition, Offset> headMap = offsetMap.headMap(source); if (headMap.isEmpty()) { // no offset change occurs before the position offset = new Offset(0, 0); } else { // offset change strictly precedes the position offset = headMap.get(headMap.lastKey()); } } return offset.forwardOffset(source); }
public static void init() { Add.init(); Address.init(); Align.init(); Alloc.init(); Anchor.init(); And.init(); Bad.init(); Bitcast.init(); Block.init(); Builtin.init(); Call.init(); Cmp.init(); Cond.init(); Confirm.init(); Const.init(); Conv.init(); CopyB.init(); Deleted.init(); Div.init(); Dummy.init(); End.init(); Eor.init(); Free.init(); IJmp.init(); Id.init(); Jmp.init(); Load.init(); Member.init(); Minus.init(); Mod.init(); Mul.init(); Mulh.init(); Mux.init(); NoMem.init(); Not.init(); Offset.init(); Or.init(); Phi.init(); Pin.init(); Proj.init(); Raise.init(); Return.init(); Sel.init(); Shl.init(); Shr.init(); Shrs.init(); Size.init(); Start.init(); Store.init(); Sub.init(); Switch.init(); Sync.init(); Tuple.init(); Unknown.init(); }
/** * 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)); }
public UnioningOffset(Offset lhs, Offset rhs) { if (lhs.withinBounds()) { offsets[0] = lhs; } if (rhs.withinBounds()) { if (offsets[0] == null) { offsets[0] = rhs; } else { offsets[1] = rhs; } } if (offsets[0] != null) { offsetVals[0] = offsets[0].getOffset(); if (offsets[1] != null) { offsetVals[1] = offsets[1].getOffset(); } } figureOutNextValue(); }
/** * Compute the label's screen position from its geographic position. * * @param dc Current draw context. */ protected void computeGeometry(DrawContext dc) { // Project the label position onto the viewport Position pos = this.getPosition(); if (pos == null) return; this.placePoint = dc.computeTerrainPoint(pos.getLatitude(), pos.getLongitude(), 0); this.screenPlacePoint = dc.getView().project(this.placePoint); this.eyeDistance = this.placePoint.distanceTo3(dc.getView().getEyePoint()); boolean orientationReversed = false; if (this.orientationPosition != null) { // Project the orientation point onto the screen Vec4 orientationPlacePoint = dc.computeTerrainPoint( this.orientationPosition.getLatitude(), this.orientationPosition.getLongitude(), 0); Vec4 orientationScreenPoint = dc.getView().project(orientationPlacePoint); this.rotation = this.computeRotation(this.screenPlacePoint, orientationScreenPoint); // The orientation is reversed if the orientation point falls to the right of the screen // point. Text is // never drawn upside down, so when the orientation is reversed the text flips vertically to // keep the text // right side up. orientationReversed = (orientationScreenPoint.x <= this.screenPlacePoint.x); } this.computeBoundsIfNeeded(dc); Offset offset = this.getOffset(); Point2D offsetPoint = offset.computeOffset(this.bounds.getWidth(), this.bounds.getHeight(), null, null); // If a rotation is applied to the text, then rotate the offset as well. An offset in the x // direction // will move the text along the orientation line, and a offset in the y direction will move the // text // perpendicular to the orientation line. if (this.rotation != null) { double dy = offsetPoint.getY(); // If the orientation is reversed we need to adjust the vertical offset to compensate for the // flipped // text. For example, if the offset normally aligns the top of the text with the place point // then without // this adjustment the bottom of the text would align with the place point when the // orientation is // reversed. if (orientationReversed) { dy = -(dy + this.bounds.getHeight()); } Vec4 pOffset = new Vec4(offsetPoint.getX(), dy); Matrix rot = Matrix.fromRotationZ(this.rotation.multiply(-1)); pOffset = pOffset.transformBy3(rot); offsetPoint = new Point((int) pOffset.getX(), (int) pOffset.getY()); } int x = (int) (this.screenPlacePoint.x + offsetPoint.getX()); int y = (int) (this.screenPlacePoint.y - offsetPoint.getY()); this.screenPoint = new Point(x, y); this.screenExtent = this.computeTextExtent(x, y, this.rotation); }
private static void confirmDoubleConvert(double doubleVal, int expected) { assertEquals(expected, Offset.convertDoubleToInt(doubleVal)); }
public static void kBiggest(Node root, int K) { Offset offset = new Offset(); offset.offest = 0; kBiggest(root, K, offset); }