Skip to content

Commit efb6e88

Browse files
committed
Remove GetNextWithoutFrameNode
1 parent cf2fae2 commit efb6e88

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/keywords/CopyKeywordsNode.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@
6363
import com.oracle.truffle.api.dsl.GenerateUncached;
6464
import com.oracle.truffle.api.dsl.ImportStatic;
6565
import com.oracle.truffle.api.dsl.Specialization;
66+
import com.oracle.truffle.api.frame.VirtualFrame;
6667
import com.oracle.truffle.api.library.CachedLibrary;
6768
import com.oracle.truffle.api.nodes.Node;
69+
import com.oracle.truffle.api.profiles.ConditionProfile;
6870

6971
@ImportStatic(PythonOptions.class)
7072
@GenerateUncached
@@ -145,18 +147,23 @@ void doBuiltinDict(@SuppressWarnings("unused") PArguments.ThreadState state, PDi
145147

146148
@Specialization(guards = "!isBuiltinDict(starargs, classProfile)", limit = "getCallSiteInlineCacheMaxDepth()")
147149
void doDict(PArguments.ThreadState state, PDict starargs, PKeyword[] keywords,
148-
@Cached GetNextNode.GetNextWithoutFrameNode getNextNode,
150+
@Cached GetNextNode getNextNode,
149151
@Cached CastToJavaStringNode castToJavaStringNode,
150152
@Cached IsBuiltinClassProfile errorProfile,
151153
@CachedLibrary("starargs") PythonObjectLibrary pol,
152154
@Cached PRaiseNode raiseNode,
155+
@Cached ConditionProfile gotState,
153156
@SuppressWarnings("unused") @Cached IsBuiltinClassProfile classProfile) {
154157
Object iter = pol.getIteratorWithState(starargs, state);
155158
int i = 0;
156159
while (true) {
157160
Object key;
158161
try {
159-
key = getNextNode.executeWithGlobalState(iter);
162+
VirtualFrame frame = null;
163+
if (gotState.profile(state != null)) {
164+
frame = PArguments.frameForCall(state);
165+
}
166+
key = getNextNode.execute(frame, iter);
160167
Object value = pol.lookupAndCallSpecialMethodWithState(starargs, state, __GETITEM__, key);
161168
keywords[i++] = new PKeyword(castToJavaStringNode.execute(key), value);
162169
} catch (PException e) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/argument/positional/ExecutePositionalStarargsNode.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import com.oracle.graal.python.nodes.PNodeWithContext;
5757
import com.oracle.graal.python.nodes.PRaiseNode;
5858
import com.oracle.graal.python.nodes.control.GetNextNode;
59-
import com.oracle.graal.python.nodes.control.GetNextNode.GetNextWithoutFrameNode;
6059
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
6160
import com.oracle.graal.python.runtime.PythonOptions;
6261
import com.oracle.graal.python.runtime.exception.PException;
@@ -205,14 +204,14 @@ static Object[] starargs(PNone none,
205204
static Object[] starargs(Object object,
206205
@Cached PRaiseNode raise,
207206
@CachedLibrary("object") PythonObjectLibrary lib,
208-
@Cached GetNextWithoutFrameNode nextNode,
207+
@Cached GetNextNode nextNode,
209208
@Cached IsBuiltinClassProfile errorProfile) {
210209
Object iterator = lib.getIterator(object);
211210
if (iterator != PNone.NO_VALUE && iterator != PNone.NONE) {
212211
ArrayList<Object> internalStorage = new ArrayList<>();
213212
while (true) {
214213
try {
215-
addToList(internalStorage, nextNode.executeWithGlobalState(iterator));
214+
addToList(internalStorage, nextNode.execute(null, iterator));
216215
} catch (PException e) {
217216
e.expectStopIteration(errorProfile);
218217
return toArray(internalStorage);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/control/GetNextNode.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,13 @@
4949
import com.oracle.graal.python.nodes.PNodeWithContext;
5050
import com.oracle.graal.python.nodes.PRaiseNode;
5151
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
52-
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.LookupAndCallUnaryDynamicNode;
5352
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode.NoAttributeHandler;
5453
import com.oracle.graal.python.runtime.exception.PythonErrorType;
5554
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
56-
import com.oracle.truffle.api.dsl.Cached;
57-
import com.oracle.truffle.api.dsl.GenerateUncached;
58-
import com.oracle.truffle.api.dsl.Specialization;
5955
import com.oracle.truffle.api.frame.Frame;
6056
import com.oracle.truffle.api.frame.VirtualFrame;
6157
import com.oracle.truffle.api.nodes.NodeInfo;
6258
import com.oracle.truffle.api.nodes.UnexpectedResultException;
63-
import com.oracle.truffle.api.profiles.ConditionProfile;
6459

6560
public abstract class GetNextNode extends PNodeWithContext {
6661
public abstract Object execute(Frame frame, Object iterator);
@@ -185,25 +180,4 @@ public static GetNextNode create() {
185180
public static GetNextNode getUncached() {
186181
return GetNextUncached.INSTANCE;
187182
}
188-
189-
@GenerateUncached
190-
public abstract static class GetNextWithoutFrameNode extends PNodeWithContext {
191-
192-
public abstract Object executeWithGlobalState(Object iterator);
193-
194-
private static Object checkResult(PRaiseNode raiseNode, ConditionProfile notAnIterator, Object result, Object iterator) {
195-
if (notAnIterator.profile(result == PNone.NO_VALUE)) {
196-
throw raiseNode.raise(PythonErrorType.AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, iterator, __NEXT__);
197-
}
198-
return result;
199-
}
200-
201-
@Specialization
202-
Object doObject(Object iterator,
203-
@Cached LookupAndCallUnaryDynamicNode nextCall,
204-
@Cached PRaiseNode raiseNode,
205-
@Cached("createBinaryProfile()") ConditionProfile notAnIterator) {
206-
return checkResult(raiseNode, notAnIterator, nextCall.executeObject(iterator, __NEXT__), iterator);
207-
}
208-
}
209183
}

0 commit comments

Comments
 (0)