Skip to content

Commit 9cad5fd

Browse files
qunaibitsteve-s
authored andcommitted
Folding a specialization and tag a class with ValueType
1 parent d929828 commit 9cad5fd

File tree

1 file changed

+6
-15
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common

1 file changed

+6
-15
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/HashingStorage.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import com.oracle.graal.python.runtime.sequence.PSequence;
7777
import com.oracle.graal.python.util.ArrayBuilder;
7878
import com.oracle.truffle.api.Assumption;
79+
import com.oracle.truffle.api.CompilerDirectives.ValueType;
7980
import com.oracle.truffle.api.Truffle;
8081
import com.oracle.truffle.api.dsl.Bind;
8182
import com.oracle.truffle.api.dsl.Cached;
@@ -154,27 +155,16 @@ HashingStorage doPDictKwargs(VirtualFrame frame, PHashingCollection iterable, PK
154155
}
155156
}
156157

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) {
171159
Object attr = lookupIter.execute(getClassNode.execute(inliningTarget, col));
172160
return attr != PNone.NO_VALUE && !(attr instanceof PBuiltinMethod || attr instanceof PBuiltinFunction);
173161
}
174162

175-
@Specialization(guards = {"!isNoValue(arg)", "!isPDict(arg)"})
163+
@Specialization(guards = {"!isNoValue(arg)", "!isPDict(arg) || hasIterAttrButNotBuiltin(inliningTarget, arg, getClassNode, lookupIter)"})
176164
static HashingStorage updateArg(VirtualFrame frame, Object arg, PKeyword[] kwargs,
177165
@Bind("this") Node inliningTarget,
166+
@SuppressWarnings("unused") @Exclusive @Cached GetClassNode getClassNode,
167+
@SuppressWarnings("unused") @Exclusive @Cached(parameters = "Iter") LookupCallableSlotInMRONode lookupIter,
178168
@Exclusive @Cached PyObjectLookupAttr lookupKeysAttributeNode,
179169
@Exclusive @Cached ObjectToArrayPairNode toArrayPair,
180170
@Exclusive @Cached HashingStorageSetItem setHasihngStorageItem,
@@ -216,6 +206,7 @@ public static HashingStorage addKeywordsToStorage(VirtualFrame frame, PKeyword[]
216206
return storage;
217207
}
218208

209+
@ValueType
219210
protected static final class KeyValue {
220211
final Object key;
221212
final Object value;

0 commit comments

Comments
 (0)