47
47
48
48
import com .oracle .graal .python .PythonLanguage ;
49
49
import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .AsCharPointerNode ;
50
+ import com .oracle .graal .python .builtins .objects .cext .capi .ExternalFunctionNodes .ExternalFunctionInvokeNode ;
50
51
import com .oracle .graal .python .builtins .objects .cext .capi .ExternalFunctionNodes .PExternalFunctionWrapper ;
51
52
import com .oracle .graal .python .builtins .objects .cext .capi .ExternalFunctionNodes .PyObjectCheckFunctionResultNode ;
53
+ import com .oracle .graal .python .builtins .objects .cext .capi .transitions .CApiTiming ;
52
54
import com .oracle .graal .python .builtins .objects .cext .capi .transitions .CApiTransitions .NativeToPythonTransferNode ;
53
55
import com .oracle .graal .python .builtins .objects .cext .capi .transitions .CApiTransitions .PythonToNativeNode ;
54
56
import com .oracle .graal .python .builtins .objects .cext .structs .CStructAccess .FreeNode ;
64
66
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
65
67
import com .oracle .graal .python .nodes .object .BuiltinClassProfiles .IsBuiltinObjectProfile ;
66
68
import com .oracle .graal .python .runtime .ExecutionContext .CallContext ;
67
- import com .oracle .graal .python .runtime .ExecutionContext .IndirectCallContext ;
68
- import com .oracle .graal .python .runtime .IndirectCallData ;
69
69
import com .oracle .graal .python .runtime .PythonContext .GetThreadStateNode ;
70
70
import com .oracle .graal .python .runtime .PythonContext .PythonThreadState ;
71
71
import com .oracle .graal .python .runtime .exception .PException ;
72
- import com .oracle .truffle .api .CompilerDirectives ;
73
72
import com .oracle .truffle .api .HostCompilerDirectives .InliningCutoff ;
74
73
import com .oracle .truffle .api .RootCallTarget ;
75
74
import com .oracle .truffle .api .dsl .Bind ;
82
81
import com .oracle .truffle .api .dsl .NodeFactory ;
83
82
import com .oracle .truffle .api .dsl .Specialization ;
84
83
import com .oracle .truffle .api .frame .VirtualFrame ;
85
- import com .oracle .truffle .api .interop .InteropException ;
86
- import com .oracle .truffle .api .interop .InteropLibrary ;
87
- import com .oracle .truffle .api .library .CachedLibrary ;
88
84
import com .oracle .truffle .api .nodes .IndirectCallNode ;
89
85
import com .oracle .truffle .api .nodes .Node ;
90
86
import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
@@ -232,6 +228,8 @@ static Object callNative(VirtualFrame frame, TpSlots slots, TpSlotNative slot, O
232
228
@ GenerateInline (false ) // Used lazily
233
229
@ GenerateUncached
234
230
abstract static class CallNativeSlotGetAttrNode extends Node {
231
+ private static final CApiTiming C_API_TIMING = CApiTiming .create (true , "tp_getattr" );
232
+
235
233
abstract Object execute (VirtualFrame frame , TpSlots slots , TpSlotNative tp_get_attro_attr , Object self , Object name );
236
234
237
235
@ Specialization
@@ -241,30 +239,23 @@ static Object callNative(VirtualFrame frame, TpSlots slots, TpSlotNative slot, O
241
239
@ Cached InlinedConditionProfile isGetAttrProfile ,
242
240
@ Cached AsCharPointerNode asCharPointerNode ,
243
241
@ Cached FreeNode freeNode ,
244
- @ Cached ("createFor(inliningTarget)" ) IndirectCallData callData ,
245
- @ Cached PythonToNativeNode toNativeNode ,
246
- @ CachedLibrary (limit = "3" ) InteropLibrary lib ,
242
+ @ Cached PythonToNativeNode nameToNativeNode ,
243
+ @ Cached PythonToNativeNode selfToNativeNode ,
247
244
@ Cached NativeToPythonTransferNode toPythonNode ,
245
+ @ Cached ExternalFunctionInvokeNode externalInvokeNode ,
248
246
@ Cached PyObjectCheckFunctionResultNode checkResultNode ) {
249
- PythonThreadState threadState = getThreadStateNode .execute (inliningTarget , null );
250
247
boolean isGetAttr = isGetAttrProfile .profile (inliningTarget , slots .tp_getattr () == slot );
251
248
Object nameArg ;
252
249
if (isGetAttr ) {
253
250
nameArg = asCharPointerNode .execute (name );
254
251
} else {
255
- nameArg = toNativeNode .execute (name );
252
+ nameArg = nameToNativeNode .execute (name );
256
253
}
257
- Object state = IndirectCallContext .enter (frame , threadState , callData );
258
254
Object result ;
255
+ PythonThreadState threadState = getThreadStateNode .execute (inliningTarget , null );
259
256
try {
260
- result = lib .execute (slot .callable , toNativeNode .execute (self ), nameArg );
261
- } catch (InteropException e ) {
262
- throw CompilerDirectives .shouldNotReachHere (e );
257
+ result = externalInvokeNode .call (frame , inliningTarget , threadState , C_API_TIMING , T___GETATTR__ , slot .callable , selfToNativeNode .execute (self ), nameArg );
263
258
} finally {
264
- if (frame != null ) {
265
- PArguments .setException (frame , threadState .getCaughtException ());
266
- }
267
- IndirectCallContext .exit (frame , threadState , state );
268
259
if (isGetAttr ) {
269
260
freeNode .free (nameArg );
270
261
}
0 commit comments