Skip to content

Commit c867ec0

Browse files
author
John Rose
committed
remove about 25 obsolete methods from constantPool.hpp, adjusting client code
1 parent c59f394 commit c867ec0

29 files changed

+387
-442
lines changed

src/hotspot/share/cds/aotConstantPoolResolver.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ bool AOTConstantPoolResolver::is_resolution_deterministic(ConstantPool* cp, int
6464
return resolved_klass != nullptr && is_class_resolution_deterministic(cp->pool_holder(), resolved_klass);
6565
} else if (cp->tag_at(cp_index).is_invoke_dynamic()) {
6666
return is_indy_resolution_deterministic(cp, cp_index);
67-
} else if (cp->tag_at(cp_index).is_field() ||
68-
cp->tag_at(cp_index).is_method() ||
69-
cp->tag_at(cp_index).is_interface_method()) {
70-
int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
67+
} else if (cp->tag_at(cp_index).is_field_or_method()) {
68+
int klass_cp_index = cp->uncached_field_or_method_ref_at(cp_index).klass_index();
7169
if (!cp->tag_at(klass_cp_index).is_klass()) {
7270
// Not yet resolved
7371
return false;
@@ -283,13 +281,14 @@ void AOTConstantPoolResolver::maybe_resolve_fmi_ref(InstanceKlass* ik, Method* m
283281
return;
284282
}
285283

286-
int klass_cp_index = cp->uncached_klass_ref_index_at(cp_index);
284+
int klass_cp_index = cp->uncached_field_or_method_ref_at(cp_index).klass_index();
287285
if (find_loaded_class(THREAD, cp(), klass_cp_index) == nullptr) {
288286
// Do not resolve any field/methods from a class that has not been loaded yet.
289287
return;
290288
}
291289

292-
Klass* resolved_klass = cp->klass_ref_at(raw_index, bc, CHECK);
290+
auto fmiref = cp->from_bytecode_ref_at(raw_index, bc);
291+
Klass* resolved_klass = fmiref.klass(cp, CHECK);
293292

294293
switch (bc) {
295294
case Bytecodes::_getfield:
@@ -314,8 +313,8 @@ void AOTConstantPoolResolver::maybe_resolve_fmi_ref(InstanceKlass* ik, Method* m
314313
if (log_is_enabled(Trace, cds, resolve)) {
315314
ResourceMark rm(THREAD);
316315
bool resolved = cp->is_resolved(raw_index, bc);
317-
Symbol* name = cp->name_ref_at(raw_index, bc);
318-
Symbol* signature = cp->signature_ref_at(raw_index, bc);
316+
Symbol* name = fmiref.name(cp);
317+
Symbol* signature = fmiref.signature(cp);
319318
log_trace(cds, resolve)("%s %s [%3d] %s -> %s.%s:%s",
320319
(resolved ? "Resolved" : "Failed to resolve"),
321320
Bytecodes::name(bc), cp_index, ik->external_name(),
@@ -410,14 +409,14 @@ bool AOTConstantPoolResolver::check_lambda_metafactory_signature(ConstantPool* c
410409
return !exclude;
411410
}
412411

413-
bool AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i) {
414-
int mt_index = cp->bsm_attribute_entry(bsms_attribute_index)->argument_index(arg_i);
412+
bool AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg(ConstantPool* cp, BSMAttributeEntry* bsme, int arg_i) {
413+
int mt_index = bsme->argument_index(arg_i);
415414
if (!cp->tag_at(mt_index).is_method_type()) {
416415
// malformed class?
417416
return false;
418417
}
419418

420-
Symbol* sig = cp->method_type_signature_at(mt_index);
419+
Symbol* sig = cp->method_type_ref_at(mt_index).signature(cp);
421420
if (log_is_enabled(Debug, cds, resolve)) {
422421
ResourceMark rm;
423422
log_debug(cds, resolve)("Checking MethodType for LambdaMetafactory BSM arg %d: %s", arg_i, sig->as_C_string());
@@ -426,14 +425,14 @@ bool AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg(ConstantPo
426425
return check_methodtype_signature(cp, sig);
427426
}
428427

429-
bool AOTConstantPoolResolver::check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i) {
430-
int mh_index = cp->bsm_attribute_entry(bsms_attribute_index)->argument_index(arg_i);
428+
bool AOTConstantPoolResolver::check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, BSMAttributeEntry* bsme, int arg_i) {
429+
int mh_index = bsme->argument_index(arg_i);
431430
if (!cp->tag_at(mh_index).is_method_handle()) {
432431
// malformed class?
433432
return false;
434433
}
435434

436-
Symbol* sig = cp->method_handle_signature_ref_at(mh_index);
435+
Symbol* sig = cp->method_handle_ref_at(mh_index).signature(cp);
437436
if (log_is_enabled(Debug, cds, resolve)) {
438437
ResourceMark rm;
439438
log_debug(cds, resolve)("Checking MethodType of MethodHandle for LambdaMetafactory BSM arg %d: %s", arg_i, sig->as_C_string());
@@ -452,12 +451,13 @@ bool AOTConstantPoolResolver::is_indy_resolution_deterministic(ConstantPool* cp,
452451
return false;
453452
}
454453

455-
int bsms_attribute_index = cp->bootstrap_methods_attribute_index(cp_index);
456-
int bsm = cp->bsm_attribute_entry(bsms_attribute_index)->bootstrap_method_index();
457-
int bsm_ref = cp->method_handle_index_at(bsm);
458-
Symbol* bsm_name = cp->uncached_name_ref_at(bsm_ref);
459-
Symbol* bsm_signature = cp->uncached_signature_ref_at(bsm_ref);
460-
Symbol* bsm_klass = cp->klass_name_at(cp->uncached_klass_ref_index_at(bsm_ref));
454+
auto indy = cp->uncached_bootstrap_specifier_ref_at(cp_index);
455+
auto bsme = indy.bsme(cp);
456+
auto bsmh = bsme->bootstrap_method(cp);
457+
Symbol* bsm_name = bsmh.name(cp);
458+
Symbol* bsm_signature = bsmh.signature(cp);
459+
Symbol* bsm_klass = bsmh.klass_name(cp);
460+
Symbol* factory_type_sig = indy.signature(cp);
461461

462462
// We currently support only StringConcatFactory::makeConcatWithConstants() and LambdaMetafactory::metafactory()
463463
// We should mark the allowed BSMs in the JDK code using a private annotation.
@@ -471,7 +471,6 @@ bool AOTConstantPoolResolver::is_indy_resolution_deterministic(ConstantPool* cp,
471471
"Ljava/lang/String;"
472472
"[Ljava/lang/Object;"
473473
")Ljava/lang/invoke/CallSite;")) {
474-
Symbol* factory_type_sig = cp->uncached_signature_ref_at(cp_index);
475474
if (log_is_enabled(Debug, cds, resolve)) {
476475
ResourceMark rm;
477476
log_debug(cds, resolve)("Checking StringConcatFactory callsite signature [%d]: %s", cp_index, factory_type_sig->as_C_string());
@@ -523,7 +522,6 @@ bool AOTConstantPoolResolver::is_indy_resolution_deterministic(ConstantPool* cp,
523522
* In simple use cases this is the same as
524523
* {@code interfaceMethodType}.
525524
*/
526-
Symbol* factory_type_sig = cp->uncached_signature_ref_at(cp_index);
527525
if (log_is_enabled(Debug, cds, resolve)) {
528526
ResourceMark rm;
529527
log_debug(cds, resolve)("Checking indy callsite signature [%d]: %s", cp_index, factory_type_sig->as_C_string());
@@ -533,24 +531,24 @@ bool AOTConstantPoolResolver::is_indy_resolution_deterministic(ConstantPool* cp,
533531
return false;
534532
}
535533

536-
int arg_count = cp->bsm_attribute_entry(bsms_attribute_index)->argument_count();
534+
int arg_count = bsme->argument_count();
537535
if (arg_count != 3) {
538536
// Malformed class?
539537
return false;
540538
}
541539

542540
// interfaceMethodType
543-
if (!check_lambda_metafactory_methodtype_arg(cp, bsms_attribute_index, 0)) {
541+
if (!check_lambda_metafactory_methodtype_arg(cp, bsme, 0)) {
544542
return false;
545543
}
546544

547545
// implementation
548-
if (!check_lambda_metafactory_methodhandle_arg(cp, bsms_attribute_index, 1)) {
546+
if (!check_lambda_metafactory_methodhandle_arg(cp, bsme, 1)) {
549547
return false;
550548
}
551549

552550
// dynamicMethodType
553-
if (!check_lambda_metafactory_methodtype_arg(cp, bsms_attribute_index, 2)) {
551+
if (!check_lambda_metafactory_methodtype_arg(cp, bsme, 2)) {
554552
return false;
555553
}
556554

src/hotspot/share/cds/aotConstantPoolResolver.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "utilities/macros.hpp"
3535
#include "utilities/resourceHash.hpp"
3636

37+
class BSMAttributeEntry;
3738
class ConstantPool;
3839
class constantPoolHandle;
3940
class InstanceKlass;
@@ -76,8 +77,8 @@ class AOTConstantPoolResolver : AllStatic {
7677

7778
static bool check_methodtype_signature(ConstantPool* cp, Symbol* sig, Klass** return_type_ret = nullptr);
7879
static bool check_lambda_metafactory_signature(ConstantPool* cp, Symbol* sig);
79-
static bool check_lambda_metafactory_methodtype_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i);
80-
static bool check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, int bsms_attribute_index, int arg_i);
80+
static bool check_lambda_metafactory_methodtype_arg(ConstantPool* cp, BSMAttributeEntry* bsme, int arg_i);
81+
static bool check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, BSMAttributeEntry* bsme, int arg_i);
8182

8283
public:
8384
static void initialize();

src/hotspot/share/cds/classListParser.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,26 +535,27 @@ InstanceKlass* ClassListParser::load_class_from_source(Symbol* class_name, TRAPS
535535

536536
void ClassListParser::populate_cds_indy_info(const constantPoolHandle &pool, int cp_index, CDSIndyInfo* cii, TRAPS) {
537537
// Caller needs to allocate ResourceMark.
538-
int type_index = pool->bootstrap_name_and_type_ref_index_at(cp_index);
539-
int name_index = pool->name_ref_index_at(type_index);
538+
auto indy = pool->uncached_bootstrap_specifier_ref_at(cp_index);
539+
int name_index = indy.name_index();
540540
cii->add_item(pool->symbol_at(name_index)->as_C_string());
541-
int sig_index = pool->signature_ref_index_at(type_index);
541+
int sig_index = indy.signature_index();
542542
cii->add_item(pool->symbol_at(sig_index)->as_C_string());
543-
auto bsme = pool->bootstrap_methods_attribute_entry(cp_index);
543+
auto bsme = indy.bsme(pool);
544544
int argc = bsme->argument_count();;
545545
if (argc > 0) {
546546
for (int arg_i = 0; arg_i < argc; arg_i++) {
547547
int arg = bsme->argument_index(arg_i);
548548
jbyte tag = pool->tag_at(arg).value();
549549
if (tag == JVM_CONSTANT_MethodType) {
550-
cii->add_item(pool->method_type_signature_at(arg)->as_C_string());
550+
auto ref = pool->method_type_ref_at(arg);
551+
cii->add_item(ref.signature(pool)->as_C_string());
551552
} else if (tag == JVM_CONSTANT_MethodHandle) {
552-
cii->add_ref_kind(pool->method_handle_ref_kind_at(arg));
553-
int callee_index = pool->method_handle_klass_index_at(arg);
554-
Klass* callee = pool->klass_at(callee_index, CHECK);
553+
auto ref = pool->method_handle_ref_at(arg);
554+
cii->add_ref_kind(ref.ref_kind());
555+
Klass* callee = ref.klass(pool, CHECK); // use ref.klass_name here?
555556
cii->add_item(callee->name()->as_C_string());
556-
cii->add_item(pool->method_handle_name_ref_at(arg)->as_C_string());
557-
cii->add_item(pool->method_handle_signature_ref_at(arg)->as_C_string());
557+
cii->add_item(ref.name(pool)->as_C_string());
558+
cii->add_item(ref.signature(pool)->as_C_string());
558559
} else {
559560
ShouldNotReachHere();
560561
}

src/hotspot/share/ci/ciEnv.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -701,18 +701,20 @@ ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool,
701701
} else if (tag.is_method_type() || tag.is_method_type_in_error()) {
702702
// must execute Java code to link this CP entry into cache[i].f1
703703
assert(obj_index >= 0, "should have an object index");
704-
ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));
704+
SymbolicReference ref = cpool->method_type_ref_at(index);
705+
ciSymbol* signature = get_symbol(ref.signature(cpool));
705706
ciObject* ciobj = get_unloaded_method_type_constant(signature);
706707
return ciConstant(T_OBJECT, ciobj);
707708
} else if (tag.is_method_handle() || tag.is_method_handle_in_error()) {
708709
// must execute Java code to link this CP entry into cache[i].f1
709710
assert(obj_index >= 0, "should have an object index");
711+
auto ref = cpool->method_handle_ref_at(index);
710712
bool ignore_will_link;
711-
int ref_kind = cpool->method_handle_ref_kind_at(index);
712-
int callee_index = cpool->method_handle_klass_index_at(index);
713+
int ref_kind = ref.ref_kind();
714+
int callee_index = ref.ref_index();
713715
ciKlass* callee = get_klass_by_index_impl(cpool, callee_index, ignore_will_link, accessor);
714-
ciSymbol* name = get_symbol(cpool->method_handle_name_ref_at(index));
715-
ciSymbol* signature = get_symbol(cpool->method_handle_signature_ref_at(index));
716+
ciSymbol* name = get_symbol(ref.name(cpool));
717+
ciSymbol* signature = get_symbol(ref.signature(cpool));
716718
ciObject* ciobj = get_unloaded_method_handle_constant(callee, name, signature, ref_kind);
717719
return ciConstant(T_OBJECT, ciobj);
718720
} else if (tag.is_dynamic_constant() || tag.is_dynamic_constant_in_error()) {
@@ -834,13 +836,14 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
834836
ciSymbol* signature = get_symbol(rie->signature(cpool()));
835837
return get_unloaded_method(holder, name, signature, accessor);
836838
} else {
837-
const int holder_index = cpool->klass_ref_index_at(index, bc);
839+
auto mref = cpool->from_bytecode_ref_at(index, bc);
840+
const int holder_index = mref.klass_index();
838841
bool holder_is_accessible;
839842
ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
840843

841844
// Get the method's name and signature.
842-
Symbol* name_sym = cpool->name_ref_at(index, bc);
843-
Symbol* sig_sym = cpool->signature_ref_at(index, bc);
845+
Symbol* name_sym = mref.name(cpool);
846+
Symbol* sig_sym = mref.signature(cpool);
844847

845848
if (cpool->has_preresolution()
846849
|| ((holder == ciEnv::MethodHandle_klass() || holder == ciEnv::VarHandle_klass()) &&
@@ -1465,12 +1468,13 @@ void ciEnv::process_invokedynamic(const constantPoolHandle &cp, int indy_index,
14651468

14661469
// Process an invokehandle call site and record any dynamic locations.
14671470
void ciEnv::process_invokehandle(const constantPoolHandle &cp, int index, JavaThread* thread) {
1468-
const int holder_index = cp->klass_ref_index_at(index, Bytecodes::_invokehandle);
1471+
auto mref = cp->from_bytecode_ref_at(index, Bytecodes::_invokehandle);
1472+
const int holder_index = mref.klass_index();
14691473
if (!cp->tag_at(holder_index).is_klass()) {
14701474
return; // not resolved
14711475
}
14721476
Klass* holder = ConstantPool::klass_at_if_loaded(cp, holder_index);
1473-
Symbol* name = cp->name_ref_at(index, Bytecodes::_invokehandle);
1477+
Symbol* name = mref.name(cp);
14741478
if (MethodHandles::is_signature_polymorphic_name(holder, name)) {
14751479
ResolvedMethodEntry* method_entry = cp->resolved_method_entry_at(index);
14761480
if (method_entry->is_resolved(Bytecodes::_invokehandle)) {

src/hotspot/share/ci/ciField.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ ciField::ciField(ciInstanceKlass* klass, int index, Bytecodes::Code bc) :
7979
assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constant-pool");
8080

8181
constantPoolHandle cpool(THREAD, klass->get_instanceKlass()->constants());
82+
SymbolicReference ref = cpool->from_bytecode_ref_at(index, bc);
8283

8384
// Get the field's name, signature, and type.
84-
Symbol* name = cpool->name_ref_at(index, bc);
85+
Symbol* name = ref.name(cpool);
8586
_name = ciEnv::current(THREAD)->get_symbol(name);
8687

87-
int nt_index = cpool->name_and_type_ref_index_at(index, bc);
88-
int sig_index = cpool->signature_ref_index_at(nt_index);
89-
Symbol* signature = cpool->symbol_at(sig_index);
88+
Symbol* signature = ref.signature(cpool);
9089
_signature = ciEnv::current(THREAD)->get_symbol(signature);
9190

9291
BasicType field_type = Signature::basic_type(signature);
@@ -97,6 +96,7 @@ ciField::ciField(ciInstanceKlass* klass, int index, Bytecodes::Code bc) :
9796
bool ignore;
9897
// This is not really a class reference; the index always refers to the
9998
// field's type signature, as a symbol. Linkage checks do not apply.
99+
int sig_index = ref.signature_index();
100100
_type = ciEnv::current(THREAD)->get_klass_by_index(cpool, sig_index, ignore, klass);
101101
} else {
102102
_type = ciType::make(field_type);
@@ -108,7 +108,7 @@ ciField::ciField(ciInstanceKlass* klass, int index, Bytecodes::Code bc) :
108108
//
109109
// Note: we actually create a ciInstanceKlass for this klass,
110110
// even though we may not need to.
111-
int holder_index = cpool->klass_ref_index_at(index, bc);
111+
int holder_index = ref.klass_index();
112112
bool holder_is_accessible;
113113

114114
ciKlass* generic_declared_holder = ciEnv::current(THREAD)->get_klass_by_index(cpool, holder_index,

src/hotspot/share/ci/ciReplay.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,9 @@ class CompileReplay : public StackObj {
419419
pool_index = cp->resolved_indy_entry_at(index)->constant_pool_index();
420420
} else if (bytecode.is_invokehandle()) {
421421
#ifdef ASSERT
422-
Klass* holder = cp->klass_ref_at(index, bytecode.code(), CHECK_NULL);
423-
Symbol* name = cp->name_ref_at(index, bytecode.code());
422+
auto ref = cp->from_bytecode_ref_at(index, bytecode.code());
423+
Klass* holder = ref.klass(cp, CHECK_NULL);
424+
Symbol* name = ref.name(cp);
424425
assert(MethodHandles::is_signature_polymorphic_name(holder, name), "");
425426
#endif
426427
ResolvedMethodEntry* method_entry = cp->cache()->set_method_handle(index, callInfo);

src/hotspot/share/ci/ciStreams.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() {
342342
int ciBytecodeStream::get_field_holder_index() {
343343
GUARDED_VM_ENTRY(
344344
ConstantPool* cpool = _holder->get_instanceKlass()->constants();
345-
return cpool->klass_ref_index_at(get_field_index(), _bc);
345+
return cpool->from_bytecode_ref_at(get_field_index(), _bc).klass_index();
346346
)
347347
}
348348

@@ -526,7 +526,7 @@ ciKlass* ciBytecodeStream::get_declared_method_holder() {
526526
// deoptimization information.
527527
int ciBytecodeStream::get_method_holder_index() {
528528
ConstantPool* cpool = _method->get_Method()->constants();
529-
return cpool->klass_ref_index_at(get_method_index(), _bc);
529+
return cpool->from_bytecode_ref_at(get_method_index(), _bc).klass_index();
530530
}
531531

532532
// ------------------------------------------------------------------
@@ -537,8 +537,6 @@ int ciBytecodeStream::get_method_holder_index() {
537537
// deoptimization information.
538538
int ciBytecodeStream::get_method_signature_index(const constantPoolHandle& cpool) {
539539
GUARDED_VM_ENTRY(
540-
const int method_index = get_method_index();
541-
const int name_and_type_index = cpool->name_and_type_ref_index_at(method_index, _bc);
542-
return cpool->signature_ref_index_at(name_and_type_index);
540+
return cpool->from_bytecode_ref_at(get_method_index(), _bc).signature_index();
543541
)
544542
}

src/hotspot/share/classfile/bytecodeAssembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ void BytecodeConstantPool::init() {
4444
entry = BytecodeCPEntry::utf8(_orig->symbol_at(i));
4545
break;
4646
case JVM_CONSTANT_NameAndType:
47-
entry = BytecodeCPEntry::name_and_type(_orig->name_ref_index_at(i), _orig->signature_ref_index_at(i));
47+
entry = BytecodeCPEntry::name_and_type(_orig->name_and_type_pair_at(i));
4848
break;
4949
case JVM_CONSTANT_Methodref:
50-
entry = BytecodeCPEntry::methodref(_orig->uncached_klass_ref_index_at(i), _orig->uncached_name_and_type_ref_index_at(i));
50+
entry = BytecodeCPEntry::methodref(_orig->uncached_field_or_method_ref_at(i));
5151
break;
5252
case JVM_CONSTANT_String:
5353
entry = BytecodeCPEntry::string(_orig->unresolved_string_at(i));

src/hotspot/share/classfile/bytecodeAssembler.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,20 @@ class BytecodeCPEntry {
104104
bcpe._u.name_and_type.type_index = type;
105105
return bcpe;
106106
}
107+
static BytecodeCPEntry name_and_type(const SymbolicReference& ref) {
108+
assert(ref.tag().is_name_and_type(), "");
109+
return name_and_type(ref.name_index(), ref.signature_index());
110+
}
107111

108112
static BytecodeCPEntry methodref(u2 class_index, u2 nat) {
109113
BytecodeCPEntry bcpe(METHODREF);
110114
bcpe._u.methodref.class_index = class_index;
111115
bcpe._u.methodref.name_and_type_index = nat;
112116
return bcpe;
113117
}
118+
static BytecodeCPEntry methodref(const SymbolicReference& ref) {
119+
return methodref(ref.klass_index(), ref.nt_index());
120+
}
114121

115122
static bool equals(BytecodeCPEntry const& e0, BytecodeCPEntry const& e1) {
116123
// The hash is the "union trick" value of the information saved for the tag,

0 commit comments

Comments
 (0)