4747
4848import com .oracle .graal .python .PythonLanguage ;
4949import com .oracle .graal .python .builtins .objects .cext .capi .CExtNodes .AsCharPointerNode ;
50+ import com .oracle .graal .python .builtins .objects .cext .capi .ExternalFunctionNodes .ExternalFunctionInvokeNode ;
5051import com .oracle .graal .python .builtins .objects .cext .capi .ExternalFunctionNodes .PExternalFunctionWrapper ;
5152import com .oracle .graal .python .builtins .objects .cext .capi .ExternalFunctionNodes .PyObjectCheckFunctionResultNode ;
53+ import com .oracle .graal .python .builtins .objects .cext .capi .transitions .CApiTiming ;
5254import com .oracle .graal .python .builtins .objects .cext .capi .transitions .CApiTransitions .NativeToPythonTransferNode ;
5355import com .oracle .graal .python .builtins .objects .cext .capi .transitions .CApiTransitions .PythonToNativeNode ;
5456import com .oracle .graal .python .builtins .objects .cext .structs .CStructAccess .FreeNode ;
6466import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
6567import com .oracle .graal .python .nodes .object .BuiltinClassProfiles .IsBuiltinObjectProfile ;
6668import com .oracle .graal .python .runtime .ExecutionContext .CallContext ;
67- import com .oracle .graal .python .runtime .ExecutionContext .IndirectCallContext ;
68- import com .oracle .graal .python .runtime .IndirectCallData ;
6969import com .oracle .graal .python .runtime .PythonContext .GetThreadStateNode ;
7070import com .oracle .graal .python .runtime .PythonContext .PythonThreadState ;
7171import com .oracle .graal .python .runtime .exception .PException ;
72- import com .oracle .truffle .api .CompilerDirectives ;
7372import com .oracle .truffle .api .HostCompilerDirectives .InliningCutoff ;
7473import com .oracle .truffle .api .RootCallTarget ;
7574import com .oracle .truffle .api .dsl .Bind ;
8281import com .oracle .truffle .api .dsl .NodeFactory ;
8382import com .oracle .truffle .api .dsl .Specialization ;
8483import 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 ;
8884import com .oracle .truffle .api .nodes .IndirectCallNode ;
8985import com .oracle .truffle .api .nodes .Node ;
9086import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
@@ -232,6 +228,8 @@ static Object callNative(VirtualFrame frame, TpSlots slots, TpSlotNative slot, O
232228 @ GenerateInline (false ) // Used lazily
233229 @ GenerateUncached
234230 abstract static class CallNativeSlotGetAttrNode extends Node {
231+ private static final CApiTiming C_API_TIMING = CApiTiming .create (true , "tp_getattr" );
232+
235233 abstract Object execute (VirtualFrame frame , TpSlots slots , TpSlotNative tp_get_attro_attr , Object self , Object name );
236234
237235 @ Specialization
@@ -241,30 +239,23 @@ static Object callNative(VirtualFrame frame, TpSlots slots, TpSlotNative slot, O
241239 @ Cached InlinedConditionProfile isGetAttrProfile ,
242240 @ Cached AsCharPointerNode asCharPointerNode ,
243241 @ 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 ,
247244 @ Cached NativeToPythonTransferNode toPythonNode ,
245+ @ Cached ExternalFunctionInvokeNode externalInvokeNode ,
248246 @ Cached PyObjectCheckFunctionResultNode checkResultNode ) {
249- PythonThreadState threadState = getThreadStateNode .execute (inliningTarget , null );
250247 boolean isGetAttr = isGetAttrProfile .profile (inliningTarget , slots .tp_getattr () == slot );
251248 Object nameArg ;
252249 if (isGetAttr ) {
253250 nameArg = asCharPointerNode .execute (name );
254251 } else {
255- nameArg = toNativeNode .execute (name );
252+ nameArg = nameToNativeNode .execute (name );
256253 }
257- Object state = IndirectCallContext .enter (frame , threadState , callData );
258254 Object result ;
255+ PythonThreadState threadState = getThreadStateNode .execute (inliningTarget , null );
259256 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 );
263258 } finally {
264- if (frame != null ) {
265- PArguments .setException (frame , threadState .getCaughtException ());
266- }
267- IndirectCallContext .exit (frame , threadState , state );
268259 if (isGetAttr ) {
269260 freeNode .free (nameArg );
270261 }
0 commit comments