Skip to content

Commit 2b7f9b3

Browse files
committed
Review usages of IsForeignObjectNode and remove unnecessary ones
1 parent bebf304 commit 2b7f9b3

File tree

3 files changed

+1
-57
lines changed

3 files changed

+1
-57
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/iterator/IteratorNodes.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@
7979
import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
8080
import com.oracle.graal.python.nodes.object.GetClassNode;
8181
import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode;
82-
import com.oracle.graal.python.nodes.object.IsForeignObjectNode;
8382
import com.oracle.graal.python.nodes.util.CastBuiltinStringToTruffleStringNode;
84-
import com.oracle.graal.python.runtime.GilNode;
8583
import com.oracle.graal.python.runtime.exception.PException;
8684
import com.oracle.graal.python.runtime.sequence.PSequence;
8785
import com.oracle.graal.python.runtime.sequence.storage.SequenceStorage;
@@ -98,9 +96,6 @@
9896
import com.oracle.truffle.api.dsl.ImportStatic;
9997
import com.oracle.truffle.api.dsl.Specialization;
10098
import com.oracle.truffle.api.frame.VirtualFrame;
101-
import com.oracle.truffle.api.interop.InteropLibrary;
102-
import com.oracle.truffle.api.interop.UnsupportedMessageException;
103-
import com.oracle.truffle.api.library.CachedLibrary;
10499
import com.oracle.truffle.api.nodes.Node;
105100
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
106101
import com.oracle.truffle.api.profiles.InlinedLoopConditionProfile;
@@ -172,8 +167,6 @@ static int length(@SuppressWarnings("unused") PNone iterable) {
172167
@Fallback
173168
@InliningCutoff
174169
static int length(VirtualFrame frame, Node inliningTarget, Object iterable,
175-
@Cached IsForeignObjectNode isForeignObjectNode,
176-
@Cached(inline = false) GetLengthForeign getLengthForeign,
177170
@Cached GetClassNode getClassNode,
178171
@Cached GetCachedTpSlotsNode getSlotsNode,
179172
@Cached PyIndexCheckNode indexCheckNode,
@@ -185,12 +178,6 @@ static int length(VirtualFrame frame, Node inliningTarget, Object iterable,
185178
@Cached InlinedConditionProfile hasLenProfile,
186179
@Cached InlinedConditionProfile hasLengthHintProfile,
187180
@Cached PRaiseNode.Lazy raiseNode) {
188-
if (isForeignObjectNode.execute(inliningTarget, iterable)) {
189-
int foreignLen = getLengthForeign.execute(iterable);
190-
if (foreignLen != -1) {
191-
return foreignLen;
192-
}
193-
}
194181
Object clazz = getClassNode.execute(inliningTarget, iterable);
195182
TpSlots slots = getSlotsNode.execute(inliningTarget, clazz);
196183
if (hasLenProfile.profile(inliningTarget, slots.combined_sq_mp_length() != null)) {
@@ -229,35 +216,6 @@ static int length(VirtualFrame frame, Node inliningTarget, Object iterable,
229216
}
230217
}
231218

232-
/**
233-
* Handles the special case of foreign Strings. If the input is not a string, returns -1.
234-
*/
235-
@GenerateInline(false) // Intentionally lazy initialized
236-
public abstract static class GetLengthForeign extends PNodeWithContext {
237-
public abstract int execute(Object foreign);
238-
239-
@Specialization
240-
static int doIt(Object foreign,
241-
@Bind("this") Node inliningTarget,
242-
@Cached InlinedConditionProfile isString,
243-
@CachedLibrary(limit = "3") InteropLibrary iLib,
244-
@Cached TruffleString.SwitchEncodingNode switchEncodingNode,
245-
@Cached TruffleString.CodePointLengthNode codePointLengthNode,
246-
@Cached GilNode gil) {
247-
if (isString.profile(inliningTarget, iLib.isString(foreign))) {
248-
gil.release(true);
249-
try {
250-
return codePointLengthNode.execute(switchEncodingNode.execute(iLib.asTruffleString(foreign), TS_ENCODING), TS_ENCODING);
251-
} catch (UnsupportedMessageException e) {
252-
throw CompilerDirectives.shouldNotReachHere();
253-
} finally {
254-
gil.acquire();
255-
}
256-
}
257-
return -1;
258-
}
259-
}
260-
261219
@ImportStatic(PGuards.class)
262220
@GenerateInline
263221
@GenerateCached(false)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyMappingCheckNode.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import com.oracle.graal.python.builtins.objects.type.TpSlots.GetCachedTpSlotsNode;
4545
import com.oracle.graal.python.nodes.PNodeWithContext;
4646
import com.oracle.graal.python.nodes.object.GetClassNode;
47-
import com.oracle.graal.python.nodes.object.IsForeignObjectNode;
48-
import com.oracle.graal.python.nodes.util.LazyInteropLibrary;
4947
import com.oracle.graal.python.runtime.sequence.PSequence;
5048
import com.oracle.truffle.api.dsl.Cached;
5149
import com.oracle.truffle.api.dsl.GenerateCached;
@@ -86,13 +84,8 @@ static boolean doSequence(@SuppressWarnings("unused") PSequence object) {
8684
@Specialization
8785
static boolean doGeneric(Node inliningTarget, Object object,
8886
@Cached GetClassNode getClassNode,
89-
@Cached GetCachedTpSlotsNode getSlotsNode,
90-
@Cached IsForeignObjectNode isForeignObjectNode,
91-
@Cached LazyInteropLibrary lazyLib) {
87+
@Cached GetCachedTpSlotsNode getSlotsNode) {
9288
Object type = getClassNode.execute(inliningTarget, object);
93-
if (isForeignObjectNode.execute(inliningTarget, object)) {
94-
return lazyLib.get(inliningTarget).hasHashEntries(object);
95-
}
9689
return getSlotsNode.execute(inliningTarget, type).mp_subscript() != null;
9790
}
9891
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberCheckNode.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
import com.oracle.graal.python.nodes.PNodeWithContext;
4646
import com.oracle.graal.python.nodes.attributes.LookupCallableSlotInMRONode;
4747
import com.oracle.graal.python.nodes.object.GetClassNode;
48-
import com.oracle.graal.python.nodes.object.IsForeignObjectNode;
49-
import com.oracle.graal.python.nodes.util.LazyInteropLibrary;
5048
import com.oracle.truffle.api.dsl.Cached;
5149
import com.oracle.truffle.api.dsl.Fallback;
5250
import com.oracle.truffle.api.dsl.GenerateCached;
@@ -105,17 +103,12 @@ static boolean doNone(PNone object) {
105103

106104
@Fallback
107105
static boolean doOthers(Node inliningTarget, Object object,
108-
@Cached IsForeignObjectNode isForeignObjectNode,
109-
@Cached LazyInteropLibrary interopLibrary,
110106
@Cached GetClassNode getClassNode,
111107
@Cached(parameters = "Index", inline = false) LookupCallableSlotInMRONode lookupIndex,
112108
@Cached(parameters = "Float", inline = false) LookupCallableSlotInMRONode lookupFloat,
113109
@Cached(parameters = "Int", inline = false) LookupCallableSlotInMRONode lookupInt,
114110
@Cached PyComplexCheckNode checkComplex) {
115111
Object type = getClassNode.execute(inliningTarget, object);
116-
if (isForeignObjectNode.execute(inliningTarget, object)) {
117-
return interopLibrary.get(inliningTarget).isNumber(object);
118-
}
119112
return lookupIndex.execute(type) != PNone.NO_VALUE || lookupInt.execute(type) != PNone.NO_VALUE || lookupFloat.execute(type) != PNone.NO_VALUE || checkComplex.execute(inliningTarget, object);
120113
}
121114
}

0 commit comments

Comments
 (0)