mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +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
|
@ -199,8 +199,8 @@ int TypeStackSlotEntries::compute_cell_count(Symbol* signature, bool include_rec
|
|||
// Parameter profiling include the receiver
|
||||
int args_count = include_receiver ? 1 : 0;
|
||||
ResourceMark rm;
|
||||
SignatureStream ss(signature);
|
||||
args_count += ss.reference_parameter_count();
|
||||
ReferenceArgumentCount rac(signature);
|
||||
args_count += rac.count();
|
||||
args_count = MIN2(args_count, max);
|
||||
return args_count * per_arg_cell_count;
|
||||
}
|
||||
|
@ -227,32 +227,28 @@ int TypeEntriesAtCall::compute_cell_count(BytecodeStream* stream) {
|
|||
return header_cell + args_cell + ret_cell;
|
||||
}
|
||||
|
||||
class ArgumentOffsetComputer : public SignatureInfo {
|
||||
class ArgumentOffsetComputer : public SignatureIterator {
|
||||
private:
|
||||
int _max;
|
||||
int _offset;
|
||||
GrowableArray<int> _offsets;
|
||||
|
||||
void set(int size, BasicType type) { _size += size; }
|
||||
void do_object(int begin, int end) {
|
||||
if (_offsets.length() < _max) {
|
||||
_offsets.push(_size);
|
||||
friend class SignatureIterator; // so do_parameters_on can call do_type
|
||||
void do_type(BasicType type) {
|
||||
if (is_reference_type(type) && _offsets.length() < _max) {
|
||||
_offsets.push(_offset);
|
||||
}
|
||||
SignatureInfo::do_object(begin, end);
|
||||
}
|
||||
void do_array (int begin, int end) {
|
||||
if (_offsets.length() < _max) {
|
||||
_offsets.push(_size);
|
||||
}
|
||||
SignatureInfo::do_array(begin, end);
|
||||
_offset += parameter_type_word_count(type);
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
ArgumentOffsetComputer(Symbol* signature, int max)
|
||||
: SignatureInfo(signature), _max(max), _offsets(Thread::current(), max) {
|
||||
: SignatureIterator(signature),
|
||||
_max(max), _offset(0),
|
||||
_offsets(Thread::current(), max) {
|
||||
do_parameters_on(this); // non-virtual template execution
|
||||
}
|
||||
|
||||
int total() { lazy_iterate_parameters(); return _size; }
|
||||
|
||||
int off_at(int i) const { return _offsets.at(i); }
|
||||
};
|
||||
|
||||
|
@ -266,7 +262,6 @@ void TypeStackSlotEntries::post_initialize(Symbol* signature, bool has_receiver,
|
|||
start += 1;
|
||||
}
|
||||
ArgumentOffsetComputer aos(signature, _number_of_entries-start);
|
||||
aos.total();
|
||||
for (int i = start; i < _number_of_entries; i++) {
|
||||
set_stack_slot(i, aos.off_at(i-start) + (has_receiver ? 1 : 0));
|
||||
set_type(i, type_none());
|
||||
|
@ -277,11 +272,11 @@ void CallTypeData::post_initialize(BytecodeStream* stream, MethodData* mdo) {
|
|||
assert(Bytecodes::is_invoke(stream->code()), "should be invoke");
|
||||
Bytecode_invoke inv(stream->method(), stream->bci());
|
||||
|
||||
SignatureStream ss(inv.signature());
|
||||
if (has_arguments()) {
|
||||
#ifdef ASSERT
|
||||
ResourceMark rm;
|
||||
int count = MIN2(ss.reference_parameter_count(), (int)TypeProfileArgsLimit);
|
||||
ReferenceArgumentCount rac(inv.signature());
|
||||
int count = MIN2(rac.count(), (int)TypeProfileArgsLimit);
|
||||
assert(count > 0, "room for args type but none found?");
|
||||
check_number_of_arguments(count);
|
||||
#endif
|
||||
|
@ -301,8 +296,8 @@ void VirtualCallTypeData::post_initialize(BytecodeStream* stream, MethodData* md
|
|||
if (has_arguments()) {
|
||||
#ifdef ASSERT
|
||||
ResourceMark rm;
|
||||
SignatureStream ss(inv.signature());
|
||||
int count = MIN2(ss.reference_parameter_count(), (int)TypeProfileArgsLimit);
|
||||
ReferenceArgumentCount rac(inv.signature());
|
||||
int count = MIN2(rac.count(), (int)TypeProfileArgsLimit);
|
||||
assert(count > 0, "room for args type but none found?");
|
||||
check_number_of_arguments(count);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue