48
48
BootstrapInfo::BootstrapInfo (const constantPoolHandle& pool, int bss_index, int indy_index)
49
49
: _pool(pool),
50
50
_bss_index(bss_index),
51
- _indy_index(indy_index),
52
- // derived and eagerly cached:
53
- _argc( pool->bootstrap_argument_count_at (bss_index) ),
54
- _name( pool->uncached_name_ref_at (bss_index) ),
55
- _signature( pool->uncached_signature_ref_at (bss_index) )
51
+ _indy_index(indy_index)
56
52
{
57
- _is_resolved = false ;
53
+ assert (bss_index != 0 , " " );
54
+ _bsm_attr_index = _pool->bootstrap_methods_attribute_index (_bss_index);
55
+ _name = pool->uncached_name_ref_at (bss_index);
56
+ _signature = pool->uncached_signature_ref_at (bss_index);
58
57
assert (pool->tag_at (bss_index).has_bootstrap (), " " );
59
58
assert (indy_index == -1 || pool->resolved_indy_entry_at (indy_index)->constant_pool_index () == bss_index, " invalid bootstrap specifier index" );
59
+ _is_resolved = false ;
60
+ }
61
+
62
+ ResolvedIndyEntry* BootstrapInfo::indy_entry () const {
63
+ if (_indy_index >= 0 ) {
64
+ return _pool->resolved_indy_entry_at (_indy_index);
65
+ }
66
+ return nullptr ;
60
67
}
61
68
62
69
// If there is evidence this call site was already linked, set the
@@ -130,7 +137,9 @@ void BootstrapInfo::resolve_args(TRAPS) {
130
137
assert (_bsm.not_null (), " resolve_bsm first" );
131
138
132
139
// if there are no static arguments, return leaving _arg_values as null
133
- if (_argc == 0 && UseBootstrapCallInfo < 2 ) return ;
140
+ BSMAttributeEntry* attr = bsm_attr ();
141
+ int argc = attr->argument_count ();
142
+ if (argc == 0 && UseBootstrapCallInfo < 2 ) return ;
134
143
135
144
bool use_BSCI;
136
145
switch (UseBootstrapCallInfo) {
@@ -156,8 +165,8 @@ void BootstrapInfo::resolve_args(TRAPS) {
156
165
// potentially cyclic cases from C to Java.
157
166
if (!use_BSCI && _pool->tag_at (_bss_index).is_dynamic_constant ()) {
158
167
bool found_unresolved_condy = false ;
159
- for (int i = 0 ; i < _argc ; i++) {
160
- int arg_index = _pool-> bootstrap_argument_index_at (_bss_index, i);
168
+ for (int i = 0 ; i < argc ; i++) {
169
+ int arg_index = attr-> argument_index ( i);
161
170
if (_pool->tag_at (arg_index).is_dynamic_constant ()) {
162
171
// potential recursion point condy -> condy
163
172
bool found_it = false ;
@@ -170,14 +179,14 @@ void BootstrapInfo::resolve_args(TRAPS) {
170
179
}
171
180
172
181
const int SMALL_ARITY = 5 ;
173
- if (use_BSCI && _argc <= SMALL_ARITY && UseBootstrapCallInfo <= 2 ) {
182
+ if (use_BSCI && argc <= SMALL_ARITY && UseBootstrapCallInfo <= 2 ) {
174
183
// If there are only a few arguments, and none of them need linking,
175
184
// push them, instead of asking the JDK runtime to turn around and
176
185
// pull them, saving a JVM/JDK transition in some simple cases.
177
186
bool all_resolved = true ;
178
- for (int i = 0 ; i < _argc ; i++) {
187
+ for (int i = 0 ; i < argc ; i++) {
179
188
bool found_it = false ;
180
- int arg_index = _pool-> bootstrap_argument_index_at (_bss_index, i);
189
+ int arg_index = attr-> argument_index ( i);
181
190
_pool->find_cached_constant_at (arg_index, found_it, CHECK);
182
191
if (!found_it) { all_resolved = false ; break ; }
183
192
}
@@ -187,10 +196,11 @@ void BootstrapInfo::resolve_args(TRAPS) {
187
196
188
197
if (!use_BSCI) {
189
198
// return {arg...}; resolution of arguments is done immediately, before JDK code is called
190
- objArrayOop args_oop = oopFactory::new_objArray (vmClasses::Object_klass (), _argc , CHECK);
199
+ objArrayOop args_oop = oopFactory::new_objArray (vmClasses::Object_klass (), argc , CHECK);
191
200
objArrayHandle args (THREAD, args_oop);
192
- _pool->copy_bootstrap_arguments_at (_bss_index, 0 , _argc, args, 0 , true , Handle (), CHECK);
193
- oop arg_oop = ((_argc == 1 ) ? args->obj_at (0 ) : (oop)nullptr );
201
+ _pool->copy_bootstrap_arguments_at (_bsm_attr_index,
202
+ 0 , argc, args, 0 , true , Handle (), CHECK);
203
+ oop arg_oop = ((argc == 1 ) ? args->obj_at (0 ) : (oop)nullptr );
194
204
// try to discard the singleton array
195
205
if (arg_oop != nullptr && !arg_oop->is_array ()) {
196
206
// JVM treats arrays and nulls specially in this position,
@@ -200,10 +210,12 @@ void BootstrapInfo::resolve_args(TRAPS) {
200
210
_arg_values = args;
201
211
}
202
212
} else {
203
- // return {arg_count, pool_index}; JDK code must pull the arguments as needed
204
- typeArrayOop ints_oop = oopFactory::new_typeArray (T_INT, 2 , CHECK);
205
- ints_oop->int_at_put (0 , _argc);
213
+ // return {arg_count, pool_index, indy_index}
214
+ // JDK code must pull the arguments as needed
215
+ typeArrayOop ints_oop = oopFactory::new_typeArray (T_INT, 3 , CHECK);
216
+ ints_oop->int_at_put (0 , argc);
206
217
ints_oop->int_at_put (1 , _bss_index);
218
+ ints_oop->int_at_put (2 , _indy_index);
207
219
_arg_values = Handle (THREAD, ints_oop);
208
220
}
209
221
}
@@ -236,6 +248,7 @@ void BootstrapInfo::print_msg_on(outputStream* st, const char* msg) {
236
248
os::snprintf_checked (what, sizeof (what), " condy" );
237
249
}
238
250
bool have_msg = (msg != nullptr && strlen (msg) > 0 );
251
+ int argc = arg_count ();
239
252
st->print_cr (" %s%sBootstrap in %s %s@CP[%d] %s:%s%s BSMS[%d] BSM@CP[%d]%s argc=%d%s" ,
240
253
(have_msg ? msg : " " ), (have_msg ? " " : " " ),
241
254
caller ()->name ()->as_C_string (),
@@ -244,13 +257,13 @@ void BootstrapInfo::print_msg_on(outputStream* st, const char* msg) {
244
257
_name->as_C_string (),
245
258
_signature->as_C_string (),
246
259
(_type_arg.is_null () ? " " : " (resolved)" ),
247
- bsms_attr_index (),
260
+ bsm_attr_index (),
248
261
bsm_index (), (_bsm.is_null () ? " " : " (resolved)" ),
249
- _argc , (_arg_values.is_null () ? " " : " (resolved)" ));
250
- if (_argc > 0 ) {
262
+ argc , (_arg_values.is_null () ? " " : " (resolved)" ));
263
+ if (argc > 0 ) {
251
264
char argbuf[80 ];
252
265
argbuf[0 ] = 0 ;
253
- for (int i = 0 ; i < _argc ; i++) {
266
+ for (int i = 0 ; i < argc ; i++) {
254
267
int pos = (int ) strlen (argbuf);
255
268
if (pos + 20 > (int )sizeof (argbuf)) {
256
269
os::snprintf_checked (argbuf + pos, sizeof (argbuf) - pos, " ..." );
@@ -272,11 +285,11 @@ void BootstrapInfo::print_msg_on(outputStream* st, const char* msg) {
272
285
// Find the static arguments within the first element of _arg_values.
273
286
objArrayOop static_args = (objArrayOop)_arg_values ();
274
287
if (!static_args->is_array ()) {
275
- assert (_argc == 1 , " Invalid BSM _arg_values for non-array" );
288
+ assert (argc == 1 , " Invalid BSM _arg_values for non-array" );
276
289
st->print (" resolved arg[0]: " ); static_args->print_on (st);
277
290
} else if (static_args->is_objArray ()) {
278
291
int lines = 0 ;
279
- for (int i = 0 ; i < _argc ; i++) {
292
+ for (int i = 0 ; i < argc ; i++) {
280
293
oop x = static_args->obj_at (i);
281
294
if (x != nullptr ) {
282
295
if (++lines > 6 ) {
0 commit comments