46
46
import com .oracle .graal .python .builtins .objects .method .PBuiltinMethod ;
47
47
import com .oracle .graal .python .builtins .objects .method .PMethod ;
48
48
import com .oracle .graal .python .nodes .PNodeWithContext ;
49
- import com .oracle .truffle .api .CompilerDirectives ;
49
+ import com .oracle .truffle .api .dsl . Cached ;
50
50
import com .oracle .truffle .api .dsl .Specialization ;
51
51
52
52
public abstract class GetSignatureNode extends PNodeWithContext {
53
- @ Child private GetFunctionCodeNode getCodeNode ;
54
-
55
- private GetFunctionCodeNode getGetCodeNode () {
56
- if (getCodeNode == null ) {
57
- CompilerDirectives .transferToInterpreterAndInvalidate ();
58
- getCodeNode = GetFunctionCodeNode .create ();
59
- }
60
- return getCodeNode ;
61
- }
62
-
63
- private Signature doFunctionInternal (PFunction function ) {
64
- return getGetCodeNode ().execute (function ).getSignature ();
53
+ private Signature doFunctionInternal (GetFunctionCodeNode getFunctionCodeNode , PFunction function ) {
54
+ return getFunctionCodeNode .execute (function ).getSignature ();
65
55
}
66
56
67
- private Signature doMethodInternal (Object function ) {
57
+ private Signature doMethodInternal (GetFunctionCodeNode getFunctionCodeNode , Object function ) {
68
58
if (function instanceof PFunction ) {
69
- return doFunctionInternal ((PFunction ) function );
59
+ return doFunctionInternal (getFunctionCodeNode , (PFunction ) function );
70
60
} else if (function instanceof PBuiltinFunction ) {
71
61
return ((PBuiltinFunction ) function ).getSignature ();
72
62
}
@@ -76,8 +66,9 @@ private Signature doMethodInternal(Object function) {
76
66
public abstract Signature execute (Object function );
77
67
78
68
@ Specialization
79
- Signature doFunction (PFunction function ) {
80
- return doFunctionInternal (function );
69
+ Signature doFunction (PFunction function ,
70
+ @ Cached ("create()" ) GetFunctionCodeNode getFunctionCodeNode ) {
71
+ return doFunctionInternal (getFunctionCodeNode , function );
81
72
}
82
73
83
74
@ Specialization
@@ -86,13 +77,15 @@ Signature doBuiltinFunction(PBuiltinFunction builtinFunction) {
86
77
}
87
78
88
79
@ Specialization
89
- Signature doMethod (PMethod method ) {
90
- return doMethodInternal (method .getFunction ());
80
+ Signature doMethod (PMethod method ,
81
+ @ Cached ("create()" ) GetFunctionCodeNode getFunctionCodeNode ) {
82
+ return doMethodInternal (getFunctionCodeNode , method .getFunction ());
91
83
}
92
84
93
85
@ Specialization
94
- Signature doBuiltinMethod (PBuiltinMethod builtinMethod ) {
95
- return doMethodInternal (builtinMethod .getFunction ());
86
+ Signature doBuiltinMethod (PBuiltinMethod builtinMethod ,
87
+ @ Cached ("create()" ) GetFunctionCodeNode getFunctionCodeNode ) {
88
+ return doMethodInternal (getFunctionCodeNode , builtinMethod .getFunction ());
96
89
}
97
90
98
91
public static GetSignatureNode create () {
0 commit comments