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:
Lois Foltan 2020-02-06 14:29:57 +00:00
parent 2ede36b3a3
commit d19a396e96
57 changed files with 1394 additions and 1498 deletions

View file

@ -625,6 +625,24 @@ enum BasicType {
T_ILLEGAL = 99
};
#define SIGNATURE_TYPES_DO(F, N) \
F(JVM_SIGNATURE_BOOLEAN, T_BOOLEAN, N) \
F(JVM_SIGNATURE_CHAR, T_CHAR, N) \
F(JVM_SIGNATURE_FLOAT, T_FLOAT, N) \
F(JVM_SIGNATURE_DOUBLE, T_DOUBLE, N) \
F(JVM_SIGNATURE_BYTE, T_BYTE, N) \
F(JVM_SIGNATURE_SHORT, T_SHORT, N) \
F(JVM_SIGNATURE_INT, T_INT, N) \
F(JVM_SIGNATURE_LONG, T_LONG, N) \
F(JVM_SIGNATURE_CLASS, T_OBJECT, N) \
F(JVM_SIGNATURE_ARRAY, T_ARRAY, N) \
F(JVM_SIGNATURE_VOID, T_VOID, N) \
/*end*/
inline bool is_java_type(BasicType t) {
return T_BOOLEAN <= t && t <= T_VOID;
}
inline bool is_java_primitive(BasicType t) {
return T_BOOLEAN <= t && t <= T_LONG;
}
@ -646,24 +664,6 @@ inline bool is_reference_type(BasicType t) {
return (t == T_OBJECT || t == T_ARRAY);
}
// Convert a char from a classfile signature to a BasicType
inline BasicType char2type(char c) {
switch( c ) {
case JVM_SIGNATURE_BYTE: return T_BYTE;
case JVM_SIGNATURE_CHAR: return T_CHAR;
case JVM_SIGNATURE_DOUBLE: return T_DOUBLE;
case JVM_SIGNATURE_FLOAT: return T_FLOAT;
case JVM_SIGNATURE_INT: return T_INT;
case JVM_SIGNATURE_LONG: return T_LONG;
case JVM_SIGNATURE_SHORT: return T_SHORT;
case JVM_SIGNATURE_BOOLEAN: return T_BOOLEAN;
case JVM_SIGNATURE_VOID: return T_VOID;
case JVM_SIGNATURE_CLASS: return T_OBJECT;
case JVM_SIGNATURE_ARRAY: return T_ARRAY;
}
return T_ILLEGAL;
}
extern char type2char_tab[T_CONFLICT+1]; // Map a BasicType to a jchar
inline char type2char(BasicType t) { return (uint)t < T_CONFLICT+1 ? type2char_tab[t] : 0; }
extern int type2size[T_CONFLICT+1]; // Map BasicType to result stack elements
@ -693,6 +693,13 @@ enum BasicTypeSize {
T_VOID_size = 0
};
// this works on valid parameter types but not T_VOID, T_CONFLICT, etc.
inline int parameter_type_word_count(BasicType t) {
if (is_double_word_type(t)) return 2;
assert(is_java_primitive(t) || is_reference_type(t), "no goofy types here please");
assert(type2size[t] == 1, "must be");
return 1;
}
// maps a BasicType to its instance field storage type:
// all sub-word integral types are widened to T_INT