Skip to content

Commit 24b3f1e

Browse files
committed
Fixing fixing
1 parent 3aaca4a commit 24b3f1e

15 files changed

+200
-191
lines changed

src/hotspot/share/cds/classListParser.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -570,24 +570,22 @@ void ClassListParser::populate_cds_indy_info(const constantPoolHandle &pool, int
570570
cii->add_item(pool->symbol_at(name_index)->as_C_string());
571571
int sig_index = pool->signature_ref_index_at(type_index);
572572
cii->add_item(pool->symbol_at(sig_index)->as_C_string());
573-
auto bsme = pool->bootstrap_methods_attribute_entry(cp_index);
574-
int argc = bsme->argument_count();;
575-
if (argc > 0) {
576-
for (int arg_i = 0; arg_i < argc; arg_i++) {
577-
int arg = bsme->argument_index(arg_i);
578-
jbyte tag = pool->tag_at(arg).value();
579-
if (tag == JVM_CONSTANT_MethodType) {
580-
cii->add_item(pool->method_type_signature_at(arg)->as_C_string());
581-
} else if (tag == JVM_CONSTANT_MethodHandle) {
582-
cii->add_ref_kind(pool->method_handle_ref_kind_at(arg));
583-
int callee_index = pool->method_handle_klass_index_at(arg);
584-
Klass* callee = pool->klass_at(callee_index, CHECK);
585-
cii->add_item(callee->name()->as_C_string());
586-
cii->add_item(pool->method_handle_name_ref_at(arg)->as_C_string());
587-
cii->add_item(pool->method_handle_signature_ref_at(arg)->as_C_string());
588-
} else {
589-
ShouldNotReachHere();
590-
}
573+
BSMAttributeEntry* bsme = pool->bootstrap_methods_attribute_entry(cp_index);
574+
int argc = bsme->argument_count();
575+
for (int arg_i = 0; arg_i < argc; arg_i++) {
576+
int arg = bsme->argument_index(arg_i);
577+
jbyte tag = pool->tag_at(arg).value();
578+
if (tag == JVM_CONSTANT_MethodType) {
579+
cii->add_item(pool->method_type_signature_at(arg)->as_C_string());
580+
} else if (tag == JVM_CONSTANT_MethodHandle) {
581+
cii->add_ref_kind(pool->method_handle_ref_kind_at(arg));
582+
int callee_index = pool->method_handle_klass_index_at(arg);
583+
Klass* callee = pool->klass_at(callee_index, CHECK);
584+
cii->add_item(callee->name()->as_C_string());
585+
cii->add_item(pool->method_handle_name_ref_at(arg)->as_C_string());
586+
cii->add_item(pool->method_handle_signature_ref_at(arg)->as_C_string());
587+
} else {
588+
ShouldNotReachHere();
591589
}
592590
}
593591
}

src/hotspot/share/ci/ciEnv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
821821
// Patch the call site to the nmethod entry point of the static compiled lambda form.
822822
// As with other two-component call sites, both values must be independently verified.
823823
assert(index < cpool->cache()->resolved_indy_entries_length(), "impossible");
824-
auto rie = cpool->resolved_indy_entry_at(index);
824+
ResolvedIndyEntry* rie = cpool->resolved_indy_entry_at(index);
825825
Method* adapter = rie->method();
826826
// Resolved if the adapter is non null.
827827
if (adapter != nullptr) {

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3279,90 +3279,94 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(const ClassFil
32793279

32803280
cfs->guarantee_more(attribute_byte_length, CHECK);
32813281

3282-
const int attribute_entry_count = cfs->get_u2_fast();
3282+
const u2 num_bootstrap_methods = cfs->get_u2_fast();
32833283

3284-
guarantee_property(_max_bootstrap_specifier_index < attribute_entry_count,
3284+
guarantee_property(_max_bootstrap_specifier_index < num_bootstrap_methods,
32853285
"Short length on BootstrapMethods in class file %s",
32863286
CHECK);
32873287

32883288
// The attribute contains a counted array of counted tuples of shorts,
3289-
// represending bootstrap specifiers:
3289+
// representing bootstrap specifiers:
32903290
// length*{bootstrap_method_index, argument_count, argument_count*{argument_index}}
3291-
const unsigned int attribute_tail_length = attribute_byte_length - (unsigned)sizeof(u2);
3292-
3291+
const u4 attribute_tail_length = attribute_byte_length - static_cast<u4>(sizeof(u2));
3292+
assert(attribute_tail_length % sizeof(u2) == 0, "");
32933293
Array<u4>* const offsets =
3294-
MetadataFactory::new_array<u4>(_loader_data, attribute_entry_count, CHECK);
3294+
MetadataFactory::new_array<u4>(_loader_data, num_bootstrap_methods, CHECK);
32953295
Array<u2>* const entries = // u2 data holding all the BSM attribute entries
32963296
MetadataFactory::new_array<u2>(_loader_data, attribute_tail_length / sizeof(u2), CHECK);
32973297

3298-
// Eagerly assign arrays so they will be deallocated with the constant
3299-
// pool if there is an error.
3298+
// Eagerly assign arrays so they will be deallocated with
3299+
// the constant pool if there is an error.
33003300
cp->set_bsm_attribute_offsets(offsets);
33013301
cp->set_bsm_attribute_entries(entries);
33023302

33033303
int next_entry = 0;
33043304
const int cp_size = cp->length();
33053305

3306-
for (int n = 0; n < attribute_entry_count; n++) {
3306+
for (int n = 0; n < num_bootstrap_methods; n++) {
33073307
// Store a 32-bit offset into the array of BSM entry offsets.
33083308
offsets->at_put(n, next_entry);
33093309

33103310
// Read a bootstrap method attribute entry.
33113311
cfs->guarantee_more(sizeof(u2) * 2, CHECK); // bsm, argc
3312-
const u2 bootstrap_method_index = cfs->get_u2_fast();
3313-
const u2 argument_count = cfs->get_u2_fast();
3312+
const u2 bootstrap_method_ref = cfs->get_u2_fast();
3313+
const u2 num_bootstrap_arguments = cfs->get_u2_fast();
33143314
guarantee_property(
3315-
valid_cp_range(bootstrap_method_index, cp_size) &&
3316-
cp->tag_at(bootstrap_method_index).is_method_handle(),
3315+
valid_cp_range(bootstrap_method_ref, cp_size) &&
3316+
cp->tag_at(bootstrap_method_ref).is_method_handle(),
33173317
"bootstrap_method_index %u has bad constant type in class file %s",
3318-
bootstrap_method_index,
3318+
bootstrap_method_ref,
33193319
CHECK);
33203320

3321-
guarantee_property((next_entry + 2 + argument_count) <= entries->length(),
3321+
guarantee_property((next_entry + 2 + num_bootstrap_arguments) <= entries->length(),
33223322
"Invalid BootstrapMethods num_bootstrap_methods or num_bootstrap_arguments value in class file %s",
33233323
CHECK);
33243324

3325-
entries->at_put(next_entry++, bootstrap_method_index);
3326-
entries->at_put(next_entry++, argument_count);
3325+
entries->at_put(next_entry, bootstrap_method_ref);
3326+
next_entry++;
3327+
entries->at_put(next_entry, num_bootstrap_arguments);
3328+
next_entry++;
33273329

3328-
cfs->guarantee_more(sizeof(u2) * argument_count, CHECK); // argv[argc]
3329-
for (int j = 0; j < argument_count; j++) {
3330+
cfs->guarantee_more(sizeof(u2) * num_bootstrap_arguments, CHECK); // argv[argc]
3331+
for (u2 j = 0; j < num_bootstrap_arguments; j++) {
33303332
const u2 argument_index = cfs->get_u2_fast();
33313333
guarantee_property(
33323334
valid_cp_range(argument_index, cp_size) &&
33333335
cp->tag_at(argument_index).is_loadable_constant(),
33343336
"argument_index %u has bad constant type in class file %s",
33353337
argument_index,
33363338
CHECK);
3337-
entries->at_put(next_entry++, argument_index);
3339+
entries->at_put(next_entry, argument_index);
3340+
next_entry++;
33383341
}
33393342
}
33403343
guarantee_property(current_start + attribute_byte_length == cfs->current(),
33413344
"Bad length on BootstrapMethods in class file %s",
33423345
CHECK);
33433346
assert(next_entry == entries->length(), "");
33443347

3345-
// check access methods, for extra luck
3346-
if (attribute_entry_count > 0) {
3347-
auto bsme = cp->bsm_attribute_entry(0);
3348+
#ifdef ASSERT
3349+
if (num_bootstrap_methods > 0) {
3350+
BSMAttributeEntry* bsme = cp->bsm_attribute_entry(0);
33483351
assert(bsme->bootstrap_method_index() == entries->at(0), "");
33493352
assert(bsme->argument_count() == entries->at(1), "");
3350-
int nexti = (attribute_entry_count == 1) ? entries->length() : offsets->at(1);
3353+
int nexti = (num_bootstrap_methods == 1) ? entries->length() : offsets->at(1);
33513354
assert(nexti == 2 + bsme->argument_count(), "");
3352-
if (attribute_entry_count > 1) {
3355+
if (num_bootstrap_methods > 1) {
33533356
bsme = cp->bsm_attribute_entry(1);
33543357
assert(bsme->bootstrap_method_index() == entries->at(nexti+0), "");
33553358
assert(bsme->argument_count() == entries->at(nexti+1), "");
33563359
}
33573360
int lasti = offsets->at(offsets->length() - 1);
3358-
bsme = cp->bsm_attribute_entry(attribute_entry_count - 1);
3361+
bsme = cp->bsm_attribute_entry(num_bootstrap_methods - 1);
33593362
assert(bsme->bootstrap_method_index() == entries->at(lasti+0), "");
33603363
assert(bsme->argument_count() == entries->at(lasti+1), "");
33613364
int lastu2 = entries->at(entries->length() - 1);
33623365
int lastac = bsme->argument_count();
33633366
int expect_lastu2 = (lastac == 0) ? 0 : bsme->argument_index(lastac-1);
33643367
assert(lastu2 == expect_lastu2, "");
33653368
}
3369+
#endif
33663370
}
33673371

33683372
void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cfs,

src/hotspot/share/interpreter/bootstrapInfo.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ void BootstrapInfo::resolve_args(TRAPS) {
137137
assert(_bsm.not_null(), "resolve_bsm first");
138138

139139
// if there are no static arguments, return leaving _arg_values as null
140-
BSMAttributeEntry* attr = bsm_attr();
141-
int argc = attr->argument_count();
140+
BSMAttributeEntry& attr = bsm_attr();
141+
int argc = attr.argument_count();
142142
if (argc == 0 && UseBootstrapCallInfo < 2) return;
143143

144144
bool use_BSCI;
@@ -166,16 +166,20 @@ void BootstrapInfo::resolve_args(TRAPS) {
166166
if (!use_BSCI && _pool->tag_at(_bss_index).is_dynamic_constant()) {
167167
bool found_unresolved_condy = false;
168168
for (int i = 0; i < argc; i++) {
169-
int arg_index = attr->argument_index(i);
169+
int arg_index = attr.argument_index(i);
170170
if (_pool->tag_at(arg_index).is_dynamic_constant()) {
171171
// potential recursion point condy -> condy
172172
bool found_it = false;
173173
_pool->find_cached_constant_at(arg_index, found_it, CHECK);
174-
if (!found_it) { found_unresolved_condy = true; break; }
174+
if (!found_it) {
175+
found_unresolved_condy = true;
176+
break;
177+
}
175178
}
176179
}
177-
if (found_unresolved_condy)
180+
if (found_unresolved_condy) {
178181
use_BSCI = true;
182+
}
179183
}
180184

181185
const int SMALL_ARITY = 5;
@@ -186,12 +190,16 @@ void BootstrapInfo::resolve_args(TRAPS) {
186190
bool all_resolved = true;
187191
for (int i = 0; i < argc; i++) {
188192
bool found_it = false;
189-
int arg_index = attr->argument_index(i);
193+
int arg_index = attr.argument_index(i);
190194
_pool->find_cached_constant_at(arg_index, found_it, CHECK);
191-
if (!found_it) { all_resolved = false; break; }
195+
if (!found_it) {
196+
all_resolved = false;
197+
break;
198+
}
192199
}
193-
if (all_resolved)
200+
if (all_resolved) {
194201
use_BSCI = false;
202+
}
195203
}
196204

197205
if (!use_BSCI) {

src/hotspot/share/interpreter/bootstrapInfo.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BootstrapInfo : public StackObj {
4343
Handle _name_arg; // resolved String
4444
Handle _type_arg; // resolved Class or MethodType
4545
Handle _arg_values; // array of static arguments; null implies either
46-
// uresolved or zero static arguments are specified
46+
// unresolved or zero static arguments are specified
4747

4848
// post-bootstrap resolution state:
4949
bool _is_resolved; // set true when any of the next fields are set
@@ -76,10 +76,10 @@ class BootstrapInfo : public StackObj {
7676
// derived accessors
7777
InstanceKlass* caller() const { return _pool->pool_holder(); }
7878
oop caller_mirror() const { return caller()->java_mirror(); }
79-
BSMAttributeEntry* bsm_attr() const { return _pool->bsm_attribute_entry(_bsm_attr_index); }
80-
int bsm_index() const { return bsm_attr()->bootstrap_method_index(); }
81-
int arg_count() const { return bsm_attr()->argument_count(); }
82-
int arg_index(int j) const { return bsm_attr()->argument_index(j); }
79+
BSMAttributeEntry& bsm_attr() const { return *_pool->bsm_attribute_entry(_bsm_attr_index); }
80+
int bsm_index() const { return bsm_attr().bootstrap_method_index(); }
81+
int arg_count() const { return bsm_attr().argument_count(); }
82+
int arg_index(int j) const { return bsm_attr().argument_index(j); }
8383
ResolvedIndyEntry* indy_entry() const;
8484

8585
// If there is evidence this call site was already linked, set the

src/hotspot/share/interpreter/bytecodeTracer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ void BytecodePrinter::print_bsm(int cp_index, outputStream* st) {
326326
}
327327
st->print(" BSM: %s", ref_kind);
328328
print_field_or_method(constants()->method_handle_index_at(bsm), st);
329-
auto bsme = constants()->bootstrap_methods_attribute_entry(cp_index);
330-
int argc = bsme->argument_count();;
329+
BSMAttributeEntry* bsme = constants()->bootstrap_methods_attribute_entry(cp_index);
330+
int argc = bsme->argument_count();
331331
st->print(" arguments[%d] = {", argc);
332332
if (argc > 0) {
333333
st->cr();

src/hotspot/share/oops/array.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class Array: public MetaspaceObj {
126126
T at(int i) const { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return data()[i]; }
127127
void at_put(const int i, const T& x) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); data()[i] = x; }
128128
T* adr_at(const int i) { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return &data()[i]; }
129+
const T* adr_at(const int i) const { assert(i >= 0 && i< _length, "oob: 0 <= %d < %d", i, _length); return &data()[i]; }
129130
int find(const T& x) { return index_of(x); }
130131

131132
T at_acquire(const int i) { return Atomic::load_acquire(adr_at(i)); }

0 commit comments

Comments
 (0)