43
43
import java .util .Arrays ;
44
44
45
45
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
46
- import com .oracle .graal .python .builtins .objects .function .Signature ;
47
46
import com .oracle .graal .python .builtins .objects .function .PArguments ;
48
47
import com .oracle .graal .python .builtins .objects .function .PBuiltinFunction ;
49
48
import com .oracle .graal .python .builtins .objects .function .PFunction ;
50
49
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
50
+ import com .oracle .graal .python .builtins .objects .function .Signature ;
51
51
import com .oracle .graal .python .builtins .objects .method .PBuiltinMethod ;
52
52
import com .oracle .graal .python .builtins .objects .method .PMethod ;
53
53
import com .oracle .graal .python .builtins .objects .module .PythonModule ;
60
60
import com .oracle .graal .python .nodes .argument .CreateArgumentsNodeGen .FillKwDefaultsNodeGen ;
61
61
import com .oracle .graal .python .nodes .argument .CreateArgumentsNodeGen .FindKwDefaultNodeGen ;
62
62
import com .oracle .graal .python .nodes .argument .CreateArgumentsNodeGen .HandleTooManyArgumentsNodeGen ;
63
+ import com .oracle .graal .python .nodes .code .GetSignatureNode ;
63
64
import com .oracle .graal .python .runtime .PythonOptions ;
64
65
import com .oracle .graal .python .runtime .exception .PException ;
65
66
import com .oracle .truffle .api .CompilerDirectives ;
@@ -79,11 +80,12 @@ public static CreateArgumentsNode create() {
79
80
@ Specialization (guards = {"isMethod(method)" , "method == cachedMethod" }, limit = "getVariableArgumentInlineCacheLimit()" )
80
81
Object [] doMethodCached (PythonObject method , Object [] userArguments , PKeyword [] keywords ,
81
82
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
83
+ @ Cached ("create()" ) GetSignatureNode getSignatureNode ,
82
84
@ Cached ("method" ) @ SuppressWarnings ("unused" ) PythonObject cachedMethod ) {
83
85
84
86
// We do not directly cache these objects because they are compilation final anyway and the
85
87
// getter check the appropriate assumptions.
86
- Signature signature = getSignature (cachedMethod );
88
+ Signature signature = getSignatureNode . execute (cachedMethod );
87
89
Object [] defaults = getDefaults (cachedMethod );
88
90
PKeyword [] kwdefaults = getKwDefaults (cachedMethod );
89
91
Object self = getSelf (cachedMethod );
@@ -95,11 +97,12 @@ Object[] doMethodCached(PythonObject method, Object[] userArguments, PKeyword[]
95
97
Object [] doMethodFunctionAndSelfCached (PythonObject method , Object [] userArguments , PKeyword [] keywords ,
96
98
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
97
99
@ Cached ("getFunction(method)" ) @ SuppressWarnings ("unused" ) Object cachedFunction ,
100
+ @ Cached ("create()" ) GetSignatureNode getSignatureNode ,
98
101
@ Cached ("getSelf(method)" ) Object cachedSelf ) {
99
102
100
103
// We do not directly cache these objects because they are compilation final anyway and the
101
104
// getter check the appropriate assumptions.
102
- Signature signature = getSignature (cachedFunction );
105
+ Signature signature = getSignatureNode . execute (cachedFunction );
103
106
Object [] defaults = getDefaults (cachedFunction );
104
107
PKeyword [] kwdefaults = getKwDefaults (cachedFunction );
105
108
return createAndCheckArgumentsNode .execute (method , userArguments , keywords , signature , cachedSelf , defaults , kwdefaults , isMethodCall (cachedSelf ));
@@ -108,11 +111,12 @@ Object[] doMethodFunctionAndSelfCached(PythonObject method, Object[] userArgumen
108
111
@ Specialization (guards = {"isMethod(method)" , "getFunction(method) == cachedFunction" }, limit = "getVariableArgumentInlineCacheLimit()" , replaces = "doMethodFunctionAndSelfCached" )
109
112
Object [] doMethodFunctionCached (PythonObject method , Object [] userArguments , PKeyword [] keywords ,
110
113
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
114
+ @ Cached ("create()" ) GetSignatureNode getSignatureNode ,
111
115
@ Cached ("getFunction(method)" ) @ SuppressWarnings ("unused" ) Object cachedFunction ) {
112
116
113
117
// We do not directly cache these objects because they are compilation final anyway and the
114
118
// getter check the appropriate assumptions.
115
- Signature signature = getSignature (cachedFunction );
119
+ Signature signature = getSignatureNode . execute (cachedFunction );
116
120
Object [] defaults = getDefaults (cachedFunction );
117
121
PKeyword [] kwdefaults = getKwDefaults (cachedFunction );
118
122
Object self = getSelf (method );
@@ -122,11 +126,12 @@ Object[] doMethodFunctionCached(PythonObject method, Object[] userArguments, PKe
122
126
@ Specialization (guards = {"isFunction(callable)" , "callable == cachedCallable" }, limit = "getVariableArgumentInlineCacheLimit()" )
123
127
Object [] doFunctionCached (PythonObject callable , Object [] userArguments , PKeyword [] keywords ,
124
128
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
129
+ @ Cached ("create()" ) GetSignatureNode getSignatureNode ,
125
130
@ Cached ("callable" ) @ SuppressWarnings ("unused" ) PythonObject cachedCallable ) {
126
131
127
132
// We do not directly cache these objects because they are compilation final anyway and the
128
133
// getter check the appropriate assumptions.
129
- Signature signature = getSignature (cachedCallable );
134
+ Signature signature = getSignatureNode . execute (cachedCallable );
130
135
Object [] defaults = getDefaults (cachedCallable );
131
136
PKeyword [] kwdefaults = getKwDefaults (cachedCallable );
132
137
return createAndCheckArgumentsNode .execute (callable , userArguments , keywords , signature , null , defaults , kwdefaults , false );
@@ -584,10 +589,6 @@ protected static PKeyword[] getKwDefaultsUncached(Object callable) {
584
589
return getProperty (callable , UncachedKwDefaultsGetter .INSTANCE );
585
590
}
586
591
587
- protected static Signature getSignature (Object callable ) {
588
- return getProperty (callable , SignatureGetter .INSTANCE );
589
- }
590
-
591
592
protected static Object [] getDefaults (Object callable ) {
592
593
return getProperty (callable , DefaultsGetter .INSTANCE );
593
594
}
@@ -652,20 +653,6 @@ private abstract static class Getter<T> {
652
653
public abstract T fromPBuiltinFunction (PBuiltinFunction fun );
653
654
}
654
655
655
- private static final class SignatureGetter extends Getter <Signature > {
656
- private static final SignatureGetter INSTANCE = new SignatureGetter ();
657
-
658
- @ Override
659
- public Signature fromPFunction (PFunction fun ) {
660
- return fun .getSignature ();
661
- }
662
-
663
- @ Override
664
- public Signature fromPBuiltinFunction (PBuiltinFunction fun ) {
665
- return fun .getSignature ();
666
- }
667
- }
668
-
669
656
private static final class DefaultsGetter extends Getter <Object []> {
670
657
private static final DefaultsGetter INSTANCE = new DefaultsGetter ();
671
658
@@ -699,7 +686,7 @@ private static final class UncachedSignatureGetter extends Getter<Signature> {
699
686
700
687
@ Override
701
688
public Signature fromPFunction (PFunction fun ) {
702
- return fun .getUncachedCode ().getSignature ();
689
+ return fun .getCode ().getSignature ();
703
690
}
704
691
705
692
@ Override
0 commit comments