Skip to content

Commit 67856e1

Browse files
committed
remove indirection through PythonBinaryBuiltinNode.call
1 parent 226ac28 commit 67856e1

26 files changed

+56
-55
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/builtins/modules/ClinicTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ protected BinaryBuiltinRoot(PythonBinaryClinicBuiltinNode node) {
193193
@Override
194194
public Object execute(VirtualFrame frame) {
195195
try {
196-
return node.call(frame, frame.getArguments()[0], frame.getArguments()[1]);
196+
return node.execute(frame, frame.getArguments()[0], frame.getArguments()[1]);
197197
} catch (PException ex) {
198198
boolean expectTypeError = frame.getArguments().length >= 3 && (boolean) frame.getArguments()[2];
199199
if (expectTypeError) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
6666
import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
6767
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
68-
import com.oracle.graal.python.nodes.util.CastToJavaStringNode;
6968
import com.oracle.graal.python.nodes.util.SplitArgsNode;
7069
import com.oracle.graal.python.runtime.exception.PException;
7170
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
@@ -194,20 +193,19 @@ PArray arrayWithRangeInitializer(Object cls, String typeCode, PIntRange range,
194193
PArray arrayWithBytesInitializer(VirtualFrame frame, Object cls, String typeCode, PBytesLike bytes,
195194
@Cached ArrayBuiltins.FromBytesNode fromBytesNode) {
196195
PArray array = getFactory().createArray(cls, typeCode, getFormatChecked(typeCode));
197-
fromBytesNode.execute(frame, array, bytes);
196+
fromBytesNode.executeWithoutClinic(frame, array, bytes);
198197
return array;
199198
}
200199

201200
@Specialization(guards = "isString(initializer)")
202201
PArray arrayWithStringInitializer(VirtualFrame frame, Object cls, String typeCode, Object initializer,
203-
@Cached CastToJavaStringNode cast,
204202
@Cached ArrayBuiltins.FromUnicodeNode fromUnicodeNode) {
205203
BufferFormat format = getFormatChecked(typeCode);
206204
if (format != BufferFormat.UNICODE) {
207205
throw raise(TypeError, "cannot use a str to initialize an array with typecode '%s'", typeCode);
208206
}
209207
PArray array = getFactory().createArray(cls, typeCode, format);
210-
fromUnicodeNode.execute(frame, array, cast.execute(initializer));
208+
fromUnicodeNode.execute(frame, array, initializer);
211209
return array;
212210
}
213211

@@ -366,15 +364,15 @@ private Object doReconstruct(VirtualFrame frame, Object arrayType, String typeCo
366364
PArray array;
367365
if (machineFormat == MachineFormat.forFormat(format)) {
368366
array = factory().createArray(arrayType, typeCode, machineFormat.format);
369-
fromBytesNode.execute(frame, array, bytes);
367+
fromBytesNode.executeWithoutClinic(frame, array, bytes);
370368
} else {
371369
String newTypeCode = machineFormat.format == format ? typeCode : machineFormat.format.baseTypeCode;
372370
array = factory().createArray(arrayType, newTypeCode, machineFormat.format);
373371
if (machineFormat.unicodeEncoding != null) {
374372
Object decoded = callDecode.execute(frame, bytes, "decode", machineFormat.unicodeEncoding);
375373
fromUnicodeNode.execute(frame, array, decoded);
376374
} else {
377-
fromBytesNode.execute(frame, array, bytes);
375+
fromBytesNode.executeWithoutClinic(frame, array, bytes);
378376
if (machineFormat.order != ByteOrder.nativeOrder()) {
379377
byteSwapNode.execute(frame, array);
380378
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ PTuple lookup(VirtualFrame frame, PBytesLike encoding,
827827
@Cached ConditionProfile hasSearchPathProfile,
828828
@Cached ConditionProfile hasTruffleEncodingProfile,
829829
@Cached ConditionProfile isTupleProfile) {
830-
String decoded = (String) ((PTuple) asciiDecodeNode.call(frame, encoding, PNone.NO_VALUE)).getSequenceStorage().getInternalArray()[0];
830+
String decoded = (String) ((PTuple) asciiDecodeNode.execute(frame, encoding, PNone.NO_VALUE)).getSequenceStorage().getInternalArray()[0];
831831
return lookup(frame, decoded, callNode, lenNode, hasSearchPathProfile, hasTruffleEncodingProfile, isTupleProfile);
832832
}
833833

@@ -936,7 +936,7 @@ abstract static class ForgetCodecNode extends PythonBuiltinNode {
936936
@Specialization
937937
Object forget(VirtualFrame frame, PBytesLike encoding,
938938
@Cached AsciiDecodeNode asciiDecodeNode) {
939-
forget((String) ((PTuple) asciiDecodeNode.call(frame, encoding, PNone.NO_VALUE)).getSequenceStorage().getInternalArray()[0]);
939+
forget((String) ((PTuple) asciiDecodeNode.execute(frame, encoding, PNone.NO_VALUE)).getSequenceStorage().getInternalArray()[0]);
940940
return PNone.NONE;
941941
}
942942

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/LazyPyCSimpleTypeBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Object c_wchar_p_from_param(VirtualFrame frame, Object type, Object value,
184184

185185
Object as_parameter = lookupAsParam.execute(value);
186186
if (as_parameter != null) {
187-
return cwCharPFromParamNode.call(frame, type, as_parameter);
187+
return cwCharPFromParamNode.execute(frame, type, as_parameter);
188188
}
189189
/* XXX better message */
190190
throw raise(TypeError, WRONG_TYPE);
@@ -301,7 +301,7 @@ Object c_void_p_from_param(VirtualFrame frame, Object type, Object value, // PyU
301301

302302
Object as_parameter = lookupAsParam.execute(value);
303303
if (as_parameter != null) {
304-
return cVoidPFromParamNode.call(frame, type, as_parameter);
304+
return cVoidPFromParamNode.execute(frame, type, as_parameter);
305305
}
306306
/* XXX better message */
307307
throw raise(TypeError, WRONG_TYPE);
@@ -363,7 +363,7 @@ Object c_char_p_from_param(VirtualFrame frame, Object type, Object value,
363363

364364
Object as_parameter = lookupAsParam.execute(value);
365365
if (as_parameter != null) {
366-
return cCharPFromParamNode.call(frame, type, as_parameter);
366+
return cCharPFromParamNode.execute(frame, type, as_parameter);
367367
}
368368
/* XXX better message */
369369
throw raise(TypeError, WRONG_TYPE);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BytesIOBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static Object writeLines(VirtualFrame frame, PBytesIO self, Object lines,
545545
e.expectStopIteration(errorProfile);
546546
break;
547547
}
548-
writeNode.call(frame, self, line);
548+
writeNode.execute(frame, self, line);
549549
}
550550
return PNone.NONE;
551551
}
@@ -744,7 +744,7 @@ Object doit(VirtualFrame frame, PBytesIO self, PTuple state,
744744
* Set the value of the internal buffer. If state[0] does not support the buffer
745745
* protocol, bytesio_write will raise the appropriate TypeError.
746746
*/
747-
writeNode.call(frame, self, array[0]);
747+
writeNode.execute(frame, self, array[0]);
748748
/*
749749
* Set carefully the position value. Alternatively, we could use the seek method instead
750750
* of modifying self.getPos() directly to better protect the object internal state

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ abstract static class TruncateNode extends PythonBinaryBuiltinNode {
797797
@Specialization(guards = {"!self.isClosed()", "self.isWritable()", "!isPNone(posobj)"})
798798
static Object num(VirtualFrame frame, PFileIO self, Object posobj,
799799
@Shared("ft") @Cached PosixModuleBuiltins.FtruncateNode posixTruncate) {
800-
posixTruncate.call(frame, self.getFD(), posobj);
800+
posixTruncate.execute(frame, self.getFD(), posobj);
801801
return posobj;
802802
}
803803

@@ -806,7 +806,7 @@ static Object none(VirtualFrame frame, PFileIO self, @SuppressWarnings("unused")
806806
@Shared("ft") @Cached PosixModuleBuiltins.FtruncateNode posixTruncate,
807807
@Cached PosixModuleBuiltins.LseekNode posixSeek) {
808808
Object pos = posixSeek.call(frame, self.getFD(), 0, SEEK_CUR);
809-
posixTruncate.call(frame, self.getFD(), pos);
809+
posixTruncate.execute(frame, self.getFD(), pos);
810810
return pos;
811811
}
812812

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array/ArrayBuiltins.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ protected ArgumentClinicProvider getArgumentClinic() {
921921
@ArgumentClinic(name = "buffer", conversion = ArgumentClinic.ClinicConversion.ReadableBuffer)
922922
@GenerateNodeFactory
923923
public abstract static class FromBytesNode extends PythonBinaryClinicBuiltinNode {
924+
925+
// make this method accessible
926+
@Override
927+
public abstract Object executeWithoutClinic(VirtualFrame frame, Object arg, Object arg2);
928+
924929
@Specialization(limit = "3")
925930
Object frombytes(PArray self, Object buffer,
926931
@CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib) {
@@ -972,7 +977,7 @@ Object fromfile(VirtualFrame frame, PArray self, Object file, int n,
972977
Object readResult = callMethod.execute(frame, file, "read", nbytes);
973978
if (readResult instanceof PBytes) {
974979
int readLength = sizeNode.execute(frame, readResult);
975-
fromBytesNode.execute(frame, self, readResult);
980+
fromBytesNode.executeWithoutClinic(frame, self, readResult);
976981
// It would make more sense to check this before the frombytes call, but CPython
977982
// does it this way
978983
if (readLength != nbytes) {
@@ -1036,7 +1041,7 @@ static Object fromstring(VirtualFrame frame, PArray self, Object str,
10361041
@Cached FromBytesNode fromBytesNode) {
10371042
warnNode.warnEx(frame, DeprecationWarning, "fromstring() is deprecated. Use frombytes() instead.", 1);
10381043
Object bytes = callMethod.execute(frame, str, "encode", "utf-8");
1039-
return fromBytesNode.execute(frame, self, bytes);
1044+
return fromBytesNode.executeWithoutClinic(frame, self, bytes);
10401045
}
10411046

10421047
@Specialization(guards = "!isString(str)")
@@ -1045,7 +1050,7 @@ static Object fromother(VirtualFrame frame, PArray self, Object str,
10451050
@Cached WarningsModuleBuiltins.WarnNode warnNode,
10461051
@Cached FromBytesNode fromBytesNode) {
10471052
warnNode.warnEx(frame, DeprecationWarning, "fromstring() is deprecated. Use frombytes() instead.", 1);
1048-
return fromBytesNode.execute(frame, self, bufferAcquireLib.acquireReadonly(str));
1053+
return fromBytesNode.executeWithoutClinic(frame, self, bufferAcquireLib.acquireReadonly(str));
10491054
}
10501055
}
10511056

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ private EqNode getEqNode() {
409409

410410
@Specialization
411411
public Object notEqual(VirtualFrame frame, Object self, Object other) {
412-
Object result = getEqNode().call(frame, self, other);
412+
Object result = getEqNode().execute(frame, self, other);
413413
if (result == PNotImplemented.NOT_IMPLEMENTED) {
414414
return result;
415415
} else {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/exception/BaseExceptionBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Object reduce(VirtualFrame frame, PBaseException self,
314314
@Cached DictNode dictNode) {
315315
Object clazz = getClassNode.execute(self);
316316
Object args = argsNode.executeObject(frame, self, PNone.NO_VALUE);
317-
Object dict = dictNode.call(frame, self, PNone.NO_VALUE);
317+
Object dict = dictNode.execute(frame, self, PNone.NO_VALUE);
318318
return factory().createTuple(new Object[]{clazz, args, dict});
319319
}
320320
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/floats/FloatBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ PTuple doLD(long left, double right) {
635635
PTuple doGenericFloat(VirtualFrame frame, Object left, Object right,
636636
@Cached FloorDivNode floorDivNode,
637637
@Cached ModNode modNode) {
638-
return factory().createTuple(new Object[]{floorDivNode.call(frame, left, right), modNode.call(frame, left, right)});
638+
return factory().createTuple(new Object[]{floorDivNode.execute(frame, left, right), modNode.execute(frame, left, right)});
639639
}
640640

641641
@SuppressWarnings("unused")

0 commit comments

Comments
 (0)