22
22
*/
23
23
package com .oracle .truffle .espresso .runtime .dispatch .staticobject ;
24
24
25
+ import com .oracle .truffle .api .dsl .Bind ;
25
26
import com .oracle .truffle .api .dsl .Cached ;
26
27
import com .oracle .truffle .api .dsl .Cached .Exclusive ;
27
28
import com .oracle .truffle .api .dsl .GenerateUncached ;
28
29
import com .oracle .truffle .api .dsl .Specialization ;
29
30
import com .oracle .truffle .api .interop .ArityException ;
30
31
import com .oracle .truffle .api .interop .UnknownIdentifierException ;
31
32
import com .oracle .truffle .api .interop .UnsupportedTypeException ;
33
+ import com .oracle .truffle .api .nodes .Node ;
32
34
import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
33
35
import com .oracle .truffle .espresso .impl .Klass ;
34
36
import com .oracle .truffle .espresso .impl .Method ;
@@ -71,7 +73,8 @@ public abstract Object execute(StaticObject receiver, Klass klass, Object[] argu
71
73
@ GenerateUncached
72
74
public abstract static class Virtual extends InteropLookupAndInvoke {
73
75
@ Specialization
74
- public Object doVirtual (StaticObject receiver , Klass klass , Object [] arguments , String member ,
76
+ Object doVirtual (StaticObject receiver , Klass klass , Object [] arguments , String member ,
77
+ @ Bind Node node ,
75
78
@ Cached LookupVirtualMethodNode lookup ,
76
79
@ Cached SelectAndInvokeNode selectAndInvoke ,
77
80
@ Cached InlinedBranchProfile error ,
@@ -80,17 +83,18 @@ public Object doVirtual(StaticObject receiver, Klass klass, Object[] arguments,
80
83
assert receiver != null ;
81
84
Method [] candidates = lookup .execute (klass , member , arguments .length );
82
85
if (candidates != null ) {
83
- return selectAndInvoke (selectAndInvoke , exception , receiver , arguments , candidates );
86
+ return selectAndInvoke (selectAndInvoke , exception , node , receiver , arguments , candidates );
84
87
}
85
- error .enter (this );
88
+ error .enter (node );
86
89
throw ArityException .create (arguments .length + 1 , -1 , arguments .length );
87
90
}
88
91
}
89
92
90
93
@ GenerateUncached
91
94
public abstract static class NonVirtual extends InteropLookupAndInvoke {
92
95
@ Specialization
93
- public Object doNonVirtual (StaticObject receiver , Klass klass , Object [] arguments , String member ,
96
+ Object doNonVirtual (StaticObject receiver , Klass klass , Object [] arguments , String member ,
97
+ @ Bind Node node ,
94
98
@ Cached LookupDeclaredMethod lookup ,
95
99
@ Cached SelectAndInvokeNode selectAndInvoke ,
96
100
@ Cached InlinedBranchProfile error ,
@@ -99,19 +103,20 @@ public Object doNonVirtual(StaticObject receiver, Klass klass, Object[] argument
99
103
boolean isStatic = receiver == null ;
100
104
Method [] candidates = lookup .execute (klass , member , true , isStatic , arguments .length );
101
105
if (candidates != null ) {
102
- return selectAndInvoke (selectAndInvoke , exception , receiver , arguments , candidates );
106
+ return selectAndInvoke (selectAndInvoke , exception , node , receiver , arguments , candidates );
103
107
}
104
- error .enter (this );
108
+ error .enter (node );
105
109
throw ArityException .create (arguments .length + 1 , -1 , arguments .length );
106
110
}
107
111
}
108
112
109
- Object selectAndInvoke (SelectAndInvokeNode selectAndInvoke , InlinedBranchProfile exception ,
113
+ Object selectAndInvoke (SelectAndInvokeNode selectAndInvoke ,
114
+ InlinedBranchProfile exception , Node node ,
110
115
StaticObject receiver , Object [] args , Method [] candidates ) throws UnsupportedTypeException , ArityException {
111
116
try {
112
117
return selectAndInvoke .execute (receiver , args , candidates );
113
118
} catch (EspressoException e ) {
114
- exception .enter (this );
119
+ exception .enter (node );
115
120
throw InteropUtils .unwrapExceptionBoundary (getLanguage (), e , getMeta ());
116
121
}
117
122
}
@@ -121,7 +126,7 @@ abstract static class SelectAndInvokeNode extends EspressoNode {
121
126
public abstract Object execute (StaticObject receiver , Object [] args , Method [] candidates ) throws ArityException , UnsupportedTypeException ;
122
127
123
128
@ Specialization (guards = {"isSingleNonVarargs(candidates)" })
124
- Object doSingleNonVarargs (StaticObject receiver , Object [] args , Method [] candidates ,
129
+ static Object doSingleNonVarargs (StaticObject receiver , Object [] args , Method [] candidates ,
125
130
@ Cached @ Exclusive InvokeEspressoNode invoke ,
126
131
@ Cached InteropUnwrapNode unwrapNode )
127
132
throws ArityException , UnsupportedTypeException {
@@ -133,7 +138,8 @@ Object doSingleNonVarargs(StaticObject receiver, Object[] args, Method[] candida
133
138
}
134
139
135
140
@ Specialization (guards = {"isSingleVarargs(candidates)" })
136
- Object doSingleVarargs (StaticObject receiver , Object [] args , Method [] candidates ,
141
+ static Object doSingleVarargs (StaticObject receiver , Object [] args , Method [] candidates ,
142
+ @ Bind Node node ,
137
143
@ Cached @ Exclusive InvokeEspressoNode invoke ,
138
144
@ Cached ToEspressoNode .DynamicToEspresso toEspresso ,
139
145
@ Cached InteropUnwrapNode unwrapNode ,
@@ -148,12 +154,13 @@ Object doSingleVarargs(StaticObject receiver, Object[] args, Method[] candidates
148
154
assert matched != null ;
149
155
return invoke .execute (matched .getMethod (), receiver , matched .getConvertedArgs (), true , unwrapNode );
150
156
}
151
- error .enter (this );
157
+ error .enter (node );
152
158
throw UnsupportedTypeException .create (args );
153
159
}
154
160
155
161
@ Specialization (guards = {"isMulti(candidates)" })
156
- Object doMulti (StaticObject receiver , Object [] args , Method [] candidates ,
162
+ static Object doMulti (StaticObject receiver , Object [] args , Method [] candidates ,
163
+ @ Bind Node node ,
157
164
@ Cached OverLoadedMethodSelectorNode selector ,
158
165
@ Cached @ Exclusive InvokeEspressoNode invoke ,
159
166
@ Cached InteropUnwrapNode unwrapNode ,
@@ -165,7 +172,7 @@ Object doMulti(StaticObject receiver, Object[] args, Method[] candidates,
165
172
return invoke .execute (typeMatched .getMethod (), receiver , typeMatched .getConvertedArgs (), true , unwrapNode );
166
173
} else {
167
174
// unable to select exactly one best candidate for the input args!
168
- error .enter (this );
175
+ error .enter (node );
169
176
throw UnsupportedTypeException .create (args );
170
177
}
171
178
}
0 commit comments