7575import com .oracle .truffle .api .nodes .DirectCallNode ;
7676import com .oracle .truffle .api .nodes .IndirectCallNode ;
7777import com .oracle .truffle .api .nodes .Node ;
78+ import com .oracle .truffle .api .nodes .RootNode ;
7879import com .oracle .truffle .api .profiles .InlinedConditionProfile ;
7980
8081public class CallDispatchers {
@@ -192,8 +193,9 @@ static Object callBuiltinFunctionCached(VirtualFrame frame, Node inliningTarget,
192193 return invoke .execute (frame , inliningTarget , callNode , arguments );
193194 }
194195
195- @ Specialization (guards = "sameCallTarget( callee.getCallTargetOrNull(), callNode) " , limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callBuiltinFunctionCached" )
196+ @ Specialization (guards = "callee.getFunctionRootNode() == rootNode " , limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callBuiltinFunctionCached" )
196197 static Object callBuiltinFunctionCachedCt (VirtualFrame frame , Node inliningTarget , @ SuppressWarnings ("unused" ) PBuiltinFunction callee , Object [] arguments ,
198+ @ SuppressWarnings ("unused" ) @ Cached (value = "callee.getFunctionRootNode()" , adopt = false ) RootNode rootNode ,
197199 @ Cached ("createDirectCallNodeFor(callee)" ) DirectCallNode callNode ,
198200 @ Exclusive @ Cached SimpleDirectInvokeNode invoke ) {
199201 return invoke .execute (frame , inliningTarget , callNode , arguments );
@@ -231,8 +233,9 @@ static Object callBuiltinFunctionCached(VirtualFrame frame, Node inliningTarget,
231233 return invoke .execute (frame , inliningTarget , callNode , pArguments );
232234 }
233235
234- @ Specialization (guards = "sameCallTarget( callee.getCallTargetOrNull(), callNode) " , limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callBuiltinFunctionCached" )
236+ @ Specialization (guards = "callee.getFunctionRootNode() == rootNode " , limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callBuiltinFunctionCached" )
235237 static Object callBuiltinFunctionCachedCt (VirtualFrame frame , Node inliningTarget , PBuiltinFunction callee , Object [] arguments , PKeyword [] keywords ,
238+ @ SuppressWarnings ("unused" ) @ Cached (value = "callee.getFunctionRootNode()" , adopt = false ) RootNode rootNode ,
236239 @ Exclusive @ Cached CreateArgumentsNode createArgs ,
237240 @ Cached ("createDirectCallNodeFor(callee)" ) DirectCallNode callNode ,
238241 @ Exclusive @ Cached SimpleDirectInvokeNode invoke ) {
@@ -287,9 +290,10 @@ static Object callBuiltinMethodCached(VirtualFrame frame, Node inliningTarget, @
287290 return invoke .execute (frame , inliningTarget , callNode , pArguments );
288291 }
289292
290- @ Specialization (guards = "sameCallTarget( function.getCallTargetOrNull(), callNode) " , limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callBuiltinMethodCached" )
293+ @ Specialization (guards = "function.getFunctionRootNode() == rootNode " , limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callBuiltinMethodCached" )
291294 static Object callBuiltinMethodCachedCt (VirtualFrame frame , Node inliningTarget , PBuiltinMethod callee , Object [] arguments , PKeyword [] keywords ,
292295 @ Bind ("callee.getBuiltinFunction()" ) PBuiltinFunction function ,
296+ @ SuppressWarnings ("unused" ) @ Cached (value = "function.getFunctionRootNode()" , adopt = false ) RootNode rootNode ,
293297 @ Exclusive @ Cached CreateArgumentsNode createArgs ,
294298 @ Cached ("createDirectCallNodeFor(function)" ) DirectCallNode callNode ,
295299 @ Exclusive @ Cached SimpleDirectInvokeNode invoke ) {
@@ -390,8 +394,9 @@ static Object callFunctionCached(VirtualFrame frame, Node inliningTarget, @Suppr
390394 }
391395
392396 // We have multiple contexts, don't cache the objects so that contexts can be cleaned up
393- @ Specialization (guards = {"sameCallTarget( callee.getCallTargetOrNull(), callNode) " }, limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callFunctionCached" )
397+ @ Specialization (guards = {"callee.getCode().getRootNode() == rootNode " }, limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callFunctionCached" )
394398 static Object callFunctionCachedCt (VirtualFrame frame , Node inliningTarget , PFunction callee , Object [] arguments ,
399+ @ SuppressWarnings ("unused" ) @ Cached (value = "callee.getCode().getRootNode()" , adopt = false ) RootNode rootNode ,
395400 @ Cached ("createDirectCallNodeFor(callee)" ) DirectCallNode callNode ,
396401 @ Exclusive @ Cached FunctionDirectInvokeNode invoke ) {
397402 return invoke .execute (frame , inliningTarget , callNode , callee , arguments );
@@ -408,7 +413,7 @@ static Object callFunctionMegamorphic(VirtualFrame frame, Node inliningTarget, P
408413
409414 /**
410415 * Node for calling python functions with an inline cache on the function object and a secondary
411- * inline cache on the call target. Takes PArguments
416+ * inline cache on the call target.
412417 */
413418 @ GenerateInline
414419 @ GenerateCached (false )
@@ -430,8 +435,9 @@ static Object callFunctionCached(VirtualFrame frame, Node inliningTarget, @Suppr
430435 }
431436
432437 // We have multiple contexts, don't cache the objects so that contexts can be cleaned up
433- @ Specialization (guards = {"sameCallTarget( callee.getCallTargetOrNull(), callNode) " }, limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callFunctionCached" )
438+ @ Specialization (guards = {"callee.getCode().getRootNode() == rootNode " }, limit = "getCallSiteInlineCacheMaxDepth()" , replaces = "callFunctionCached" )
434439 static Object callFunctionCachedCt (VirtualFrame frame , Node inliningTarget , PFunction callee , Object [] arguments , PKeyword [] keywords ,
440+ @ SuppressWarnings ("unused" ) @ Cached (value = "callee.getCode().getRootNode()" , adopt = false ) RootNode rootNode ,
435441 @ Exclusive @ Cached CreateArgumentsNode createArgs ,
436442 @ Cached ("createDirectCallNodeFor(callee)" ) DirectCallNode callNode ,
437443 @ Exclusive @ Cached FunctionDirectInvokeNode invoke ) {
0 commit comments