diff --git a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/model/CompiledCodeObject.java b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/model/CompiledCodeObject.java index 36d13560a..a2c9ba938 100644 --- a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/model/CompiledCodeObject.java +++ b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/model/CompiledCodeObject.java @@ -18,8 +18,6 @@ import com.oracle.truffle.api.RootCallTarget; import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.frame.FrameDescriptor; -import com.oracle.truffle.api.frame.FrameDescriptor.Builder; -import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.source.Source; @@ -46,6 +44,7 @@ import de.hpi.swa.trufflesqueak.nodes.primitives.PrimitiveNodeFactory.ArgumentsLocation; import de.hpi.swa.trufflesqueak.shared.SqueakLanguageConfig; import de.hpi.swa.trufflesqueak.util.ArrayUtils; +import de.hpi.swa.trufflesqueak.util.FrameAccess; import de.hpi.swa.trufflesqueak.util.MiscUtils; import de.hpi.swa.trufflesqueak.util.ObjectGraphUtils.ObjectTracer; import de.hpi.swa.trufflesqueak.util.UnsafeUtils; @@ -270,13 +269,7 @@ public RootCallTarget getResumptionCallTarget(final ContextObject context) { public FrameDescriptor getFrameDescriptor() { if (frameDescriptor == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - final Builder builder = FrameDescriptor.newBuilder(); - builder.addSlot(FrameSlotKind.Object, null, null); // SLOT_IDENTIFIER.THIS_MARKER - builder.addSlot(FrameSlotKind.Illegal, null, null); // SLOT_IDENTIFIER.THIS_CONTEXT - builder.addSlot(FrameSlotKind.Int, null, null); // SLOT_IDENTIFIER.INSTRUCTION_POINTER - builder.addSlot(FrameSlotKind.Int, null, null); // SLOT_IDENTIFIER.STACK_POINTER - builder.addSlots(getSqueakContextSize(), FrameSlotKind.Illegal); - frameDescriptor = builder.build(); + frameDescriptor = FrameAccess.newFrameDescriptor(getSqueakContextSize()); } return frameDescriptor; } diff --git a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/util/FrameAccess.java b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/util/FrameAccess.java index 6da8b30ba..61c1e37cc 100644 --- a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/util/FrameAccess.java +++ b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/util/FrameAccess.java @@ -15,6 +15,7 @@ import com.oracle.truffle.api.Truffle; import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.FrameDescriptor.Builder; import com.oracle.truffle.api.frame.FrameInstance; import com.oracle.truffle.api.frame.FrameSlotKind; import com.oracle.truffle.api.frame.MaterializedFrame; @@ -97,6 +98,17 @@ private enum SlotIndicies { private FrameAccess() { } + /** Creates a new {@link FrameDescriptor} according to {@link SlotIndicies}. */ + public static FrameDescriptor newFrameDescriptor(final int squeakContextSize) { + final Builder builder = FrameDescriptor.newBuilder(); + builder.addSlot(FrameSlotKind.Static, null, null); // SlotIndicies.THIS_MARKER + builder.addSlot(FrameSlotKind.Illegal, null, null); // SlotIndicies.THIS_CONTEXT + builder.addSlot(FrameSlotKind.Static, null, null); // SlotIndicies.INSTRUCTION_POINTER + builder.addSlot(FrameSlotKind.Static, null, null); // SlotIndicies.STACK_POINTER + builder.addSlots(squeakContextSize, FrameSlotKind.Illegal); + return builder.build(); + } + public static CompiledCodeObject getCodeObject(final Frame frame) { return (CompiledCodeObject) frame.getArguments()[ArgumentIndicies.CODE_OBJECT.ordinal()]; } @@ -169,11 +181,11 @@ public static Object[] getReceiverAndArguments(final Frame frame) { } public static FrameMarker getMarker(final Frame frame) { - return (FrameMarker) frame.getObject(SlotIndicies.THIS_MARKER.ordinal()); + return (FrameMarker) frame.getObjectStatic(SlotIndicies.THIS_MARKER.ordinal()); } public static void setMarker(final Frame frame, final FrameMarker marker) { - frame.setObject(SlotIndicies.THIS_MARKER.ordinal(), marker); + frame.setObjectStatic(SlotIndicies.THIS_MARKER.ordinal(), marker); } public static void initializeMarker(final Frame frame) { @@ -206,19 +218,19 @@ public static void setContext(final Frame frame, final ContextObject context) { } public static int getInstructionPointer(final Frame frame) { - return frame.getInt(SlotIndicies.INSTRUCTION_POINTER.ordinal()); + return frame.getIntStatic(SlotIndicies.INSTRUCTION_POINTER.ordinal()); } public static void setInstructionPointer(final Frame frame, final int value) { - frame.setInt(SlotIndicies.INSTRUCTION_POINTER.ordinal(), value); + frame.setIntStatic(SlotIndicies.INSTRUCTION_POINTER.ordinal(), value); } public static int getStackPointer(final Frame frame) { - return frame.getInt(SlotIndicies.STACK_POINTER.ordinal()); + return frame.getIntStatic(SlotIndicies.STACK_POINTER.ordinal()); } public static void setStackPointer(final Frame frame, final int value) { - frame.setInt(SlotIndicies.STACK_POINTER.ordinal(), value); + frame.setIntStatic(SlotIndicies.STACK_POINTER.ordinal(), value); } public static int toStackSlotIndex(final Frame frame, final int index) {