Skip to content

Commit 36bbdc4

Browse files
committed
replace __len__ calls in DynamicObjectNativeWrapper
1 parent 8936679 commit 36bbdc4

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/DynamicObjectNativeWrapper.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
125125
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
126126
import com.oracle.graal.python.nodes.attributes.WriteAttributeToObjectNode;
127-
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.LookupAndCallUnaryDynamicNode;
128127
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
129128
import com.oracle.graal.python.nodes.object.GetClassNode;
130129
import com.oracle.graal.python.nodes.object.GetLazyClassNode;
@@ -601,24 +600,24 @@ Object doObBase(PString o, @SuppressWarnings("unused") String key,
601600
return toSulongNode.execute(o);
602601
}
603602

604-
@Specialization(guards = "eq(OB_SIZE, key)")
603+
@Specialization(guards = "eq(OB_SIZE, key)", limit = "getCallSiteInlineCacheMaxDepth()")
605604
long doObSize(Object object, @SuppressWarnings("unused") String key,
606-
@Exclusive @Cached LookupAndCallUnaryDynamicNode callLenNode) {
607-
Object res = callLenNode.executeObject(object, SpecialMethodNames.__LEN__);
608-
if (res instanceof Number) {
609-
return ((Number) res).intValue();
605+
@CachedLibrary("object") PythonObjectLibrary lib) {
606+
try {
607+
return lib.length(object);
608+
} catch (PException e) {
609+
return -1;
610610
}
611-
return -1;
612611
}
613612

614-
@Specialization(guards = "eq(MA_USED, key)")
613+
@Specialization(guards = "eq(MA_USED, key)", limit = "getCallSiteInlineCacheMaxDepth()")
615614
int doMaUsed(PDict object, @SuppressWarnings("unused") String key,
616-
@Exclusive @Cached LookupAndCallUnaryDynamicNode callLenNode) {
617-
Object res = callLenNode.executeObject(object, SpecialMethodNames.__LEN__);
618-
if (res instanceof Number) {
619-
return ((Number) res).intValue();
615+
@CachedLibrary("object") PythonObjectLibrary lib) {
616+
try {
617+
return lib.length(object);
618+
} catch (PException e) {
619+
return -1;
620620
}
621-
return -1;
622621
}
623622

624623
@Specialization(guards = "eq(OB_SVAL, key)")

0 commit comments

Comments
 (0)