Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Nov 3, 2023
1 parent 7b34237 commit f535683
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ public long toWord(final Object object) {
return toTaggedSmallInteger((long) object);
} else if (object instanceof Double) {
return toTaggedSmallFloat((double) object);
} else if (object instanceof AbstractSqueakObject) {
final Long oop = oopMap.get(object);
} else if (object instanceof AbstractSqueakObject aso) {
final Long oop = oopMap.get(aso);
if (oop != null) {
return oop;
} else {
image.printToStdErr("Unreserved object detected: " + object + ". Replacing with nil.");
image.printToStdErr("Unreserved object detected: " + aso + ". Replacing with nil.");
return nilOop;
}
} else {
Expand Down Expand Up @@ -384,7 +384,7 @@ public void writeObjects(final Object[] objects) {
}

public void writeObjectIfTracedElseNil(final Object object) {
writeLong(toWord(oopMap.containsKey(object) ? object : NilObject.SINGLETON));
writeLong(toWord(object instanceof AbstractSqueakObject aso && oopMap.containsKey(aso) ? object : NilObject.SINGLETON));
}

private static long toTaggedCharacter(final long value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ private void recordMouseEvent(final MOUSE_EVENT type, final MouseEvent e) {
case DOWN -> mapButton(e);
case MOVE -> display.buttons & MOUSE.ALL;
case UP -> 0;
default -> {
LogUtils.IO.warning("Unknown mouse event: " + e);
yield display.buttons & MOUSE.ALL;
}
};
display.buttons = buttons | display.recordModifiers(e);
display.addEvent(EVENT_TYPE.MOUSE, e.getX(), e.getY(), display.buttons & MOUSE.ALL, display.buttons >> 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@ public Object[] getObjectStorage() {
return (Object[]) storage;
}

public Class<?> getStorageType() {
return storage.getClass();
}

@Override
public int instsize() {
return 0;
Expand Down Expand Up @@ -242,10 +238,6 @@ public boolean isObjectType() {
return storage instanceof Object[];
}

public boolean isTraceable() {
return isObjectType();
}

public boolean hasSameStorageType(final ArrayObject other) {
return storage.getClass() == other.storage.getClass();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,7 @@ public NativeObject getCompiledInSelector() {
final Object penultimateLiteral = literals[literals.length - 2];
if (penultimateLiteral instanceof final NativeObject o) {
return o;
} else if (penultimateLiteral instanceof final VariablePointersObject o) {
final VariablePointersObject penultimateLiteralAsPointer = o;
} else if (penultimateLiteral instanceof final VariablePointersObject penultimateLiteralAsPointer) {
assert penultimateLiteralAsPointer.size() >= ADDITIONAL_METHOD_STATE.SELECTOR;
return (NativeObject) penultimateLiteralAsPointer.instVarAt0Slow(ADDITIONAL_METHOD_STATE.SELECTOR);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ public abstract static class VariablePointersObjectReadNode extends Node {

public abstract Object execute(VariablePointersObject object, long index);

public abstract ArrayObject executeArray(VariablePointersObject object, long index);

@Specialization(guards = {"cachedIndex == index", "object.getLayout() == cachedLayout", "cachedIndex < cachedLayout.getInstSize()"}, //
assumptions = "cachedLayout.getValidAssumption()", limit = "CACHE_LIMIT")
protected static final Object doReadCached(final VariablePointersObject object, @SuppressWarnings("unused") final long index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ protected PrimFillFromToWithNode(final CompiledCodeObject code, final int index)

@Override
public void executeVoid(final VirtualFrame frame) {
final Object value = (long) pop4Node.execute(frame);
final Object value = pop4Node.execute(frame);
final long to = (long) pop3Node.execute(frame);
final long from = (long) pop2Node.execute(frame);
final Object receiver = pop1Node.execute(frame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,6 @@ private static AbstractSqueakObject getStringPropertyValue(final SqueakImageCont
case PEER_NAME -> image.asByteString(impl.peerName);
case CERTIFICATE_NAME -> NilObject.SINGLETON; // FIXME
case SERVER_NAME -> image.asByteString(impl.serverName);
default -> NilObject.SINGLETON;
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ContextPrimitives extends AbstractPrimitiveFactoryHolder {
protected abstract static class PrimStoreStackPointerNode extends AbstractPrimitiveNode implements BinaryPrimitiveFallback {
@Specialization(guards = {"0 <= newStackPointer", "newStackPointer <= LARGE_FRAMESIZE"})
protected static final ContextObject store(final ContextObject receiver, final long newStackPointer) {
/**
/*
* Not need to "nil any newly accessible cells" as cells are always nil-initialized and
* their values are cleared (overwritten with nil) on stack pop.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ protected abstract static class PrimStoreImageSegmentNode extends AbstractPrimit
@SuppressWarnings("unused")
@Specialization(guards = "segmentWordArray.isIntType()")
protected static final Object doStore(final Object receiver, final ArrayObject rootsArray, final NativeObject segmentWordArray, final ArrayObject outPointerArray) {
/**
/*
* TODO: implement primitive. In the meantime, pretend this primitive succeeds so that
* some tests (e.g. BitmapStreamTests) run quickly.
*/
Expand All @@ -167,7 +167,7 @@ protected abstract static class PrimLoadImageSegmentNode extends AbstractPrimiti
@SuppressWarnings("unused")
@Specialization(guards = "segmentWordArray.isIntType()")
protected static final ArrayObject doLoad(final Object receiver, final NativeObject segmentWordArray, final ArrayObject outPointerArray) {
/**
/*
* TODO: implement primitive. In the meantime, pretend this primitive succeeds so that
* some tests (e.g. BitmapStreamTests) run quickly.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.oracle.truffle.api.frame.FrameInstance;

import de.hpi.swa.trufflesqueak.image.SqueakImageContext;
import de.hpi.swa.trufflesqueak.model.AbstractPointersObject;
import de.hpi.swa.trufflesqueak.model.ArrayObject;
import de.hpi.swa.trufflesqueak.model.CompiledCodeObject;
import de.hpi.swa.trufflesqueak.model.ContextObject;
Expand Down Expand Up @@ -90,8 +89,7 @@ public static void dumpThreads(final StringBuilder sb) {
final Thread.State ts = info.getThreadState();
switch (ts) {
case BLOCKED -> sb.append("\t- blocked on ").append(info.getLockInfo()).append("\r\n");
case WAITING -> sb.append("\t- waiting on ").append(info.getLockInfo()).append("\r\n");
case TIMED_WAITING -> sb.append("\t- waiting on ").append(info.getLockInfo()).append("\r\n");
case WAITING, TIMED_WAITING -> sb.append("\t- waiting on ").append(info.getLockInfo()).append("\r\n");
default -> {
}
}
Expand Down Expand Up @@ -188,8 +186,7 @@ public static void printSqStackTrace(final ContextObject context) {

private static void printSemaphoreOrNil(final StringBuilder b, final String label, final Object semaphoreOrNil, final boolean printIfNil) {
if (semaphoreOrNil instanceof final PointersObject semaphore) {
b.append(label).append(Integer.toHexString(semaphore.hashCode())).append(" with ").append(((AbstractPointersObject) semaphore).instVarAt0Slow(SEMAPHORE.EXCESS_SIGNALS)).append(
" excess signals");
b.append(label).append(Integer.toHexString(semaphore.hashCode())).append(" with ").append(semaphore.instVarAt0Slow(SEMAPHORE.EXCESS_SIGNALS)).append(" excess signals");
if (!printLinkedList(b, "", semaphore)) {
b.append(" and no processes\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public static String findSqueakOSName() {
case macOS -> "Mac OS";
case Windows -> "Win32";
case Linux -> "unix";
default -> throw SqueakException.create("Unsupported Platform.");
};
}

Expand Down

0 comments on commit f535683

Please sign in to comment.