Skip to content

Commit 0dbf67b

Browse files
author
John Rose
committed
move CP indexing structs inside of ConstantPool; rename BSReference as BootstrapReference
1 parent a22a964 commit 0dbf67b

17 files changed

+296
-335
lines changed

src/hotspot/share/cds/aotConstantPoolResolver.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ bool AOTConstantPoolResolver::check_lambda_metafactory_signature(ConstantPool* c
411411
return !exclude;
412412
}
413413

414-
bool AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg(ConstantPool* cp, BSMAttributeEntry* bsme, int arg_i) {
414+
bool AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg(ConstantPool* cp, int bsme_index, int arg_i) {
415+
BSMAttributeEntry* bsme = cp->bsm_attribute_entry(bsme_index);
415416
int mt_index = bsme->argument_index(arg_i);
416417
if (!cp->tag_at(mt_index).is_method_type()) {
417418
// malformed class?
@@ -428,7 +429,8 @@ bool AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg(ConstantPo
428429
return check_methodtype_signature(cp, sig);
429430
}
430431

431-
bool AOTConstantPoolResolver::check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, BSMAttributeEntry* bsme, int arg_i) {
432+
bool AOTConstantPoolResolver::check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, int bsme_index, int arg_i) {
433+
BSMAttributeEntry* bsme = cp->bsm_attribute_entry(bsme_index);
432434
int mh_index = bsme->argument_index(arg_i);
433435
if (!cp->tag_at(mh_index).is_method_handle()) {
434436
// malformed class?
@@ -455,9 +457,10 @@ bool AOTConstantPoolResolver::is_indy_resolution_deterministic(ConstantPool* cp,
455457
return false;
456458
}
457459

458-
BSReference indy(cp, cp_index);
460+
BootstrapReference indy(cp, cp_index);
459461
BSMAttributeEntry* bsme = indy.bsme(cp);
460462
MethodHandleReference bsmh = bsme->bootstrap_method(cp);
463+
int bsme_index = indy.bsme_index();
461464
Symbol* bsm_name = bsmh.name(cp);
462465
Symbol* bsm_signature = bsmh.signature(cp);
463466
Symbol* bsm_klass = bsmh.klass_name(cp);
@@ -542,17 +545,17 @@ bool AOTConstantPoolResolver::is_indy_resolution_deterministic(ConstantPool* cp,
542545
}
543546

544547
// interfaceMethodType
545-
if (!check_lambda_metafactory_methodtype_arg(cp, bsme, 0)) {
548+
if (!check_lambda_metafactory_methodtype_arg(cp, bsme_index, 0)) {
546549
return false;
547550
}
548551

549552
// implementation
550-
if (!check_lambda_metafactory_methodhandle_arg(cp, bsme, 1)) {
553+
if (!check_lambda_metafactory_methodhandle_arg(cp, bsme_index, 1)) {
551554
return false;
552555
}
553556

554557
// dynamicMethodType
555-
if (!check_lambda_metafactory_methodtype_arg(cp, bsme, 2)) {
558+
if (!check_lambda_metafactory_methodtype_arg(cp, bsme_index, 2)) {
556559
return false;
557560
}
558561

src/hotspot/share/cds/aotConstantPoolResolver.hpp

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

37-
class BSMAttributeEntry;
3837
class ConstantPool;
3938
class constantPoolHandle;
4039
class InstanceKlass;
@@ -77,8 +76,8 @@ class AOTConstantPoolResolver : AllStatic {
7776

7877
static bool check_methodtype_signature(ConstantPool* cp, Symbol* sig, Klass** return_type_ret = nullptr);
7978
static bool check_lambda_metafactory_signature(ConstantPool* cp, Symbol* sig);
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);
79+
static bool check_lambda_metafactory_methodtype_arg(ConstantPool* cp, int bsme_index, int arg_i);
80+
static bool check_lambda_metafactory_methodhandle_arg(ConstantPool* cp, int bsme_index, int arg_i);
8281

8382
public:
8483
static void initialize();

src/hotspot/share/cds/classListParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ 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-
BSReference indy(pool, cp_index);
538+
BootstrapReference indy(pool, cp_index);
539539
int name_index = indy.name_index();
540540
cii->add_item(pool->symbol_at(name_index)->as_C_string());
541541
int sig_index = indy.signature_index();

src/hotspot/share/classfile/classFileParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
446446
if (!_need_verify) break;
447447
// Use RawReference because CP structure is not fully checked yet.
448448
// A real FMReference causes asserts to fire on some bad classfiles.
449-
RawReference ref(/*allow_malformed*/ true, cp, index);
449+
RawReference ref = cp->possibly_malformed_RawReference_at(index);
450450
const int klass_ref_index = ref.third_index();
451451
const int name_and_type_ref_index = ref.nt_index();
452452
guarantee_property(valid_klass_reference_at(klass_ref_index),
@@ -576,8 +576,8 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
576576
case JVM_CONSTANT_InvokeDynamic:
577577
case JVM_CONSTANT_Dynamic: {
578578
// Use RawReference because CP structure is not fully checked yet.
579-
// A real BSReference causes asserts to fire on some bad classfiles.
580-
RawReference bsref(/*allow_malformed*/ true, cp, index);
579+
// A real BootstrapReference causes asserts to fire on some bad classfiles.
580+
RawReference bsref = cp->possibly_malformed_RawReference_at(index);
581581
const int name_and_type_ref_index = bsref.nt_index();
582582

583583
guarantee_property(valid_cp_range(name_and_type_ref_index, length) &&
@@ -646,7 +646,7 @@ void ClassFileParser::parse_constant_pool(const ClassFileStream* const stream,
646646
if (_need_verify) {
647647
// CONSTANT_Dynamic's name and signature are verified above, when iterating NameAndType_info.
648648
// Need only to be sure signature is the right type.
649-
BSReference bsref(cp, index);
649+
BootstrapReference bsref(cp, index);
650650
// name, signature are already verified to be utf8
651651
if (Signature::is_method(bsref.signature(cp))) {
652652
throwIllegalSignature("CONSTANT_Dynamic", bsref.name(cp), bsref.signature(cp), CHECK);

src/hotspot/share/classfile/verifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,7 @@ void ClassVerifier::verify_ldc(
21932193
VerificationType::reference_type(
21942194
vmSymbols::java_lang_invoke_MethodType()), CHECK_VERIFY(this));
21952195
} else if (tag.is_dynamic_constant()) {
2196-
BSReference condy(cp, index);
2196+
BootstrapReference condy(cp, index);
21972197
Symbol* constant_type = condy.signature(cp);
21982198
// Field signature was checked in ClassFileParser.
21992199
assert(SignatureVerifier::is_valid_type_signature(constant_type),

src/hotspot/share/interpreter/bootstrapInfo.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
class BootstrapInfo : public StackObj {
3434
constantPoolHandle _pool; // constant pool containing the bootstrap specifier
3535
const int _bss_index; // index of bootstrap specifier in CP (condy or indy)
36-
BSReference _bss_data; // indexes unpacked from the _bss_index
36+
BootstrapReference _bss_data; // indexes unpacked from the _bss_index
3737
const int _indy_index; // internal index of indy call site, or -1 if a condy call
3838
Symbol* _name; // extracted from JVM_CONSTANT_NameAndType
3939
Symbol* _signature;

src/hotspot/share/interpreter/bytecodeTracer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void BytecodePrinter::print_dynamic(int cp_index, outputStream* st) {
282282
return;
283283
}
284284

285-
BSReference ref(constants, cp_index);
285+
BootstrapReference ref(constants, cp_index);
286286
st->print(" bsm=%d", ref.bsme(constants)->bootstrap_method_index());
287287

288288
Symbol* name = ref.name(constants);
@@ -307,7 +307,7 @@ void BytecodePrinter::print_invokedynamic(int indy_index, int cp_index, outputSt
307307

308308
// cp_index: must be the cp_index of a JVM_CONSTANT_{Dynamic, DynamicInError, InvokeDynamic}
309309
void BytecodePrinter::print_bsm(int cp_index, outputStream* st) {
310-
BSReference indy(constants(), cp_index);
310+
BootstrapReference indy(constants(), cp_index);
311311
BSMAttributeEntry* bsme = indy.bsme(constants());
312312
MethodHandleReference bsmh = bsme->bootstrap_method(constants());
313313
const char* ref_kind = "";

src/hotspot/share/interpreter/linkResolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ Method* LinkResolver::resolve_method_statically(Bytecodes::Code code,
651651
// FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.
652652
// resolve klass
653653
if (code == Bytecodes::_invokedynamic) {
654-
BSReference indy(pool, index, code);
654+
BootstrapReference indy(pool, index, code);
655655
Klass* resolved_klass = vmClasses::MethodHandle_klass();
656656
Symbol* method_name = vmSymbols::invoke_name();
657657
Symbol* method_signature = indy.signature(pool);

src/hotspot/share/interpreter/rewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide,
357357
(tag.is_dynamic_constant() &&
358358
// keep regular ldc interpreter logic for condy primitives
359359
is_reference_type(Signature::basic_type(
360-
BSReference(_pool, cp_index).signature(_pool)
360+
BootstrapReference(_pool, cp_index).signature(_pool)
361361
)))
362362
) {
363363
int ref_index = cp_entry_to_resolved_references(cp_index);

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ C2V_VMENTRY_NULL(jobject, lookupConstantInPool, (JNIEnv* env, jobject, ARGUMENT_
748748
if (obj == nullptr) {
749749
return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_NULL_POINTER());
750750
}
751-
BSReference condy(cp, cp_index);
751+
BootstrapReference condy(cp, cp_index);
752752
BasicType bt = Signature::basic_type(condy.signature(cp));
753753
if (!is_reference_type(bt)) {
754754
if (!is_java_primitive(bt)) {
@@ -891,7 +891,7 @@ C2V_END
891891

892892
C2V_VMENTRY_0(jint, bootstrapArgumentIndexAt, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint cpi, jint index))
893893
constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp));
894-
BSReference indy(cp, cpi); // indy or condy
894+
BootstrapReference indy(cp, cpi); // indy or condy
895895
BSMAttributeEntry* bsme = indy.bsme(cp);
896896
return bsme->argument_index(index);
897897
C2V_END

0 commit comments

Comments
 (0)