Skip to content

8357474: [lworld] Consolidate load/store flat inline types #1470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ ciField::ciField(ciField* declared_field, ciField* subfield) {

_signature = subfield->_signature;
_type = subfield->_type;
_is_constant = false;
_is_constant = declared_field->is_strict() && declared_field->is_final();
_known_to_link_with_put = subfield->_known_to_link_with_put;
_known_to_link_with_get = subfield->_known_to_link_with_get;
_constant_value = ciConstant();
Expand All @@ -265,7 +265,7 @@ ciField::ciField(ciField* declared_field) {
_signature = ciSymbols::bool_signature();
_type = ciType::make(T_BOOLEAN);

_is_constant = false;
_is_constant = declared_field->is_strict() && declared_field->is_final();
_known_to_link_with_put = nullptr;
_known_to_link_with_get = nullptr;
_constant_value = ciConstant();
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/share/ci/ciInlineKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,11 @@ BasicType ciInlineKlass::atomic_size_to_basic_type(bool null_free) const {
}
return bt;
}

bool ciInlineKlass::must_be_atomic() const {
GUARDED_VM_ENTRY(return get_InlineKlass()->must_be_atomic();)
}

bool ciInlineKlass::is_naturally_atomic(bool null_free) {
return null_free ? (nof_nonstatic_fields() <= 1) : (nof_nonstatic_fields() == 0);
}
3 changes: 3 additions & 0 deletions src/hotspot/share/ci/ciInlineKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ class ciInlineKlass : public ciInstanceKlass {
bool has_nullable_atomic_layout() const;
int null_marker_offset_in_payload() const;
BasicType atomic_size_to_basic_type(bool null_free) const;

bool must_be_atomic() const;
bool is_naturally_atomic(bool null_free);
};

#endif // SHARE_VM_CI_CIINLINEKLASS_HPP
7 changes: 5 additions & 2 deletions src/hotspot/share/opto/callGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "ci/ciMethodHandle.hpp"
#include "classfile/javaClasses.hpp"
#include "compiler/compileLog.hpp"
#include "oops/accessDecorators.hpp"
#include "opto/addnode.hpp"
#include "opto/callGenerator.hpp"
#include "opto/callnode.hpp"
Expand Down Expand Up @@ -789,7 +790,7 @@ void CallGenerator::do_late_inline_helper() {
if (vt != nullptr) {
if (call->tf()->returns_inline_type_as_fields()) {
vt->replace_call_results(&kit, call, C);
} else if (vt->is_InlineType()) {
} else {
// Result might still be allocated (for example, if it has been stored to a non-flat field)
if (!vt->is_allocated(&kit.gvn())) {
assert(buffer_oop != nullptr, "should have allocated a buffer");
Expand All @@ -805,7 +806,9 @@ void CallGenerator::do_late_inline_helper() {

// Not null, initialize the buffer
kit.set_all_memory(init_mem);
vt->store(&kit, buffer_oop, buffer_oop, vt->type()->inline_klass());

Node* payload_ptr = kit.basic_plus_adr(buffer_oop, kit.gvn().type(vt)->inline_klass()->payload_offset());
vt->store_flat(&kit, buffer_oop, payload_ptr, false, true, true, IN_HEAP | MO_UNORDERED);
// Do not let stores that initialize this buffer be reordered with a subsequent
// store that would make this buffer accessible by other threads.
AllocateNode* alloc = AllocateNode::Ideal_allocation(buffer_oop);
Expand Down
8 changes: 7 additions & 1 deletion src/hotspot/share/opto/escape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3537,7 +3537,13 @@ bool ConnectionGraph::is_oop_field(Node* n, int offset, bool* unsafe) {
if (adr_type->is_aryptr()->is_flat() && field_offset != Type::OffsetBot) {
ciInlineKlass* vk = elemtype->inline_klass();
field_offset += vk->payload_offset();
bt = vk->get_field_by_offset(field_offset, false)->layout_type();
ciField* field = vk->get_field_by_offset(field_offset, false);
if (field != nullptr) {
bt = field->layout_type();
} else {
assert(field_offset == vk->payload_offset() + vk->null_marker_offset_in_payload(), "no field or null marker of %s at offset %d", vk->name()->as_utf8(), field_offset);
bt = T_BOOLEAN;
}
} else {
bt = elemtype->array_element_basic_type();
}
Expand Down
23 changes: 18 additions & 5 deletions src/hotspot/share/opto/graphKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1872,14 +1872,27 @@ Node* GraphKit::array_element_address(Node* ary, Node* idx, BasicType elembt,
return basic_plus_adr(ary, base, scale);
}

Node* GraphKit::flat_array_element_address(Node*& array, Node* idx, ciInlineKlass* vk, bool is_null_free,
bool is_not_null_free, bool is_atomic) {
Node* GraphKit::cast_to_flat_array(Node* array, ciInlineKlass* vk, bool is_null_free, bool is_not_null_free, bool is_atomic) {
assert(vk->maybe_flat_in_array(), "element of type %s cannot be flat in array", vk->name()->as_utf8());
if (!vk->has_nullable_atomic_layout()) {
// Element does not have a nullable flat layout, cannot be nullable
is_null_free = true;
}
if (!vk->has_atomic_layout() && !vk->has_non_atomic_layout()) {
// Element does not have a null-free flat layout, cannot be null-free
is_not_null_free = true;
}
if (is_null_free) {
// TODO 8350865 Impossible type
is_not_null_free = false;
}

bool is_exact = is_null_free || is_not_null_free;
ciArrayKlass* array_klass = ciArrayKlass::make(vk, /* flat */ true, is_null_free, is_atomic);
const TypeAryPtr* arytype = TypeOopPtr::make_from_klass(array_klass)->isa_aryptr();
arytype = arytype->cast_to_exactness(true);
arytype = arytype->cast_to_exactness(is_exact);
arytype = arytype->cast_to_not_null_free(is_not_null_free);
array = _gvn.transform(new CheckCastPPNode(control(), array, arytype));
return array_element_address(array, idx, T_FLAT_ELEMENT, arytype->size(), control());
return _gvn.transform(new CastPPNode(control(), array, arytype, ConstraintCastNode::StrongDependency));
}

//-------------------------load_array_element-------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/opto/graphKit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,7 @@ class GraphKit : public Phase {
const TypeInt* sizetype = nullptr,
// Optional control dependency (for example, on range check)
Node* ctrl = nullptr);
Node* flat_array_element_address(Node*& array, Node* idx, ciInlineKlass* vk, bool is_null_free,
bool is_not_null_free, bool is_atomic);
Node* cast_to_flat_array(Node* array, ciInlineKlass* elem_vk, bool is_null_free, bool is_not_null_free, bool is_atomic);

// Return a load of array element at idx.
Node* load_array_element(Node* ary, Node* idx, const TypeAryPtr* arytype, bool set_ctrl);
Expand Down
Loading