Skip to content

Commit 994ab92

Browse files
committed
Use interop instead of reference lib for isNull test.
1 parent ad728c0 commit 994ab92

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

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

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@
281281
import com.oracle.truffle.api.profiles.ConditionProfile;
282282
import com.oracle.truffle.api.profiles.ValueProfile;
283283
import com.oracle.truffle.api.utilities.CyclicAssumption;
284-
import com.oracle.truffle.llvm.spi.ReferenceLibrary;
285284

286285
@CoreFunctions(defineModule = PythonCextBuiltins.PYTHON_CEXT)
287286
@GenerateNodeFactory
@@ -3276,10 +3275,10 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments,
32763275
return execute(frame, self, arguments, PKeyword.EMPTY_KEYWORDS);
32773276
}
32783277

3279-
public static int doConvert(CExtContext nativeContext, Object nativeNull, Object argv, Object nativeKwds, Object nativeFormat, Object nativeKwdnames, Object nativeVarargs,
3280-
ReferenceLibrary kwdsRefLib,
3281-
ReferenceLibrary kwdnamesRefLib,
3282-
ValueProfile kwdsProfile,
3278+
public static int doConvert(CExtContext nativeContext, Object argv, Object nativeKwds, Object nativeFormat, Object nativeKwdnames, Object nativeVarargs,
3279+
InteropLibrary kwdsRefLib,
3280+
InteropLibrary kwdnamesRefLib,
3281+
ConditionProfile kwdsProfile,
32833282
ConditionProfile kwdnamesProfile,
32843283
ConditionProfile functionNameProfile,
32853284
CExtAsPythonObjectNode kwdsToJavaNode,
@@ -3308,16 +3307,16 @@ public static int doConvert(CExtContext nativeContext, Object nativeNull, Object
33083307

33093308
// sort out if kwds is native NULL
33103309
Object kwds;
3311-
if (kwdsRefLib.isSame(nativeKwds, nativeNull)) {
3310+
if (kwdsProfile.profile(kwdsRefLib.isNull(nativeKwds))) {
33123311
kwds = null;
33133312
} else {
33143313
kwds = kwdsToJavaNode.execute(nativeContext, nativeKwds);
33153314
}
33163315

33173316
// sort out if kwdnames is native NULL
3318-
Object kwdnames = kwdnamesProfile.profile(kwdnamesRefLib.isSame(nativeKwdnames, nativeNull)) ? null : nativeKwdnames;
3317+
Object kwdnames = kwdnamesProfile.profile(kwdnamesRefLib.isNull(nativeKwdnames)) ? null : nativeKwdnames;
33193318

3320-
return parseTupleAndKeywordsNode.execute(functionName, argv, kwdsProfile.profile(kwds), format, kwdnames, nativeVarargs, nativeContext);
3319+
return parseTupleAndKeywordsNode.execute(functionName, argv, kwds, format, kwdnames, nativeVarargs, nativeContext);
33213320
}
33223321

33233322
static Object getKwds(Object[] arguments) {
@@ -3334,23 +3333,20 @@ static Object getKwdnames(Object[] arguments) {
33343333
abstract static class ParseTupleAndKeywordsNode extends ParseTupleAndKeywordsBaseNode {
33353334

33363335
@Specialization(guards = "arguments.length == 5", limit = "2")
3337-
static int doConvert(Object cextModule, Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords,
3336+
static int doConvert(Object self, Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords,
33383337
@CachedContext(PythonLanguage.class) PythonContext context,
3339-
@CachedLibrary("getKwds(arguments)") ReferenceLibrary kwdsRefLib,
3340-
@CachedLibrary("getKwdnames(arguments)") ReferenceLibrary kwdnamesRefLib,
3341-
@Cached("createIdentityProfile()") ValueProfile kwdsProfile,
3338+
@CachedLibrary("getKwds(arguments)") InteropLibrary kwdsInteropLib,
3339+
@CachedLibrary("getKwdnames(arguments)") InteropLibrary kwdnamesRefLib,
3340+
@Cached("createBinaryProfile()") ConditionProfile kwdsProfile,
33423341
@Cached("createBinaryProfile()") ConditionProfile kwdnamesProfile,
33433342
@Cached("createBinaryProfile()") ConditionProfile functionNameProfile,
33443343
@Cached CExtNodes.AsPythonObjectNode argvToJavaNode,
33453344
@Cached CExtNodes.AsPythonObjectNode kwdsToJavaNode,
33463345
@Cached CastToJavaStringNode castToStringNode,
3347-
@Cached CExtNodes.ToSulongNode nativeNullToSulongNode,
3348-
@Cached GetNativeNullNode getNativeNullNode,
33493346
@Cached CExtParseArgumentsNode.ParseTupleAndKeywordsNode parseTupleAndKeywordsNode) {
33503347
CExtContext nativeContext = context.getCApiContext();
33513348
Object argv = argvToJavaNode.execute(arguments[0]);
3352-
Object nativeNull = nativeNullToSulongNode.execute(getNativeNullNode.execute(cextModule));
3353-
return ParseTupleAndKeywordsBaseNode.doConvert(nativeContext, nativeNull, argv, arguments[1], arguments[2], arguments[3], arguments[4], kwdsRefLib, kwdnamesRefLib, kwdsProfile,
3349+
return ParseTupleAndKeywordsBaseNode.doConvert(nativeContext, argv, arguments[1], arguments[2], arguments[3], arguments[4], kwdsInteropLib, kwdnamesRefLib, kwdsProfile,
33543350
kwdnamesProfile, functionNameProfile, kwdsToJavaNode, castToStringNode, parseTupleAndKeywordsNode);
33553351
}
33563352

@@ -3361,25 +3357,22 @@ static int doConvert(Object cextModule, Object[] arguments, @SuppressWarnings("u
33613357
abstract static class ParseTupleAndKeywordsVaListNode extends ParseTupleAndKeywordsBaseNode {
33623358

33633359
@Specialization(guards = "arguments.length == 5", limit = "2")
3364-
static int doConvert(Object cextModule, Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords,
3360+
static int doConvert(Object self, Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords,
33653361
@CachedContext(PythonLanguage.class) PythonContext context,
3366-
@CachedLibrary("getKwds(arguments)") ReferenceLibrary kwdsRefLib,
3367-
@CachedLibrary("getKwdnames(arguments)") ReferenceLibrary kwdnamesRefLib,
3368-
@Cached("createIdentityProfile()") ValueProfile kwdsProfile,
3362+
@CachedLibrary("getKwds(arguments)") InteropLibrary kwdsRefLib,
3363+
@CachedLibrary("getKwdnames(arguments)") InteropLibrary kwdnamesRefLib,
3364+
@Cached("createBinaryProfile()") ConditionProfile kwdsProfile,
33693365
@Cached("createBinaryProfile()") ConditionProfile kwdnamesProfile,
33703366
@Cached("createBinaryProfile()") ConditionProfile functionNameProfile,
33713367
@Cached PCallCExtFunction callMallocOutVarPtr,
33723368
@Cached CExtNodes.AsPythonObjectNode argvToJavaNode,
33733369
@Cached CExtNodes.AsPythonObjectNode kwdsToJavaNode,
33743370
@Cached CastToJavaStringNode castToStringNode,
3375-
@Cached CExtNodes.ToSulongNode nativeNullToSulongNode,
3376-
@Cached GetNativeNullNode getNativeNullNode,
33773371
@Cached CExtParseArgumentsNode.ParseTupleAndKeywordsNode parseTupleAndKeywordsNode) {
33783372
CExtContext nativeContext = context.getCApiContext();
3379-
Object nativeNull = nativeNullToSulongNode.execute(getNativeNullNode.execute(cextModule));
33803373
Object argv = argvToJavaNode.execute(arguments[0]);
33813374
VaListWrapper varargs = new VaListWrapper(nativeContext, arguments[4], callMallocOutVarPtr.call(nativeContext, NativeCAPISymbols.FUN_ALLOCATE_OUTVAR));
3382-
return ParseTupleAndKeywordsBaseNode.doConvert(nativeContext, nativeNull, argv, arguments[1], arguments[2], arguments[3], varargs, kwdsRefLib, kwdnamesRefLib, kwdsProfile, kwdnamesProfile,
3375+
return ParseTupleAndKeywordsBaseNode.doConvert(nativeContext, argv, arguments[1], arguments[2], arguments[3], varargs, kwdsRefLib, kwdnamesRefLib, kwdsProfile, kwdnamesProfile,
33833376
functionNameProfile, kwdsToJavaNode, castToStringNode, parseTupleAndKeywordsNode);
33843377
}
33853378
}

0 commit comments

Comments
 (0)