|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * The Universal Permissive License (UPL), Version 1.0
|
|
78 | 78 | import com.oracle.graal.python.runtime.object.PythonObjectFactory;
|
79 | 79 | import com.oracle.truffle.api.dsl.Bind;
|
80 | 80 | import com.oracle.truffle.api.dsl.Cached;
|
81 |
| -import com.oracle.truffle.api.dsl.Cached.Shared; |
82 | 81 | import com.oracle.truffle.api.dsl.GenerateNodeFactory;
|
83 | 82 | import com.oracle.truffle.api.dsl.ImportStatic;
|
84 | 83 | import com.oracle.truffle.api.dsl.NeverDefault;
|
@@ -144,27 +143,21 @@ static Object iter(PTee self) {
|
144 | 143 | @Builtin(name = J___NEXT__, minNumOfPositionalArgs = 1)
|
145 | 144 | @GenerateNodeFactory
|
146 | 145 | public abstract static class NextNode extends PythonUnaryBuiltinNode {
|
147 |
| - @Specialization(guards = "self.getIndex() < LINKCELLS") |
148 |
| - static Object next(VirtualFrame frame, PTee self, |
| 146 | + @Specialization |
| 147 | + static Object doIt(VirtualFrame frame, PTee self, |
149 | 148 | @Bind("this") Node inliningTarget,
|
150 |
| - @Shared @Cached BuiltinFunctions.NextNode nextNode, |
151 |
| - @Shared @Cached PRaiseNode.Lazy raiseNode) { |
| 149 | + @Cached PythonObjectFactory factory, |
| 150 | + @Cached InlinedConditionProfile indexConditionProfile, |
| 151 | + @Cached BuiltinFunctions.NextNode nextNode, |
| 152 | + @Cached PRaiseNode.Lazy raiseNode) { |
| 153 | + if (indexConditionProfile.profile(inliningTarget, self.getIndex() >= LINKCELLS)) { |
| 154 | + self.setDataObj(self.getDataobj().jumplink(factory)); |
| 155 | + self.setIndex(0); |
| 156 | + } |
152 | 157 | Object value = self.getDataobj().getItem(frame, inliningTarget, self.getIndex(), nextNode, raiseNode);
|
153 | 158 | self.setIndex(self.getIndex() + 1);
|
154 | 159 | return value;
|
155 | 160 | }
|
156 |
| - |
157 |
| - @Specialization(guards = "self.getIndex() >= LINKCELLS") |
158 |
| - static Object nextNext(VirtualFrame frame, PTee self, |
159 |
| - @Bind("this") Node inliningTarget, |
160 |
| - @Shared @Cached BuiltinFunctions.NextNode nextNode, |
161 |
| - @Cached PythonObjectFactory factory, |
162 |
| - @Shared @Cached PRaiseNode.Lazy raiseNode) { |
163 |
| - self.setDataObj(self.getDataobj().jumplink(factory)); |
164 |
| - Object value = self.getDataobj().getItem(frame, inliningTarget, 0, nextNode, raiseNode); |
165 |
| - self.setIndex(1); |
166 |
| - return value; |
167 |
| - } |
168 | 161 | }
|
169 | 162 |
|
170 | 163 | @Builtin(name = J___REDUCE__, minNumOfPositionalArgs = 1)
|
|
0 commit comments