Skip to content

Commit 17bc18d

Browse files
committed
Use single context assumption in DeleteClassAttributeNode
1 parent 72f469a commit 17bc18d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -78,7 +78,16 @@ Object getLocalsDict(VirtualFrame frame) {
7878
return null;
7979
}
8080

81-
@Specialization(guards = "localsDict != null")
81+
@Specialization(guards = {"localsDict != null", "getLocalsDict(frame) == localsDict"}, //
82+
assumptions = "singleContextAssumption()", limit = "2")
83+
void deleteFromLocalsSingleCtx(VirtualFrame frame,
84+
@Cached(value = "getLocalsDict(frame)", weak = true) Object localsDict,
85+
@Cached("create()") DeleteItemNode delItemNode) {
86+
// class namespace overrides closure
87+
delItemNode.executeWith(frame, localsDict, identifier);
88+
}
89+
90+
@Specialization(guards = "localsDict != null", replaces = "deleteFromLocalsSingleCtx")
8291
void deleteFromLocals(VirtualFrame frame,
8392
@Bind("getLocalsDict(frame)") Object localsDict,
8493
@Cached("create()") DeleteItemNode delItemNode) {
@@ -87,8 +96,8 @@ void deleteFromLocals(VirtualFrame frame,
8796
}
8897

8998
@Specialization(guards = "localsDict == null")
90-
void delete(VirtualFrame frame,
91-
@Bind("getLocalsDict(frame)") Object localsDict,
99+
void deleteSingleCtx(VirtualFrame frame,
100+
@SuppressWarnings("unused") @Bind("getLocalsDict(frame)") Object localsDict,
92101
@Cached("createDeleteNsItem()") StatementNode deleteNsItem) {
93102
// delete attribute actual attribute
94103
deleteNsItem.executeVoid(frame);

0 commit comments

Comments
 (0)