From 6bed13779a467f35a634ab960a7d825e78cf35bc Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Wed, 27 Nov 2024 16:21:12 +0100 Subject: [PATCH] Fixed incremental inlining --- src/hotspot/share/opto/inlinetypenode.cpp | 38 +++++++++++------------ src/hotspot/share/opto/inlinetypenode.hpp | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/hotspot/share/opto/inlinetypenode.cpp b/src/hotspot/share/opto/inlinetypenode.cpp index 800d3b79f77..edc31cb5f73 100644 --- a/src/hotspot/share/opto/inlinetypenode.cpp +++ b/src/hotspot/share/opto/inlinetypenode.cpp @@ -192,37 +192,37 @@ Node* InlineTypeNode::field_value(uint index) const { return in(Values + index); } - // TODO implement with a worklist -/* -static uint helper2(InlineTypeNode* vt, Unique_Node_List& worklist, Node_List& null_markers) { - uint cnt = 0; +static Node* helper2(const InlineTypeNode* vt, int search_offset, int holder_offset = 0) { for (uint i = 0; i < vt->field_count(); ++i) { - Node* value = vt->field_value(i); if (vt->field_is_flat(i)) { - cnt += helper(value->as_InlineType(), worklist, null_markers, sfpt); + InlineTypeNode* value = vt->field_value(i)->as_InlineType(); if (!vt->field_is_null_free(i)) { - vt->field_null_marker_offset(i) - null_markers.push(value->as_InlineType()->get_is_init()); + int offset = holder_offset + vt->field_null_marker_offset(i); + if (offset == search_offset) { + return value->get_is_init(); + } } - } else { - if (value->is_InlineType()) { - // Add inline type field to the worklist to process later - worklist.push(value); + Node* ret = helper2(value->as_InlineType(), search_offset, holder_offset + vt->field_offset(i) - value->bottom_type()->inline_klass()->first_field_offset()); + if (ret != nullptr) { + return ret; } - sfpt->add_req(value); - cnt++; } } - return cnt; + return nullptr; } -*/ // Get the value of the field at the given offset. // If 'recursive' is true, flat inline type fields will be resolved recursively. -Node* InlineTypeNode::field_value_by_offset(int offset, bool recursive) const { +Node* InlineTypeNode::field_value_by_offset(int offset, bool recursive, bool root) const { // If the field at 'offset' belongs to a flat inline type field, 'index' refers to the - // corresponding InlineTypeNode input and 'sub_offset' is the offset in flattened inline type. + // corresponding InlineTypeNode input and 'sub_offset' is the offset in the flattened inline type. + if (root && recursive) { + // Check if we are loading a null marker + Node* val = helper2(this, offset); + if (val != nullptr) return val; + } + int index = inline_klass()->field_index_by_offset(offset); int sub_offset = offset - field_offset(index); Node* value = field_value(index); @@ -232,7 +232,7 @@ Node* InlineTypeNode::field_value_by_offset(int offset, bool recursive) const { // Flat inline type field InlineTypeNode* vt = value->as_InlineType(); sub_offset += vt->inline_klass()->first_field_offset(); // Add header size - return vt->field_value_by_offset(sub_offset, recursive); + return vt->field_value_by_offset(sub_offset, recursive, false); } else { assert(sub_offset == 0, "should not have a sub offset"); return value; diff --git a/src/hotspot/share/opto/inlinetypenode.hpp b/src/hotspot/share/opto/inlinetypenode.hpp index 9644634b863..9a4611443c4 100644 --- a/src/hotspot/share/opto/inlinetypenode.hpp +++ b/src/hotspot/share/opto/inlinetypenode.hpp @@ -122,7 +122,7 @@ class InlineTypeNode : public TypeNode { // Inline type fields uint field_count() const { return req() - Values; } Node* field_value(uint index) const; - Node* field_value_by_offset(int offset, bool recursive = false) const; + Node* field_value_by_offset(int offset, bool recursive = false, bool root = true) const; void set_field_value(uint index, Node* value); void set_field_value_by_offset(int offset, Node* value); int field_offset(uint index) const;