Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiHartmann committed Dec 12, 2024
1 parent 496f2b8 commit 2191030
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 24 deletions.
3 changes: 1 addition & 2 deletions src/hotspot/share/c1/c1_Runtime1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ static void allocate_instance(JavaThread* current, Klass* klass, TRAPS) {
// make sure klass is initialized
h->initialize(CHECK);
oop obj = nullptr;
// TODO is this correct? C2 uses ciInlineKlass::is_empty instead
if (h->is_inline_klass() && InlineKlass::cast(h)->is_empty_inline_type()) {
if (h->is_inline_klass() && InlineKlass::cast(h)->is_empty_inline_type()) {
obj = InlineKlass::cast(h)->default_value();
assert(obj != nullptr, "default value must exist");
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/ci/ciInlineKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ bool ciInlineKlass::is_empty() {
// Do not use InlineKlass::is_empty_inline_type here because it does
// consider the container empty even if fields of empty inline types
// are not flat
// TODO double check, I think we can also consider it empty if it only contains null-free flat fields of empty inline klasses
return nof_declared_nonstatic_fields() == 0;
//return nof_nonstatic_fields() == 0;
}

// When passing an inline type's fields as arguments, count the number
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/ci/ciInstanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ GrowableArray<ciField*>* ciInstanceKlass::compute_nonstatic_fields_impl(Growable
}

// allocate the array:
// TODO why do we need this?
if (flen == 0 && !is_inlinetype()) {
return nullptr; // return nothing if none are locally declared
}
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/ci/ciReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,11 +1150,6 @@ class CompileReplay : public StackObj {
Klass* actual_array_klass = parse_klass(CHECK_(true));
Klass* kelem = ObjArrayKlass::cast(actual_array_klass)->element_klass();
value = oopFactory::new_objArray(kelem, length, CHECK_(true));
} else if (field_signature[0] == JVM_SIGNATURE_ARRAY) {
// TODO this is dead, right?
Klass* kelem = resolve_klass(field_signature + 1, CHECK_(true));
parse_klass(CHECK_(true)); // eat up the array class name
value = oopFactory::new_valueArray(kelem, length, CHECK_(true));
} else {
report_error("unhandled array staticfield");
}
Expand Down
8 changes: 3 additions & 5 deletions src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3812,11 +3812,9 @@ void nmethod::print_nmethod_labels(outputStream* stream, address block_begin, bo
}
if (!did_name)
stream->print("%s", type2name(t));
if ((*sig)._offset == -1) {
// TODO it's also -1 if it's not from a flat field
//stream->print(" IS INIT");
} else if ((*sig)._sort_offset != (*sig)._offset) {
stream->print(" NULL MARKER");
// If the entry has a non-default sort_offset, it must be a null marker
if ((*sig)._sort_offset != (*sig)._offset) {
stream->print(" (null marker)");
}
}
if (at_old_sp) {
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/oops/fieldStreams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ class HierarchicalFieldStream : public StackObj {
bool is_null_free_inline_type() {
return _current_stream.is_null_free_inline_type();
}

int null_marker_offset() {
return _current_stream.null_marker_offset();
}
};

#endif // SHARE_OOPS_FIELDSTREAMS_HPP
4 changes: 1 addition & 3 deletions src/hotspot/share/oops/inlineKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ int InlineKlass::collect_fields(GrowableArray<SigEntry>* sig, float& max_offset,
// Resolve klass of flat field and recursively collect fields
int field_null_marker_offset = -1;
if (!fs.is_null_free_inline_type()) {
// TODO can we use null_marker_offset() instead?
InlineLayoutInfo* li = inline_layout_info_adr(fs.index());
field_null_marker_offset = base_off + li->null_marker_offset() - (base_off > 0 ? first_field_offset() : 0);
field_null_marker_offset = base_off + fs.null_marker_offset() - (base_off > 0 ? first_field_offset() : 0);
}
Klass* vk = get_inline_type_field_klass(fs.index());
count += InlineKlass::cast(vk)->collect_fields(sig, max_offset, offset, field_null_marker_offset);
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/runtime/sharedRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2868,8 +2868,9 @@ void CompiledEntrySignature::compute_calling_conventions(bool init) {
_sig_cc_ro->appendAll(vk->extended_sig());
if (bt == T_OBJECT) {
// Nullable inline type argument, insert InlineTypeNode::IsInit field right after T_METADATA delimiter
_sig_cc->insert_before(last+1, SigEntry(T_BOOLEAN));
_sig_cc_ro->insert_before(last_ro+1, SigEntry(T_BOOLEAN));
// Set the sort_offset so that the field is detected as null marker by nmethod::print_nmethod_labels.
_sig_cc->insert_before(last+1, SigEntry(T_BOOLEAN, -1, 0));
_sig_cc_ro->insert_before(last_ro+1, SigEntry(T_BOOLEAN, -1, 0));
}
}
} else {
Expand Down
7 changes: 3 additions & 4 deletions src/hotspot/share/runtime/signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,10 @@ typedef GrowableArrayFilterIterator<SigEntry, SigEntryFilter> ExtendedSignature;
// specially. See comment for InlineKlass::collect_fields().
class SigEntry {
public:
// TODO improve these comments
BasicType _bt;
int _offset; // Offset of the corresponding field in it's value class holder for scalarized arguments (-1 otherwise). Used for packing and unpacking
BasicType _bt; // Basic type of the argument
int _offset; // Offset of the field in its value class holder for scalarized arguments (-1 otherwise). Used for packing and unpacking.
float _sort_offset; // Offset used for sorting
Symbol* _symbol; // For printing
Symbol* _symbol; // Symbol for printing

SigEntry()
: _bt(T_ILLEGAL), _offset(-1), _sort_offset(-1), _symbol(NULL) {}
Expand Down

0 comments on commit 2191030

Please sign in to comment.