103
103
import com .oracle .graal .python .builtins .objects .cext .PythonNativeVoidPtr ;
104
104
import com .oracle .graal .python .builtins .objects .cext .capi .CApiContext ;
105
105
import com .oracle .graal .python .builtins .objects .cext .capi .CApiContext .AllocInfo ;
106
+ import com .oracle .graal .python .builtins .objects .cext .capi .CApiContext .LLVMType ;
106
107
import com .oracle .graal .python .builtins .objects .cext .capi .CApiGuards ;
107
108
import com .oracle .graal .python .builtins .objects .cext .capi .CArrayWrappers .CStringWrapper ;
108
109
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes ;
120
121
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .FastCallArgsToSulongNode ;
121
122
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .FastCallWithKeywordsArgsToSulongNode ;
122
123
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .FromCharPointerNode ;
124
+ import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .GetLLVMType ;
123
125
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .GetNativeNullNode ;
124
126
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .MayRaiseErrorResult ;
125
127
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .MayRaiseNode ;
278
280
import com .oracle .truffle .api .dsl .Specialization ;
279
281
import com .oracle .truffle .api .dsl .TypeSystemReference ;
280
282
import com .oracle .truffle .api .frame .VirtualFrame ;
283
+ import com .oracle .truffle .api .interop .ArityException ;
281
284
import com .oracle .truffle .api .interop .InteropException ;
282
285
import com .oracle .truffle .api .interop .InteropLibrary ;
283
286
import com .oracle .truffle .api .interop .InvalidArrayIndexException ;
284
287
import com .oracle .truffle .api .interop .TruffleObject ;
288
+ import com .oracle .truffle .api .interop .UnknownIdentifierException ;
285
289
import com .oracle .truffle .api .interop .UnsupportedMessageException ;
290
+ import com .oracle .truffle .api .interop .UnsupportedTypeException ;
286
291
import com .oracle .truffle .api .library .CachedLibrary ;
287
292
import com .oracle .truffle .api .nodes .ControlFlowException ;
288
293
import com .oracle .truffle .api .nodes .Node ;
@@ -3307,13 +3312,15 @@ static Object doFunction(VirtualFrame frame, Object callableObj, Object vaList,
3307
3312
@ Shared ("argLib" ) @ CachedLibrary (limit = "2" ) InteropLibrary argLib ,
3308
3313
@ CachedLibrary (limit = "1" ) PythonObjectLibrary callableLib ,
3309
3314
@ Cached AsPythonObjectNode asPythonObjectNode ,
3315
+ @ Cached CExtNodes .ToJavaNode toJavaNode ,
3316
+ @ Cached GetLLVMType getLLVMType ,
3310
3317
@ Cached ToNewRefNode toNewRefNode ,
3311
3318
@ Cached GetNativeNullNode getNativeNullNode ,
3312
3319
@ Cached CExtNodes .ToSulongNode nullToSulongNode ,
3313
3320
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ) {
3314
3321
try {
3315
3322
Object callable = asPythonObjectNode .execute (callableObj );
3316
- return toNewRefNode .execute (callFunction (frame , callable , vaList , argsArrayLib , argLib , callableLib , asPythonObjectNode ));
3323
+ return toNewRefNode .execute (callFunction (frame , callable , vaList , argsArrayLib , argLib , callableLib , toJavaNode , getLLVMType ));
3317
3324
} catch (PException e ) {
3318
3325
// transformExceptionToNativeNode acts as a branch profile
3319
3326
transformExceptionToNativeNode .execute (frame , e );
@@ -3325,7 +3332,8 @@ static Object callFunction(VirtualFrame frame, Object callable, Object vaList,
3325
3332
InteropLibrary argsArrayLib ,
3326
3333
InteropLibrary argLib ,
3327
3334
PythonObjectLibrary callableLib ,
3328
- AsPythonObjectNode asPythonObjectNode ) {
3335
+ CExtNodes .ToJavaNode toJavaNode ,
3336
+ GetLLVMType getLLVMType ) {
3329
3337
if (argsArrayLib .hasArrayElements (vaList )) {
3330
3338
try {
3331
3339
/*
@@ -3339,15 +3347,16 @@ static Object callFunction(VirtualFrame frame, Object callable, Object vaList,
3339
3347
long arraySize = argsArrayLib .getArraySize (vaList );
3340
3348
Object [] args = new Object [PInt .intValueExact (arraySize ) - 1 ];
3341
3349
int filled = 0 ;
3350
+ Object llvmPyObjectPtrType = getLLVMType .execute (LLVMType .PyObject_ptr_t );
3342
3351
for (int i = 0 ; i < args .length ; i ++) {
3343
3352
try {
3344
- Object object = argsArrayLib .readArrayElement (vaList , i );
3353
+ Object object = argsArrayLib .invokeMember (vaList , "get" , i , llvmPyObjectPtrType );
3345
3354
if (argLib .isNull (object )) {
3346
3355
break ;
3347
3356
}
3348
- args [i ] = asPythonObjectNode .execute (object );
3357
+ args [i ] = toJavaNode .execute (object );
3349
3358
filled ++;
3350
- } catch (InvalidArrayIndexException e ) {
3359
+ } catch (ArityException | UnknownIdentifierException | UnsupportedTypeException e ) {
3351
3360
throw CompilerDirectives .shouldNotReachHere ();
3352
3361
}
3353
3362
}
@@ -3377,6 +3386,8 @@ static Object doMethod(VirtualFrame frame, Object receiverObj, Object methodName
3377
3386
@ Shared ("argLib" ) @ CachedLibrary (limit = "2" ) InteropLibrary argLib ,
3378
3387
@ Cached GetAnyAttributeNode getAnyAttributeNode ,
3379
3388
@ Cached AsPythonObjectNode asPythonObjectNode ,
3389
+ @ Cached CExtNodes .ToJavaNode toJavaNode ,
3390
+ @ Cached GetLLVMType getLLVMType ,
3380
3391
@ Cached ToNewRefNode toNewRefNode ,
3381
3392
@ Cached GetNativeNullNode getNativeNullNode ,
3382
3393
@ Cached CExtNodes .ToSulongNode nullToSulongNode ,
@@ -3386,7 +3397,7 @@ static Object doMethod(VirtualFrame frame, Object receiverObj, Object methodName
3386
3397
Object receiver = asPythonObjectNode .execute (receiverObj );
3387
3398
Object methodName = asPythonObjectNode .execute (methodNameObj );
3388
3399
Object method = getAnyAttributeNode .executeObject (frame , receiver , methodName );
3389
- return toNewRefNode .execute (PyObjectCallFunctionObjArgsNode .callFunction (frame , method , vaList , argsArrayLib , argLib , methodLib , asPythonObjectNode ));
3400
+ return toNewRefNode .execute (PyObjectCallFunctionObjArgsNode .callFunction (frame , method , vaList , argsArrayLib , argLib , methodLib , toJavaNode , getLLVMType ));
3390
3401
} catch (PException e ) {
3391
3402
// transformExceptionToNativeNode acts as a branch profile
3392
3403
transformExceptionToNativeNode .execute (frame , e );
@@ -3434,6 +3445,7 @@ abstract static class PyObjectFastCallDictNode extends PythonTernaryBuiltinNode
3434
3445
@ Specialization (limit = "1" )
3435
3446
static Object doGeneric (VirtualFrame frame , Object callableObj , Object argsArray , Object kwargsObj ,
3436
3447
@ CachedLibrary ("argsArray" ) InteropLibrary argsArrayLib ,
3448
+ @ Cached CExtNodes .ToJavaNode toJavaNode ,
3437
3449
@ Cached AsPythonObjectNode asPythonObjectNode ,
3438
3450
@ Cached CastKwargsNode castKwargsNode ,
3439
3451
@ Cached CallNode callNode ,
@@ -3449,7 +3461,7 @@ static Object doGeneric(VirtualFrame frame, Object callableObj, Object argsArray
3449
3461
Object [] args = new Object [PInt .intValueExact (arraySize )];
3450
3462
for (int i = 0 ; i < args .length ; i ++) {
3451
3463
try {
3452
- args [i ] = asPythonObjectNode .execute (argsArrayLib .readArrayElement (argsArray , i ));
3464
+ args [i ] = toJavaNode .execute (argsArrayLib .readArrayElement (argsArray , i ));
3453
3465
} catch (InvalidArrayIndexException e ) {
3454
3466
throw CompilerDirectives .shouldNotReachHere ();
3455
3467
}
@@ -3487,9 +3499,9 @@ static Object[] doNull(VirtualFrame frame, Object argsObj,
3487
3499
@ Specialization (guards = "!lib.isNull(argsObj)" )
3488
3500
static Object [] doNotNull (VirtualFrame frame , Object argsObj ,
3489
3501
@ Cached ExecutePositionalStarargsNode expandArgsNode ,
3490
- @ Cached AsPythonObjectNode argsToJavaNode ,
3502
+ @ Cached AsPythonObjectNode asPythonObjectNode ,
3491
3503
@ Shared ("lib" ) @ CachedLibrary (limit = "3" ) @ SuppressWarnings ("unused" ) InteropLibrary lib ) {
3492
- return expandArgsNode .executeWith (frame , argsToJavaNode .execute (argsObj ));
3504
+ return expandArgsNode .executeWith (frame , asPythonObjectNode .execute (argsObj ));
3493
3505
}
3494
3506
}
3495
3507
0 commit comments