44
44
import com .oracle .graal .python .builtins .objects .function .PKeyword ;
45
45
import com .oracle .graal .python .builtins .objects .method .PBuiltinMethod ;
46
46
import com .oracle .graal .python .nodes .call .CallNode ;
47
- import com .oracle .graal .python .nodes .call .special .CallTernaryMethodNodeGen ;
48
47
import com .oracle .graal .python .nodes .function .builtins .PythonQuaternaryBuiltinNode ;
49
48
import com .oracle .graal .python .nodes .function .builtins .PythonTernaryBuiltinNode ;
50
49
import com .oracle .truffle .api .RootCallTarget ;
57
56
58
57
@ ReportPolymorphism
59
58
@ GenerateUncached
60
- public abstract class CallTernaryMethodNode extends CallSpecialMethodNode {
61
-
59
+ public abstract class CallTernaryMethodNode extends CallReversibleMethodNode {
62
60
public static CallTernaryMethodNode create () {
63
- return CallTernaryMethodNodeGen .create ();
61
+ return CallTernaryMethodNodeGen .create (false );
62
+ }
63
+
64
+ static CallTernaryMethodNode createReversed () {
65
+ return CallTernaryMethodNodeGen .create (true );
64
66
}
65
67
66
68
public static CallTernaryMethodNode getUncached () {
@@ -71,38 +73,82 @@ public static CallTernaryMethodNode getUncached() {
71
73
72
74
public abstract Object execute (Frame frame , Object callable , Object arg1 , Object arg2 , Object arg3 );
73
75
74
- @ Specialization (guards = {"func == cachedFunc" , "builtinNode != null" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
76
+ @ Specialization (guards = {"func == cachedFunc" , "builtinNode != null" , "!isReverse" ,
77
+ "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
75
78
Object doBuiltinFunctionOIOCached (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , int arg2 , Object arg3 ,
76
79
@ SuppressWarnings ("unused" ) @ Cached ("func" ) PBuiltinFunction cachedFunc ,
80
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
77
81
@ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
78
82
@ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
79
83
return builtinNode .executeWithInt (frame , arg1 , arg2 , arg3 );
80
84
}
81
85
82
- @ Specialization (guards = {"func == cachedFunc" , "builtinNode != null" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
86
+ @ Specialization (guards = {"func == cachedFunc" , "builtinNode != null" , "isReverse" ,
87
+ "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
88
+ Object doBuiltinFunctionOIOCachedReverse (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , int arg2 , Object arg3 ,
89
+ @ SuppressWarnings ("unused" ) @ Cached ("func" ) PBuiltinFunction cachedFunc ,
90
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
91
+ @ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
92
+ @ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
93
+ return builtinNode .execute (frame , arg2 , arg1 , arg3 );
94
+ }
95
+
96
+ @ Specialization (guards = {"func == cachedFunc" , "builtinNode != null" , "!isReverse" ,
97
+ "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
83
98
Object doBuiltinFunctionCached (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , Object arg2 , Object arg3 ,
84
99
@ SuppressWarnings ("unused" ) @ Cached ("func" ) PBuiltinFunction cachedFunc ,
100
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
85
101
@ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
86
102
@ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
87
103
return builtinNode .execute (frame , arg1 , arg2 , arg3 );
88
104
}
89
105
90
- @ Specialization (guards = {"func.getCallTarget() == ct" , "builtinNode != null" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" )
106
+ @ Specialization (guards = {"func == cachedFunc" , "builtinNode != null" , "isReverse" ,
107
+ "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
108
+ Object doBuiltinFunctionCachedReverse (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , Object arg2 , Object arg3 ,
109
+ @ SuppressWarnings ("unused" ) @ Cached ("func" ) PBuiltinFunction cachedFunc ,
110
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
111
+ @ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
112
+ @ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
113
+ return builtinNode .execute (frame , arg2 , arg1 , arg3 );
114
+ }
115
+
116
+ @ Specialization (guards = {"func.getCallTarget() == ct" , "builtinNode != null" , "!isReverse" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" )
91
117
Object doBuiltinFunctionOIOCtCached (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , int arg2 , Object arg3 ,
92
118
@ SuppressWarnings ("unused" ) @ Cached ("func.getCallTarget()" ) RootCallTarget ct ,
119
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
93
120
@ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
94
121
@ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
95
122
return builtinNode .executeWithInt (frame , arg1 , arg2 , arg3 );
96
123
}
97
124
98
- @ Specialization (guards = {"func.getCallTarget() == ct" , "builtinNode != null" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" )
125
+ @ Specialization (guards = {"func.getCallTarget() == ct" , "builtinNode != null" , "isReverse" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" )
126
+ Object doBuiltinFunctionOIOCtCachedReverse (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , int arg2 , Object arg3 ,
127
+ @ SuppressWarnings ("unused" ) @ Cached ("func.getCallTarget()" ) RootCallTarget ct ,
128
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
129
+ @ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
130
+ @ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
131
+ return builtinNode .execute (frame , arg2 , arg1 , arg3 );
132
+ }
133
+
134
+ @ Specialization (guards = {"func.getCallTarget() == ct" , "builtinNode != null" , "!isReverse" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" )
99
135
Object doBuiltinFunctionCtCached (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , Object arg2 , Object arg3 ,
100
136
@ SuppressWarnings ("unused" ) @ Cached ("func.getCallTarget()" ) RootCallTarget ct ,
137
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
101
138
@ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
102
139
@ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
103
140
return builtinNode .execute (frame , arg1 , arg2 , arg3 );
104
141
}
105
142
143
+ @ Specialization (guards = {"func.getCallTarget() == ct" , "builtinNode != null" , "isReverse" , "frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" )
144
+ Object doBuiltinFunctionCtCachedReverse (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinFunction func , Object arg1 , Object arg2 , Object arg3 ,
145
+ @ SuppressWarnings ("unused" ) @ Cached ("func.getCallTarget()" ) RootCallTarget ct ,
146
+ @ SuppressWarnings ("unused" ) @ Cached ("isForReverseBinaryOperation(func.getCallTarget())" ) boolean isReverse ,
147
+ @ Cached ("getTernary(frame, func)" ) PythonTernaryBuiltinNode builtinNode ,
148
+ @ SuppressWarnings ("unused" ) @ Cached ("frameIsUnused(builtinNode)" ) boolean unusedFrame ) {
149
+ return builtinNode .execute (frame , arg2 , arg1 , arg3 );
150
+ }
151
+
106
152
@ Specialization (guards = {"func == cachedFunc" , "builtinNode != null" , "!takesSelfArg" ,
107
153
"frame != null || unusedFrame" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "singleContextAssumption()" )
108
154
Object doBuiltinMethodOIOCached (VirtualFrame frame , @ SuppressWarnings ("unused" ) PBuiltinMethod func , Object arg1 , int arg2 , Object arg3 ,
@@ -160,8 +206,10 @@ Object callSelfMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMe
160
206
return builtinNode .execute (frame , func .getSelf (), arg1 , arg2 , arg3 );
161
207
}
162
208
163
- @ Specialization (replaces = {"doBuiltinFunctionOIOCached" , "doBuiltinFunctionCached" , "doBuiltinFunctionOIOCtCached" , "doBuiltinFunctionCtCached" , "doBuiltinMethodOIOCached" ,
164
- "doBuiltinMethodCached" , "doBuiltinMethodOIOCtCached" , "doBuiltinMethodCtCached" , "callSelfMethodSingleContext" , "callSelfMethod" })
209
+ @ Specialization (replaces = {"doBuiltinFunctionOIOCached" , "doBuiltinFunctionCached" , "doBuiltinFunctionOIOCtCached" , "doBuiltinFunctionCtCached" ,
210
+ "doBuiltinFunctionOIOCachedReverse" , "doBuiltinFunctionCachedReverse" , "doBuiltinFunctionOIOCtCachedReverse" , "doBuiltinFunctionCtCachedReverse" ,
211
+ "doBuiltinMethodOIOCached" , "doBuiltinMethodCached" , "doBuiltinMethodOIOCtCached" , "doBuiltinMethodCtCached" , "callSelfMethodSingleContext" ,
212
+ "callSelfMethod" })
165
213
static Object call (VirtualFrame frame , Object func , Object arg1 , Object arg2 , Object arg3 ,
166
214
@ Cached CallNode callNode ) {
167
215
return callNode .execute (frame , func , new Object []{arg1 , arg2 , arg3 }, PKeyword .EMPTY_KEYWORDS );
0 commit comments