|
65 | 65 | import static com.oracle.graal.python.nodes.HiddenAttributes.ID_KEY;
|
66 | 66 | import static com.oracle.graal.python.nodes.SpecialAttributeNames.__NAME__;
|
67 | 67 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__INSTANCECHECK__;
|
68 |
| -import static com.oracle.graal.python.nodes.SpecialMethodNames.__LEN__; |
69 | 68 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__NEXT__;
|
70 | 69 | import static com.oracle.graal.python.nodes.SpecialMethodNames.__SUBCLASSCHECK__;
|
71 | 70 | import static com.oracle.graal.python.runtime.exception.PythonErrorType.OverflowError;
|
|
142 | 141 | import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
|
143 | 142 | import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode;
|
144 | 143 | import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
|
145 |
| -import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.NoAttributeHandler; |
146 | 144 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
|
147 | 145 | import com.oracle.graal.python.nodes.control.GetIteratorExpressionNode.GetIteratorNode;
|
148 | 146 | import com.oracle.graal.python.nodes.control.GetNextNode;
|
@@ -1206,30 +1204,10 @@ public Object iter(Object callable, Object sentinel) {
|
1206 | 1204 | @Builtin(name = LEN, minNumOfPositionalArgs = 1)
|
1207 | 1205 | @GenerateNodeFactory
|
1208 | 1206 | public abstract static class LenNode extends PythonUnaryBuiltinNode {
|
1209 |
| - |
1210 |
| - private static final Supplier<NoAttributeHandler> NO_LEN = () -> new NoAttributeHandler() { |
1211 |
| - @Child private PRaiseNode raiseNode; |
1212 |
| - |
1213 |
| - @Override |
1214 |
| - public Object execute(Object receiver) { |
1215 |
| - if (raiseNode == null) { |
1216 |
| - CompilerDirectives.transferToInterpreterAndInvalidate(); |
1217 |
| - raiseNode = insert(PRaiseNode.create()); |
1218 |
| - } |
1219 |
| - throw raiseNode.raise(TypeError, "object of type '%p' has no len()", receiver); |
1220 |
| - } |
1221 |
| - }; |
1222 |
| - |
1223 |
| - public abstract Object executeWith(VirtualFrame frame, Object object); |
1224 |
| - |
1225 |
| - protected static LookupAndCallUnaryNode createLen() { |
1226 |
| - return LookupAndCallUnaryNode.create(__LEN__, NO_LEN); |
1227 |
| - } |
1228 |
| - |
1229 |
| - @Specialization |
1230 |
| - public Object len(VirtualFrame frame, Object obj, |
1231 |
| - @Cached("createLen()") LookupAndCallUnaryNode dispatch) { |
1232 |
| - return dispatch.executeObject(frame, obj); |
| 1207 | + @Specialization(limit = "getCallSiteInlineCacheMaxDepth()") |
| 1208 | + public int len(VirtualFrame frame, Object obj, |
| 1209 | + @CachedLibrary("obj") PythonObjectLibrary lib) { |
| 1210 | + return lib.lengthWithState(obj, PArguments.getThreadState(frame)); |
1233 | 1211 | }
|
1234 | 1212 | }
|
1235 | 1213 |
|
|
0 commit comments