Skip to content

Commit 6177be7

Browse files
committed
Various refactorings
1 parent 8efac83 commit 6177be7

File tree

12 files changed

+65
-66
lines changed

12 files changed

+65
-66
lines changed

src/de.hpi.swa.trufflesqueak.test/src/de/hpi/swa/trufflesqueak/test/ObjectLayoutTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private static PointersObject instantiate(final ClassObject dummyClass) {
196196
}
197197

198198
private static void writeAndValidate(final AbstractPointersObject obj, final int index, final Object value) {
199-
AbstractPointersObjectWriteNode.getUncached().execute(null, obj, index, value);
200-
assertEquals("Write failed", AbstractPointersObjectReadNode.getUncached().execute(null, obj, index), value);
199+
AbstractPointersObjectWriteNode.executeUncached(obj, index, value);
200+
assertEquals("Write failed", AbstractPointersObjectReadNode.executeUncached(obj, index), value);
201201
}
202202
}

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/image/SqueakImageWriter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ private void run(final ContextObject thisContext) {
8888
final PointersObject activeProcess = image.getActiveProcessSlow();
8989
try {
9090
/* Mark thisContext as suspended during tracing and writing. */
91-
AbstractPointersObjectWriteNode.getUncached().execute(null, activeProcess, PROCESS.SUSPENDED_CONTEXT, thisContext);
91+
AbstractPointersObjectWriteNode.executeUncached(activeProcess, PROCESS.SUSPENDED_CONTEXT, thisContext);
9292
traceObjects();
9393
writeImageHeader();
9494
writeBody();
9595
} finally {
9696
/* Unmark thisContext as suspended. */
97-
AbstractPointersObjectWriteNode.getUncached().executeNil(null, activeProcess, PROCESS.SUSPENDED_CONTEXT);
97+
AbstractPointersObjectWriteNode.executeUncached(activeProcess, PROCESS.SUSPENDED_CONTEXT, NilObject.SINGLETON);
9898
closeStream();
9999
finalizeImageHeader();
100100
}
@@ -242,7 +242,7 @@ public long toWord(final Object object) {
242242
return toTaggedSmallInteger((long) object);
243243
} else if (object instanceof Double) {
244244
return toTaggedSmallFloat((double) object);
245-
} else if (object instanceof AbstractSqueakObject aso) {
245+
} else if (object instanceof AbstractSqueakObjectWithClassAndHash aso) {
246246
final Long oop = oopMap.get(aso);
247247
if (oop != null) {
248248
return oop;
@@ -252,6 +252,7 @@ public long toWord(final Object object) {
252252
}
253253
} else {
254254
/* Nil out any foreign objects. */
255+
assert !(object instanceof AbstractSqueakObject);
255256
return nilOop;
256257
}
257258
}
@@ -384,7 +385,7 @@ public void writeObjects(final Object[] objects) {
384385
}
385386

386387
public void writeObjectIfTracedElseNil(final Object object) {
387-
writeLong(toWord(object instanceof AbstractSqueakObject aso && oopMap.containsKey(aso) ? object : NilObject.SINGLETON));
388+
writeLong(toWord(object instanceof AbstractSqueakObjectWithClassAndHash aso && oopMap.containsKey(aso) ? object : NilObject.SINGLETON));
388389
}
389390

390391
private static long toTaggedCharacter(final long value) {

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/io/SqueakDisplay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private void setSqueakDisplay(final PointersObject squeakDisplay) {
163163

164164
@TruffleBoundary
165165
public void showDisplayRect(final int left, final int right, final int top, final int bottom) {
166-
assert left < right && top < bottom;
166+
assert left <= right && top <= bottom;
167167
canvas.paintImmediately(left, top, right, bottom);
168168
}
169169

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/model/AbstractPointersObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,12 @@ public final int instsize() {
289289

290290
public final Object instVarAt0Slow(final long index) {
291291
CompilerAsserts.neverPartOfCompilation();
292-
return AbstractPointersObjectReadNode.getUncached().execute(null, this, index);
292+
return AbstractPointersObjectReadNode.executeUncached(this, index);
293293
}
294294

295295
public final void instVarAtPut0Slow(final long index, final Object value) {
296296
CompilerAsserts.neverPartOfCompilation();
297-
AbstractPointersObjectWriteNode.getUncached().execute(null, this, index, value);
297+
AbstractPointersObjectWriteNode.executeUncached(this, index, value);
298298
}
299299

300300
protected final boolean layoutValuesPointTo(final SqueakObjectIdentityNode identityNode, final Node inlineTarget, final Object thang) {

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/model/layout/ObjectLayout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public ObjectLayout evolveLocation(final long longIndex, final Object value) {
5555
throw SqueakException.create("Only the latest layout should be evolved");
5656
}
5757
final SlotLocation oldLocation = locations[index];
58-
assert index < locations.length && !oldLocation.isGeneric();
58+
assert !oldLocation.isGeneric();
5959
invalidate();
6060
final SlotLocation[] newLocations = locations.clone();
6161
newLocations[index] = SlotLocation.UNINITIALIZED_LOCATION;

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/accessing/AbstractPointersObjectNodes.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public static AbstractPointersObjectReadNode getUncached() {
5353

5454
public abstract Object execute(Node node, AbstractPointersObject obj, long index);
5555

56+
public static final Object executeUncached(final AbstractPointersObject obj, final long index) {
57+
return getUncached().execute(null, obj, index);
58+
}
59+
5660
public abstract long executeLong(Node node, AbstractPointersObject obj, long index);
5761

5862
public abstract ArrayObject executeArray(Node node, AbstractPointersObject obj, long index);
@@ -95,6 +99,10 @@ public static AbstractPointersObjectWriteNode getUncached() {
9599

96100
public abstract void execute(Node node, AbstractPointersObject obj, long index, Object value);
97101

102+
public static final void executeUncached(final AbstractPointersObject obj, final long index, final Object value) {
103+
getUncached().execute(null, obj, index, value);
104+
}
105+
98106
public final void executeNil(final Node node, final AbstractPointersObject obj, final long index) {
99107
execute(node, obj, index, NilObject.SINGLETON);
100108
}

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/accessing/ArrayObjectNodes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ protected static final void doArrayOfChars(final ArrayObject obj, final long ind
492492
@Specialization(guards = {"obj.isCharType()", "isCharNilTag(value)"})
493493
protected static final void doArrayOfCharsNilTagClash(final Node node, final ArrayObject obj, final long index, final char value,
494494
@Shared("isNilTagProfile") @Cached final InlinedConditionProfile isNilTagProfile) {
495-
/** `value` happens to be char nil tag, need to despecialize to be able store it. */
495+
/** `value` happens to be char nil tag, need to despecialize to be able to store it. */
496496
obj.transitionFromCharsToObjects(isNilTagProfile, node);
497497
doArrayOfObjects(obj, index, value);
498498
}
@@ -517,7 +517,7 @@ protected static final void doArrayOfLongs(final ArrayObject obj, final long ind
517517
@Specialization(guards = {"obj.isLongType()", "isLongNilTag(value)"})
518518
protected static final void doArrayOfLongsNilTagClash(final Node node, final ArrayObject obj, final long index, final long value,
519519
@Shared("isNilTagProfile") @Cached final InlinedConditionProfile isNilTagProfile) {
520-
/** `value` happens to be long nil tag, need to despecialize to be able store it. */
520+
/** `value` happens to be long nil tag, need to despecialize to be able to store it. */
521521
obj.transitionFromLongsToObjects(isNilTagProfile, node);
522522
doArrayOfObjects(obj, index, value);
523523
}
@@ -542,7 +542,7 @@ protected static final void doArrayOfDoubles(final ArrayObject obj, final long i
542542
@Specialization(guards = {"obj.isDoubleType()", "isDoubleNilTag(value)"})
543543
protected static final void doArrayOfDoublesNilTagClash(final Node node, final ArrayObject obj, final long index, final double value,
544544
@Shared("isNilTagProfile") @Cached final InlinedConditionProfile isNilTagProfile) {
545-
// `value` happens to be double nil tag, need to despecialize to be able store it.
545+
// `value` happens to be double nil tag, need to despecialize to be able to store it.
546546
obj.transitionFromDoublesToObjects(isNilTagProfile, node);
547547
doArrayOfObjects(obj, index, value);
548548
}

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/dispatch/ResolveMethodNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected static final CompiledCodeObject doObjectAsMethod(final Node node, fina
5252
return method;
5353
} else {
5454
assert runWithInMethod == null : "runWithInMethod should not be another Object";
55-
return doDoesNotUnderstand(image, targetObjectClass, runWithInMethod);
55+
return doDoesNotUnderstand(image, targetObjectClass, null);
5656
}
5757
}
5858

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/plugins/B2D.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,11 +1304,7 @@ private void computeFinalWideBezierValueswidth(final int bezier, final int lineW
13041304
rightX = temp;
13051305
}
13061306
edgeXValueOfput(bezier, leftX);
1307-
if (rightX - leftX > lineWidth) {
1308-
wideBezierWidthOfput(bezier, rightX - leftX);
1309-
} else {
1310-
wideBezierWidthOfput(bezier, lineWidth);
1311-
}
1307+
wideBezierWidthOfput(bezier, Math.max(rightX - leftX, lineWidth));
13121308
}
13131309

13141310
/* BalloonEngineBase>>#computeSqrt: */
@@ -2497,16 +2493,8 @@ private boolean fillSpanfromto(final int fill, final int leftX, final int rightX
24972493
}
24982494
int x0;
24992495
int x1;
2500-
if (leftX < spanEndAAGet()) {
2501-
x0 = spanEndAAGet();
2502-
} else {
2503-
x0 = leftX;
2504-
}
2505-
if (rightX > shl(spanSizeGet(), aaShiftGet())) {
2506-
x1 = shl(spanSizeGet(), aaShiftGet());
2507-
} else {
2508-
x1 = rightX;
2509-
}
2496+
x0 = Math.max(leftX, spanEndAAGet());
2497+
x1 = Math.min(rightX, shl(spanSizeGet(), aaShiftGet()));
25102498
if (x0 < fillMinXGet()) {
25112499
x0 = fillMinXGet();
25122500
}
@@ -5695,7 +5683,7 @@ private void quickSortGlobalEdgeTablefromto(final int[] array, final int i, fina
56955683
di = dj;
56965684
dj = tt;
56975685
}
5698-
if (n <= 2) {
5686+
if (n == 2) {
56995687
return;
57005688
}
57015689
/* ij is the midpoint of i and j. */
@@ -5721,7 +5709,7 @@ private void quickSortGlobalEdgeTablefromto(final int[] array, final int i, fina
57215709
array[ij] = tmp;
57225710
dij = di;
57235711
}
5724-
if (n <= 3) {
5712+
if (n == 3) {
57255713
return;
57265714
}
57275715
int k = i;

0 commit comments

Comments
 (0)