|
76 | 76 | import com.oracle.graal.python.runtime.sequence.PSequence; |
77 | 77 | import com.oracle.graal.python.util.ArrayBuilder; |
78 | 78 | import com.oracle.truffle.api.Assumption; |
| 79 | +import com.oracle.truffle.api.CompilerDirectives.ValueType; |
79 | 80 | import com.oracle.truffle.api.Truffle; |
80 | 81 | import com.oracle.truffle.api.dsl.Bind; |
81 | 82 | import com.oracle.truffle.api.dsl.Cached; |
@@ -154,27 +155,16 @@ HashingStorage doPDictKwargs(VirtualFrame frame, PHashingCollection iterable, PK |
154 | 155 | } |
155 | 156 | } |
156 | 157 |
|
157 | | - @Specialization(guards = "hasIterAttrButNotBuiltin(inliningTarget, col, getClassNode, lookupIter)", limit = "1") |
158 | | - static HashingStorage doNoBuiltinKeysAttr(VirtualFrame frame, PHashingCollection col, @SuppressWarnings("unused") PKeyword[] kwargs, |
159 | | - @Bind("this") Node inliningTarget, |
160 | | - @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, |
161 | | - @SuppressWarnings("unused") @Exclusive @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter, |
162 | | - @Exclusive @Cached PyObjectLookupAttr lookupKeysAttributeNode, |
163 | | - @Exclusive @Cached ObjectToArrayPairNode toArrayPair, |
164 | | - @Exclusive @Cached HashingStorageSetItem setHasihngStorageItem, |
165 | | - @Exclusive @Cached HashingStorageAddAllToOther addAllToOther) { |
166 | | - return updateArg(frame, col, kwargs, inliningTarget, lookupKeysAttributeNode, |
167 | | - toArrayPair, setHasihngStorageItem, addAllToOther); |
168 | | - } |
169 | | - |
170 | | - protected static boolean hasIterAttrButNotBuiltin(Node inliningTarget, PHashingCollection col, GetClassNode getClassNode, LookupCallableSlotInMRONode lookupIter) { |
| 158 | + protected static boolean hasIterAttrButNotBuiltin(Node inliningTarget, Object col, GetClassNode getClassNode, LookupCallableSlotInMRONode lookupIter) { |
171 | 159 | Object attr = lookupIter.execute(getClassNode.execute(inliningTarget, col)); |
172 | 160 | return attr != PNone.NO_VALUE && !(attr instanceof PBuiltinMethod || attr instanceof PBuiltinFunction); |
173 | 161 | } |
174 | 162 |
|
175 | | - @Specialization(guards = {"!isNoValue(arg)", "!isPDict(arg)"}) |
| 163 | + @Specialization(guards = {"!isNoValue(arg)", "!isPDict(arg) || hasIterAttrButNotBuiltin(inliningTarget, arg, getClassNode, lookupIter)"}) |
176 | 164 | static HashingStorage updateArg(VirtualFrame frame, Object arg, PKeyword[] kwargs, |
177 | 165 | @Bind("this") Node inliningTarget, |
| 166 | + @SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode, |
| 167 | + @SuppressWarnings("unused") @Exclusive @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter, |
178 | 168 | @Exclusive @Cached PyObjectLookupAttr lookupKeysAttributeNode, |
179 | 169 | @Exclusive @Cached ObjectToArrayPairNode toArrayPair, |
180 | 170 | @Exclusive @Cached HashingStorageSetItem setHasihngStorageItem, |
@@ -216,6 +206,7 @@ public static HashingStorage addKeywordsToStorage(VirtualFrame frame, PKeyword[] |
216 | 206 | return storage; |
217 | 207 | } |
218 | 208 |
|
| 209 | + @ValueType |
219 | 210 | protected static final class KeyValue { |
220 | 211 | final Object key; |
221 | 212 | final Object value; |
|
0 commit comments