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
+ import com .oracle .graal .python .nodes .builtins .FunctionNodes .GetDefaultsNode ;
64
+ import com .oracle .graal .python .nodes .builtins .FunctionNodes .GetKeywordDefaultsNode ;
65
+ import com .oracle .graal .python .nodes .builtins .FunctionNodes .GetSignatureNode ;
64
66
import com .oracle .graal .python .runtime .PythonOptions ;
65
67
import com .oracle .graal .python .runtime .exception .PException ;
66
68
import com .oracle .truffle .api .CompilerDirectives ;
@@ -81,13 +83,15 @@ public static CreateArgumentsNode create() {
81
83
Object [] doMethodCached (PythonObject method , Object [] userArguments , PKeyword [] keywords ,
82
84
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
83
85
@ Cached ("create()" ) GetSignatureNode getSignatureNode ,
86
+ @ Cached ("create()" ) GetDefaultsNode getDefaultsNode ,
87
+ @ Cached ("create()" ) GetKeywordDefaultsNode getKwDefaultsNode ,
84
88
@ Cached ("method" ) @ SuppressWarnings ("unused" ) PythonObject cachedMethod ) {
85
89
86
90
// We do not directly cache these objects because they are compilation final anyway and the
87
91
// getter check the appropriate assumptions.
88
92
Signature signature = getSignatureNode .execute (cachedMethod );
89
- Object [] defaults = getDefaults (cachedMethod );
90
- PKeyword [] kwdefaults = getKwDefaults (cachedMethod );
93
+ Object [] defaults = getDefaultsNode . execute (cachedMethod );
94
+ PKeyword [] kwdefaults = getKwDefaultsNode . execute (cachedMethod );
91
95
Object self = getSelf (cachedMethod );
92
96
return createAndCheckArgumentsNode .execute (method , userArguments , keywords , signature , self , defaults , kwdefaults , isMethodCall (self ));
93
97
}
@@ -98,27 +102,31 @@ Object[] doMethodFunctionAndSelfCached(PythonObject method, Object[] userArgumen
98
102
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
99
103
@ Cached ("getFunction(method)" ) @ SuppressWarnings ("unused" ) Object cachedFunction ,
100
104
@ Cached ("create()" ) GetSignatureNode getSignatureNode ,
105
+ @ Cached ("create()" ) GetDefaultsNode getDefaultsNode ,
106
+ @ Cached ("create()" ) GetKeywordDefaultsNode getKwDefaultsNode ,
101
107
@ Cached ("getSelf(method)" ) Object cachedSelf ) {
102
108
103
109
// We do not directly cache these objects because they are compilation final anyway and the
104
110
// getter check the appropriate assumptions.
105
111
Signature signature = getSignatureNode .execute (cachedFunction );
106
- Object [] defaults = getDefaults (cachedFunction );
107
- PKeyword [] kwdefaults = getKwDefaults (cachedFunction );
112
+ Object [] defaults = getDefaultsNode . execute (cachedFunction );
113
+ PKeyword [] kwdefaults = getKwDefaultsNode . execute (cachedFunction );
108
114
return createAndCheckArgumentsNode .execute (method , userArguments , keywords , signature , cachedSelf , defaults , kwdefaults , isMethodCall (cachedSelf ));
109
115
}
110
116
111
117
@ Specialization (guards = {"isMethod(method)" , "getFunction(method) == cachedFunction" }, limit = "getVariableArgumentInlineCacheLimit()" , replaces = "doMethodFunctionAndSelfCached" )
112
118
Object [] doMethodFunctionCached (PythonObject method , Object [] userArguments , PKeyword [] keywords ,
113
119
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
114
120
@ Cached ("create()" ) GetSignatureNode getSignatureNode ,
121
+ @ Cached ("create()" ) GetDefaultsNode getDefaultsNode ,
122
+ @ Cached ("create()" ) GetKeywordDefaultsNode getKwDefaultsNode ,
115
123
@ Cached ("getFunction(method)" ) @ SuppressWarnings ("unused" ) Object cachedFunction ) {
116
124
117
125
// We do not directly cache these objects because they are compilation final anyway and the
118
126
// getter check the appropriate assumptions.
119
127
Signature signature = getSignatureNode .execute (cachedFunction );
120
- Object [] defaults = getDefaults (cachedFunction );
121
- PKeyword [] kwdefaults = getKwDefaults (cachedFunction );
128
+ Object [] defaults = getDefaultsNode . execute (cachedFunction );
129
+ PKeyword [] kwdefaults = getKwDefaultsNode . execute (cachedFunction );
122
130
Object self = getSelf (method );
123
131
return createAndCheckArgumentsNode .execute (method , userArguments , keywords , signature , self , defaults , kwdefaults , isMethodCall (self ));
124
132
}
@@ -127,13 +135,15 @@ Object[] doMethodFunctionCached(PythonObject method, Object[] userArguments, PKe
127
135
Object [] doFunctionCached (PythonObject callable , Object [] userArguments , PKeyword [] keywords ,
128
136
@ Cached ("create()" ) CreateAndCheckArgumentsNode createAndCheckArgumentsNode ,
129
137
@ Cached ("create()" ) GetSignatureNode getSignatureNode ,
138
+ @ Cached ("create()" ) GetDefaultsNode getDefaultsNode ,
139
+ @ Cached ("create()" ) GetKeywordDefaultsNode getKwDefaultsNode ,
130
140
@ Cached ("callable" ) @ SuppressWarnings ("unused" ) PythonObject cachedCallable ) {
131
141
132
142
// We do not directly cache these objects because they are compilation final anyway and the
133
143
// getter check the appropriate assumptions.
134
144
Signature signature = getSignatureNode .execute (cachedCallable );
135
- Object [] defaults = getDefaults (cachedCallable );
136
- PKeyword [] kwdefaults = getKwDefaults (cachedCallable );
145
+ Object [] defaults = getDefaultsNode . execute (cachedCallable );
146
+ PKeyword [] kwdefaults = getKwDefaultsNode . execute (cachedCallable );
137
147
return createAndCheckArgumentsNode .execute (callable , userArguments , keywords , signature , null , defaults , kwdefaults , false );
138
148
}
139
149
@@ -589,14 +599,6 @@ protected static PKeyword[] getKwDefaultsUncached(Object callable) {
589
599
return getProperty (callable , UncachedKwDefaultsGetter .INSTANCE );
590
600
}
591
601
592
- protected static Object [] getDefaults (Object callable ) {
593
- return getProperty (callable , DefaultsGetter .INSTANCE );
594
- }
595
-
596
- protected static PKeyword [] getKwDefaults (Object callable ) {
597
- return getProperty (callable , KwDefaultsGetter .INSTANCE );
598
- }
599
-
600
602
protected static String getName (Object callable ) {
601
603
return getProperty (callable , NameGetter .INSTANCE );
602
604
}
@@ -653,34 +655,6 @@ private abstract static class Getter<T> {
653
655
public abstract T fromPBuiltinFunction (PBuiltinFunction fun );
654
656
}
655
657
656
- private static final class DefaultsGetter extends Getter <Object []> {
657
- private static final DefaultsGetter INSTANCE = new DefaultsGetter ();
658
-
659
- @ Override
660
- public Object [] fromPFunction (PFunction fun ) {
661
- return fun .getDefaults ();
662
- }
663
-
664
- @ Override
665
- public Object [] fromPBuiltinFunction (PBuiltinFunction fun ) {
666
- return fun .getDefaults ();
667
- }
668
- }
669
-
670
- private static final class KwDefaultsGetter extends Getter <PKeyword []> {
671
- private static final KwDefaultsGetter INSTANCE = new KwDefaultsGetter ();
672
-
673
- @ Override
674
- public PKeyword [] fromPFunction (PFunction fun ) {
675
- return fun .getKwDefaults ();
676
- }
677
-
678
- @ Override
679
- public PKeyword [] fromPBuiltinFunction (PBuiltinFunction fun ) {
680
- return fun .getKwDefaults ();
681
- }
682
- }
683
-
684
658
private static final class UncachedSignatureGetter extends Getter <Signature > {
685
659
private static final UncachedSignatureGetter INSTANCE = new UncachedSignatureGetter ();
686
660
@@ -700,7 +674,7 @@ private static final class UncachedDefaultsGetter extends Getter<Object[]> {
700
674
701
675
@ Override
702
676
public Object [] fromPFunction (PFunction fun ) {
703
- return fun .getUncachedDefaultValues ();
677
+ return fun .getDefaults ();
704
678
}
705
679
706
680
@ Override
@@ -714,7 +688,7 @@ private static final class UncachedKwDefaultsGetter extends Getter<PKeyword[]> {
714
688
715
689
@ Override
716
690
public PKeyword [] fromPFunction (PFunction fun ) {
717
- return fun .getUncachedKwDefaults ();
691
+ return fun .getKwDefaults ();
718
692
}
719
693
720
694
@ Override
0 commit comments