mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8230199: consolidate signature parsing code in HotSpot sources
Add a new Signature class to support basic signature queries and enhance SignatureStream class to parse field signatures in addition to methods. Co-authored-by: John Rose <john.r.rose@oracle.com> Reviewed-by: coleenp, dholmes, fparain, hseigel
This commit is contained in:
parent
2ede36b3a3
commit
d19a396e96
57 changed files with 1394 additions and 1498 deletions
|
@ -577,9 +577,16 @@ int Method::extra_stack_words() {
|
|||
return extra_stack_entries() * Interpreter::stackElementSize;
|
||||
}
|
||||
|
||||
void Method::compute_size_of_parameters(Thread *thread) {
|
||||
ArgumentSizeComputer asc(signature());
|
||||
set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
|
||||
// Derive size of parameters, return type, and fingerprint,
|
||||
// all in one pass, which is run at load time.
|
||||
// We need the first two, and might as well grab the third.
|
||||
void Method::compute_from_signature(Symbol* sig) {
|
||||
// At this point, since we are scanning the signature,
|
||||
// we might as well compute the whole fingerprint.
|
||||
Fingerprinter fp(sig, is_static());
|
||||
set_size_of_parameters(fp.size_of_parameters());
|
||||
constMethod()->set_result_type(fp.return_type());
|
||||
constMethod()->set_fingerprint(fp.fingerprint());
|
||||
}
|
||||
|
||||
bool Method::is_empty_method() const {
|
||||
|
@ -1443,9 +1450,7 @@ methodHandle Method::make_method_handle_intrinsic(vmIntrinsics::ID iid,
|
|||
m->set_signature_index(_imcp_invoke_signature);
|
||||
assert(MethodHandles::is_signature_polymorphic_name(m->name()), "");
|
||||
assert(m->signature() == signature, "");
|
||||
ResultTypeFinder rtf(signature);
|
||||
m->constMethod()->set_result_type(rtf.type());
|
||||
m->compute_size_of_parameters(THREAD);
|
||||
m->compute_from_signature(signature);
|
||||
m->init_intrinsic_id();
|
||||
assert(m->is_method_handle_intrinsic(), "");
|
||||
#ifdef ASSERT
|
||||
|
@ -1685,7 +1690,7 @@ bool Method::load_signature_classes(const methodHandle& m, TRAPS) {
|
|||
ResourceMark rm(THREAD);
|
||||
Symbol* signature = m->signature();
|
||||
for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
|
||||
if (ss.is_object()) {
|
||||
if (ss.is_reference()) {
|
||||
Symbol* sym = ss.as_symbol();
|
||||
Symbol* name = sym;
|
||||
Klass* klass = SystemDictionary::resolve_or_null(name, class_loader,
|
||||
|
@ -1713,8 +1718,7 @@ bool Method::has_unloaded_classes_in_signature(const methodHandle& m, TRAPS) {
|
|||
Symbol* signature = m->signature();
|
||||
for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
|
||||
if (ss.type() == T_OBJECT) {
|
||||
Symbol* name = ss.as_symbol_or_null();
|
||||
if (name == NULL) return true;
|
||||
Symbol* name = ss.as_symbol();
|
||||
Klass* klass = SystemDictionary::find(name, class_loader, protection_domain, THREAD);
|
||||
if (klass == NULL) return true;
|
||||
}
|
||||
|
@ -1733,7 +1737,7 @@ void Method::print_short_name(outputStream* st) {
|
|||
name()->print_symbol_on(st);
|
||||
if (WizardMode) signature()->print_symbol_on(st);
|
||||
else if (MethodHandles::is_signature_polymorphic(intrinsic_id()))
|
||||
MethodHandles::print_as_basic_type_signature_on(st, signature(), true);
|
||||
MethodHandles::print_as_basic_type_signature_on(st, signature());
|
||||
}
|
||||
|
||||
// Comparer for sorting an object array containing
|
||||
|
@ -1786,8 +1790,8 @@ class SignatureTypePrinter : public SignatureTypeNames {
|
|||
_use_separator = false;
|
||||
}
|
||||
|
||||
void print_parameters() { _use_separator = false; iterate_parameters(); }
|
||||
void print_returntype() { _use_separator = false; iterate_returntype(); }
|
||||
void print_parameters() { _use_separator = false; do_parameters_on(this); }
|
||||
void print_returntype() { _use_separator = false; do_type(return_type()); }
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue