Skip to content

Commit 31c80e7

Browse files
authored
Ensure findOrAddAuxiliarySlot is not called during compilation (#969)
Fixes an issue that is preventing the native executable from building
1 parent 50cfb1c commit 31c80e7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,9 +2538,17 @@ public TypeNode initWriteSlotNode(int slot) {
25382538

25392539
@ExplodeLoop
25402540
protected Object executeLazily(VirtualFrame frame, Object value) {
2541-
var customThisSlot =
2542-
frame.getFrameDescriptor().findOrAddAuxiliarySlot(CustomThisScope.FRAME_SLOT_ID);
2543-
2541+
int customThisSlot;
2542+
var numberOfAuxiliarySlots = frame.getFrameDescriptor().getNumberOfAuxiliarySlots();
2543+
if (numberOfAuxiliarySlots == 0) {
2544+
CompilerDirectives.transferToInterpreterAndInvalidate();
2545+
customThisSlot =
2546+
frame.getFrameDescriptor().findOrAddAuxiliarySlot(CustomThisScope.FRAME_SLOT_ID);
2547+
} else {
2548+
// assertion: we only use auxiliary slots for custom `this`.
2549+
assert numberOfAuxiliarySlots == 1;
2550+
customThisSlot = 0;
2551+
}
25442552
var ret = childNode.executeLazily(frame, value);
25452553

25462554
var localContext = language.localContext.get();

0 commit comments

Comments
 (0)