diff --git a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/model/ContextObject.java b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/model/ContextObject.java index c4472f0bb..8faebef5a 100644 --- a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/model/ContextObject.java +++ b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/model/ContextObject.java @@ -67,7 +67,12 @@ private ContextObject(final ContextObject original) { final int numStackSlots = code.getNumStackSlots(); for (int i = 0; i < numStackSlots; i++) { final FrameSlot slot = code.getStackSlot(i); - FrameAccess.setStackSlot(truffleFrame, slot, original.truffleFrame.getValue(slot)); + final Object value = original.truffleFrame.getValue(slot); + if (value != null) { + FrameAccess.setStackSlot(truffleFrame, slot, value); + } else { + break; // This and all following slots are not in use. + } } } diff --git a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/ExecuteContextNode.java b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/ExecuteContextNode.java index fccf53123..804cdeb9a 100644 --- a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/ExecuteContextNode.java +++ b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/ExecuteContextNode.java @@ -107,9 +107,6 @@ protected final Object doVirtualized(final VirtualFrame frame, @SuppressWarnings @Fallback protected final Object doNonVirtualized(final VirtualFrame frame, final ContextObject context) { // maybe persist newContext, so there's no need to lookup the context to update its pc. - assert code == context.getBlockOrMethod(); - assert context.getMethod() == FrameAccess.getMethod(frame); - assert frame.getFrameDescriptor() == code.getFrameDescriptor(); try { triggerInterruptHandlerNode.executeGeneric(frame, code.hasPrimitive(), bytecodeNodes.length); final long initialPC = context.getInstructionPointerForBytecodeLoop(); diff --git a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/context/frame/FrameSlotWriteNode.java b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/context/frame/FrameSlotWriteNode.java index 36f3f2b44..e605be2cc 100644 --- a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/context/frame/FrameSlotWriteNode.java +++ b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/context/frame/FrameSlotWriteNode.java @@ -43,12 +43,10 @@ protected final void writeDouble(final Frame frame, final double value) { @Specialization(replaces = {"writeBool", "writeLong", "writeDouble"}) protected final void writeObject(final Frame frame, final Object value) { - assert !(value instanceof Byte || value instanceof Integer || value instanceof Float) : "Illegal write operation"; - /* Initialize type on first write. No-op if kind is already Object. */ frame.getFrameDescriptor().setFrameSlotKind(frameSlot, FrameSlotKind.Object); - assert value != null; + assert verifyWrite(value) : "Illegal write operation: " + value; frame.setObject(frameSlot, value); } @@ -66,4 +64,8 @@ protected final boolean isDoubleOrIllegal(final Frame frame) { final FrameSlotKind kind = frame.getFrameDescriptor().getFrameSlotKind(frameSlot); return kind == FrameSlotKind.Double || kind == FrameSlotKind.Illegal; } + + private static boolean verifyWrite(final Object value) { + return value != null && !(value instanceof Byte || value instanceof Integer || value instanceof Float); + } } diff --git a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/util/FrameAccess.java b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/util/FrameAccess.java index d75dac697..e39fc7314 100644 --- a/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/util/FrameAccess.java +++ b/src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/util/FrameAccess.java @@ -190,13 +190,14 @@ public static void setStackPointer(final Frame frame, final CompiledCodeObject c /** Write to a frame slot (slow operation), prefer {@link FrameStackWriteNode}. */ public static void setStackSlot(final Frame frame, final FrameSlot frameSlot, final Object value) { final FrameDescriptor frameDescriptor = frame.getFrameDescriptor(); - if (value instanceof Boolean) { + final Class valueClass = value.getClass(); + if (valueClass == Boolean.class) { frameDescriptor.setFrameSlotKind(frameSlot, FrameSlotKind.Boolean); frame.setBoolean(frameSlot, (boolean) value); - } else if (value instanceof Long) { + } else if (valueClass == Long.class) { frameDescriptor.setFrameSlotKind(frameSlot, FrameSlotKind.Long); frame.setLong(frameSlot, (long) value); - } else if (value instanceof Double) { + } else if (valueClass == Double.class) { frameDescriptor.setFrameSlotKind(frameSlot, FrameSlotKind.Double); frame.setDouble(frameSlot, (double) value); } else {