Skip to content

Commit a870da7

Browse files
committed
Set slot kind
1 parent fbc81d1 commit a870da7

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/StartContextRootNode.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import com.oracle.truffle.api.CompilerAsserts;
1111
import com.oracle.truffle.api.CompilerDirectives;
1212
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
13+
import com.oracle.truffle.api.frame.FrameDescriptor;
14+
import com.oracle.truffle.api.frame.FrameSlotKind;
1315
import com.oracle.truffle.api.frame.VirtualFrame;
1416
import com.oracle.truffle.api.nodes.ExplodeLoop;
1517
import com.oracle.truffle.api.nodes.NodeInfo;
@@ -29,12 +31,14 @@
2931
import de.hpi.swa.trufflesqueak.nodes.interrupts.CheckForInterruptsQuickNode;
3032
import de.hpi.swa.trufflesqueak.shared.SqueakLanguageConfig;
3133
import de.hpi.swa.trufflesqueak.util.FrameAccess;
34+
import de.hpi.swa.trufflesqueak.util.MiscUtils;
3235

3336
@NodeInfo(language = SqueakLanguageConfig.ID)
3437
public final class StartContextRootNode extends AbstractRootNode {
3538
@CompilationFinal private int initialPC;
3639
@CompilationFinal private int initialSP;
37-
@CompilationFinal private int numArgs;
40+
@CompilationFinal private byte numTempSlots;
41+
@CompilationFinal private byte tempStackSlotStartIndex;
3842
@CompilationFinal private Assumption doesNotNeedThisContext;
3943

4044
@Child private CheckForInterruptsQuickNode interruptHandlerNode;
@@ -76,7 +80,7 @@ public Object execute(final VirtualFrame frame) {
7680
private void ensureInitialized(final VirtualFrame frame) {
7781
if (doesNotNeedThisContext == null) {
7882
CompilerDirectives.transferToInterpreterAndInvalidate();
79-
numArgs = FrameAccess.getNumArguments(frame);
83+
final int numArgs = FrameAccess.getNumArguments(frame);
8084
final CompiledCodeObject code = getCode();
8185
doesNotNeedThisContext = code.getDoesNotNeedThisContextAssumption();
8286
if (!FrameAccess.hasClosure(frame)) {
@@ -89,6 +93,8 @@ private void ensureInitialized(final VirtualFrame frame) {
8993
initialSP = closure.getNumTemps();
9094
assert numArgs == closure.getNumArgs() + closure.getNumCopied();
9195
}
96+
numTempSlots = MiscUtils.toByteExact(initialSP - numArgs);
97+
tempStackSlotStartIndex = MiscUtils.toByteExact(FrameAccess.toStackSlotIndex(frame, numArgs));
9298
}
9399
}
94100

@@ -102,9 +108,11 @@ private void initializeFrame(final VirtualFrame frame) {
102108

103109
// TODO: avoid nilling out of temp slots to allow slot specializations
104110
// Initialize remaining temporary variables with nil in newContext.
105-
for (int i = 0; i < initialSP - numArgs; i++) {
106-
final int stackSlotIndex = FrameAccess.toStackSlotIndex(frame, numArgs + i);
107-
frame.setObject(stackSlotIndex, NilObject.SINGLETON);
111+
final FrameDescriptor descriptor = frame.getFrameDescriptor();
112+
for (int i = 0; i < numTempSlots; i++) {
113+
final int slotIndex = tempStackSlotStartIndex + i;
114+
descriptor.setSlotKind(slotIndex, FrameSlotKind.Object);
115+
frame.setObject(slotIndex, NilObject.SINGLETON);
108116
}
109117
}
110118

src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/util/MiscUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,11 @@ public static byte[] toBytes(final String value) {
324324
return value.getBytes();
325325
}
326326

327+
public static byte toByteExact(final int value) {
328+
assert (byte) value == value;
329+
return (byte) value;
330+
}
331+
327332
/** Similar to {@link Math#toIntExact(long)}, but uses an assertion. */
328333
public static int toIntExact(final long value) {
329334
assert (int) value == value;

0 commit comments

Comments
 (0)