mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +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
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -539,30 +539,25 @@ C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jcla
|
|||
JVMCI_THROW_MSG_NULL(ClassNotFoundException, str);
|
||||
}
|
||||
} else {
|
||||
if (class_name->char_at(0) == JVM_SIGNATURE_CLASS &&
|
||||
class_name->char_at(class_name->utf8_length()-1) == JVM_SIGNATURE_ENDCLASS) {
|
||||
if (Signature::has_envelope(class_name)) {
|
||||
// This is a name from a signature. Strip off the trimmings.
|
||||
// Call recursive to keep scope of strippedsym.
|
||||
TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1,
|
||||
class_name->utf8_length()-2);
|
||||
TempNewSymbol strippedsym = Signature::strip_envelope(class_name);
|
||||
resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0);
|
||||
} else if (FieldType::is_array(class_name)) {
|
||||
FieldArrayInfo fd;
|
||||
// dimension and object_key in FieldArrayInfo are assigned as a side-effect
|
||||
// of this call
|
||||
BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0);
|
||||
if (t == T_OBJECT) {
|
||||
TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(),
|
||||
class_name->utf8_length()-2-fd.dimension());
|
||||
} else if (Signature::is_array(class_name)) {
|
||||
SignatureStream ss(class_name, false);
|
||||
int ndim = ss.skip_array_prefix();
|
||||
if (ss.type() == T_OBJECT) {
|
||||
Symbol* strippedsym = ss.as_symbol();
|
||||
resolved_klass = SystemDictionary::find(strippedsym,
|
||||
class_loader,
|
||||
protection_domain,
|
||||
CHECK_0);
|
||||
class_loader,
|
||||
protection_domain,
|
||||
CHECK_0);
|
||||
if (!resolved_klass.is_null()) {
|
||||
resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0);
|
||||
resolved_klass = resolved_klass->array_klass(ndim, CHECK_0);
|
||||
}
|
||||
} else {
|
||||
resolved_klass = TypeArrayKlass::cast(Universe::typeArrayKlassObj(t))->array_klass(fd.dimension(), CHECK_0);
|
||||
resolved_klass = TypeArrayKlass::cast(Universe::typeArrayKlassObj(ss.type()))->array_klass(ndim, CHECK_0);
|
||||
}
|
||||
} else {
|
||||
resolved_klass = SystemDictionary::find(class_name, class_loader, protection_domain, CHECK_0);
|
||||
|
@ -1036,18 +1031,18 @@ C2V_VMENTRY_NULL(jobject, executeHotSpotNmethod, (JNIEnv* env, jobject, jobject
|
|||
JavaCallArguments jca(mh->size_of_parameters());
|
||||
|
||||
JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static());
|
||||
JavaValue result(jap.get_ret_type());
|
||||
JavaValue result(jap.return_type());
|
||||
jca.set_alternative_target(nm);
|
||||
JavaCalls::call(&result, mh, &jca, CHECK_NULL);
|
||||
|
||||
if (jap.get_ret_type() == T_VOID) {
|
||||
if (jap.return_type() == T_VOID) {
|
||||
return NULL;
|
||||
} else if (is_reference_type(jap.get_ret_type())) {
|
||||
} else if (is_reference_type(jap.return_type())) {
|
||||
return JNIHandles::make_local((oop) result.get_jobject());
|
||||
} else {
|
||||
jvalue *value = (jvalue *) result.get_value_addr();
|
||||
// Narrow the value down if required (Important on big endian machines)
|
||||
switch (jap.get_ret_type()) {
|
||||
switch (jap.return_type()) {
|
||||
case T_BOOLEAN:
|
||||
value->z = (jboolean) value->i;
|
||||
break;
|
||||
|
@ -1063,7 +1058,7 @@ C2V_VMENTRY_NULL(jobject, executeHotSpotNmethod, (JNIEnv* env, jobject, jobject
|
|||
default:
|
||||
break;
|
||||
}
|
||||
JVMCIObject o = JVMCIENV->create_box(jap.get_ret_type(), value, JVMCI_CHECK_NULL);
|
||||
JVMCIObject o = JVMCIENV->create_box(jap.return_type(), value, JVMCI_CHECK_NULL);
|
||||
return JVMCIENV->get_jobject(o);
|
||||
}
|
||||
C2V_END
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue