Skip to content

Commit a0e3a13

Browse files
committed
DeleteClassAttributeNode: do not cache locals dict
1 parent 99a477d commit a0e3a13

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/classes/DeleteClassAttributeNode.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.oracle.graal.python.nodes.argument.ReadIndexedArgumentNode;
4747
import com.oracle.graal.python.nodes.statement.StatementNode;
4848
import com.oracle.graal.python.nodes.subscript.DeleteItemNode;
49+
import com.oracle.truffle.api.dsl.Bind;
4950
import com.oracle.truffle.api.dsl.Cached;
5051
import com.oracle.truffle.api.dsl.Specialization;
5152
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -55,12 +56,13 @@
5556
public abstract class DeleteClassAttributeNode extends StatementNode {
5657
private final String identifier;
5758

58-
@Child private StatementNode deleteNsItem;
59-
6059
DeleteClassAttributeNode(String identifier) {
6160
this.identifier = identifier;
61+
}
62+
63+
protected StatementNode createDeleteNsItem() {
6264
ReadIndexedArgumentNode namespace = ReadIndexedArgumentNode.create(0);
63-
this.deleteNsItem = PythonLanguage.getCurrent().getNodeFactory().createDeleteItem(namespace.asExpression(), this.identifier);
65+
return PythonLanguage.getCurrent().getNodeFactory().createDeleteItem(namespace.asExpression(), identifier);
6466
}
6567

6668
public static DeleteClassAttributeNode create(String name) {
@@ -77,15 +79,17 @@ Object getLocalsDict(VirtualFrame frame) {
7779
}
7880

7981
@Specialization(guards = "localsDict != null")
80-
void deleteFromLocals(@SuppressWarnings("unused") VirtualFrame frame,
81-
@Cached("getLocalsDict(frame)") Object localsDict,
82+
void deleteFromLocals(VirtualFrame frame,
83+
@Bind("getLocalsDict(frame)") Object localsDict,
8284
@Cached("create()") DeleteItemNode delItemNode) {
8385
// class namespace overrides closure
8486
delItemNode.executeWith(frame, localsDict, identifier);
8587
}
8688

87-
@Specialization
88-
void delete(VirtualFrame frame) {
89+
@Specialization(guards = "localsDict == null")
90+
void delete(VirtualFrame frame,
91+
@Bind("getLocalsDict(frame)") Object localsDict,
92+
@Cached("createDeleteNsItem()") StatementNode deleteNsItem) {
8993
// delete attribute actual attribute
9094
deleteNsItem.executeVoid(frame);
9195
}

0 commit comments

Comments
 (0)