Skip to content

Commit 60645c8

Browse files
msimacektomasstupka
authored andcommitted
Correctly differentiate custom locals in frame materialization
1 parent 90fdb14 commit 60645c8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/MaterializeFrameNode.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ static void doLocalsStorageUncachedAST(PFrame pyFrame, Frame frameToSync, @Suppr
344344
@Specialization(guards = { //
345345
"!isBytecodeFrame(frameToSync)",
346346
"isDictWithCustomStorage(pyFrame)",
347+
"!hasCustomLocals(frameToSync, pyFrame)",
347348
"frameToSync.getFrameDescriptor() == cachedFd",
348349
}, //
349350
limit = "1")
@@ -389,7 +390,7 @@ static void doGenericDictCachedAST(VirtualFrame frame, PFrame pyFrame, Frame fra
389390
}
390391
}
391392

392-
@Specialization(guards = {"!isBytecodeFrame(frameToSync)", "isDictWithCustomStorage(pyFrame)"}, replaces = "doGenericDictCachedAST")
393+
@Specialization(guards = {"!isBytecodeFrame(frameToSync)", "isDictWithCustomStorage(pyFrame)", "!hasCustomLocals(frameToSync, pyFrame)"}, replaces = "doGenericDictCachedAST")
393394
static void doGenericDictAST(VirtualFrame frame, PFrame pyFrame, Frame frameToSync, @SuppressWarnings("unused") Node location,
394395
@Cached HashingCollectionNodes.SetItemNode setItemNode,
395396
@Cached BranchProfile updatedStorage,
@@ -474,6 +475,7 @@ static void doLocalsStorageUncached(PFrame pyFrame, Frame frameToSync, @Suppress
474475
@Specialization(guards = { //
475476
"isBytecodeFrame(frameToSync)",
476477
"isDictWithCustomStorage(pyFrame)",
478+
"!hasCustomLocals(frameToSync, pyFrame)",
477479
"frameToSync.getFrameDescriptor() == cachedFd",
478480
"variableSlotCount(cachedFd) < 32"
479481
}, limit = "1")
@@ -501,6 +503,7 @@ static void doGenericDictCachedExploded(VirtualFrame frame, PFrame pyFrame, Fram
501503
@Specialization(guards = { //
502504
"isBytecodeFrame(frameToSync)",
503505
"isDictWithCustomStorage(pyFrame)",
506+
"!hasCustomLocals(frameToSync, pyFrame)",
504507
"frameToSync.getFrameDescriptor() == cachedFd",
505508
}, limit = "1", replaces = "doGenericDictCachedExploded")
506509
static void doGenericDictCachedLoop(VirtualFrame frame, PFrame pyFrame, Frame frameToSync, @SuppressWarnings("unused") Node location,
@@ -523,7 +526,8 @@ static void doGenericDictCachedLoop(VirtualFrame frame, PFrame pyFrame, Frame fr
523526
}
524527
}
525528

526-
@Specialization(guards = {"isBytecodeFrame(frameToSync)", "isDictWithCustomStorage(pyFrame)"}, replaces = {"doGenericDictCachedExploded", "doGenericDictCachedLoop"})
529+
@Specialization(guards = {"isBytecodeFrame(frameToSync)", "isDictWithCustomStorage(pyFrame)", "!hasCustomLocals(frameToSync, pyFrame)"}, replaces = {"doGenericDictCachedExploded",
530+
"doGenericDictCachedLoop"})
527531
static void doGenericDict(VirtualFrame frame, PFrame pyFrame, Frame frameToSync, @SuppressWarnings("unused") Node location,
528532
@Cached BranchProfile updatedStorage,
529533
@Cached ConditionProfile hasFrame,
@@ -542,7 +546,7 @@ static void doGenericDict(VirtualFrame frame, PFrame pyFrame, Frame frameToSync,
542546
}
543547
}
544548

545-
@Specialization(guards = "!isDictWithCustomStorage(pyFrame)")
549+
@Specialization(guards = "hasCustomLocals(frameToSync, pyFrame)")
546550
@SuppressWarnings("unused")
547551
static void doCustomLocalsObject(PFrame pyFrame, Frame frameToSync, Node location) {
548552
// nothing to do; we already worked on the custom object
@@ -611,6 +615,10 @@ protected static boolean isDictWithCustomStorage(PFrame pyFrame) {
611615
return localsObject instanceof PDict && PGuards.isBuiltinDict((PDict) localsObject);
612616
}
613617

618+
protected static boolean hasCustomLocals(Frame frameToSync, PFrame pyFrame) {
619+
return PArguments.getSpecialArgument(frameToSync) == pyFrame.getLocalsDict();
620+
}
621+
614622
protected static LocalsStorage getLocalsStorage(PFrame pyFrame) {
615623
return (LocalsStorage) ((PDict) pyFrame.getLocalsDict()).getDictStorage();
616624
}

0 commit comments

Comments
 (0)