Skip to content

Commit

Permalink
Review Emanuel: Add typedef and replace usages, format lambda, some r…
Browse files Browse the repository at this point in the history
…enaming
  • Loading branch information
chhagedorn committed Mar 4, 2024
1 parent c00cc8f commit a569132
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/hotspot/share/opto/loopPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,24 @@ Node* PhaseIdealLoop::clone_nodes_with_same_ctrl(Node* start_node, ProjNode* old
DEBUG_ONLY(uint last_idx = C->unique();)
const Unique_Node_List nodes_with_same_ctrl = find_nodes_with_same_ctrl(start_node, old_uncommon_proj);
DataNodeGraph data_node_graph(nodes_with_same_ctrl, this);
auto& orig_to_new = data_node_graph.clone(new_uncommon_proj);
fix_cloned_data_node_controls(old_uncommon_proj, new_uncommon_proj, orig_to_new);
Node** cloned_node_ptr = orig_to_new.get(start_node);
const OrigToNewHashtable& orig_to_clone = data_node_graph.clone(new_uncommon_proj);
fix_cloned_data_node_controls(old_uncommon_proj, new_uncommon_proj, orig_to_clone);
Node** cloned_node_ptr = orig_to_clone.get(start_node);
assert(cloned_node_ptr != nullptr && (*cloned_node_ptr)->_idx >= last_idx, "must exist and be a proper clone");
return *cloned_node_ptr;
}

// All data nodes with a control input to the uncommon projection in the chain need to be rewired to the new uncommon
// projection (could not only be the last data node in the chain but also, for example, a pinned DivNode within the chain).
void PhaseIdealLoop::fix_cloned_data_node_controls(
const ProjNode* old_uncommon_proj, Node* new_uncommon_proj,
const ResizeableResourceHashtable<Node*, Node*, AnyObj::RESOURCE_AREA, mtCompiler>& orig_to_new) {
orig_to_new.iterate_all([&](Node* node, Node* clone) {
if (node->in(0) == old_uncommon_proj) {
void PhaseIdealLoop::fix_cloned_data_node_controls(const ProjNode* old_uncommon_proj, Node* new_uncommon_proj,
const OrigToNewHashtable& orig_to_clone) {
auto orig_clone_action = [&](Node* orig, Node* clone) {
if (orig->in(0) == old_uncommon_proj) {
_igvn.replace_input_of(clone, 0, new_uncommon_proj);
set_ctrl(clone, new_uncommon_proj);
}
});
};
orig_to_clone.iterate_all(orig_clone_action);
}

IfProjNode* PhaseIdealLoop::clone_parse_predicate_to_unswitched_loop(ParsePredicateSuccessProj* parse_predicate_proj,
Expand Down
9 changes: 4 additions & 5 deletions src/hotspot/share/opto/loopnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,9 +1348,8 @@ class PhaseIdealLoop : public PhaseTransform {
Unique_Node_List find_nodes_with_same_ctrl(Node* node, const ProjNode* ctrl);
const Unique_Node_List& find_nodes_with_same_ctrl(DataInputGraph& data_input_graph, const ProjNode* ctrl);
Node* clone_nodes_with_same_ctrl(Node* start_node, ProjNode* old_uncommon_proj, Node* new_uncommon_proj);
void fix_cloned_data_node_controls(
const ProjNode* old_uncommon_proj, Node* new_uncommon_proj,
const ResizeableResourceHashtable<Node*, Node*, AnyObj::RESOURCE_AREA, mtCompiler>& orig_to_new);
void fix_cloned_data_node_controls(const ProjNode* orig, Node* new_uncommon_proj,
const OrigToNewHashtable& orig_to_clone);
bool has_dominating_loop_limit_check(Node* init_trip, Node* limit, jlong stride_con, BasicType iv_bt,
Node* loop_entry);

Expand Down Expand Up @@ -1889,7 +1888,7 @@ class PathFrequency {
class DataNodeGraph : public StackObj {
PhaseIdealLoop* const _phase;
const Unique_Node_List& _data_nodes;
ResizeableResourceHashtable<Node*, Node*, AnyObj::RESOURCE_AREA, mtCompiler> _orig_to_new;
OrigToNewHashtable _orig_to_new;

public:
DataNodeGraph(const Unique_Node_List& data_nodes, PhaseIdealLoop* phase)
Expand All @@ -1914,7 +1913,7 @@ class DataNodeGraph : public StackObj {
public:
// Clone the provided data node collection and rewire the clones in such a way to create an identical graph copy.
// Set `new_ctrl` as ctrl for the cloned nodes.
const ResizeableResourceHashtable<Node*, Node*, AnyObj::RESOURCE_AREA, mtCompiler>& clone(Node* new_ctrl) {
const OrigToNewHashtable& clone(Node* new_ctrl) {
clone_nodes(new_ctrl);
rewire_clones_to_cloned_inputs();
return _orig_to_new;
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/opto/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ typedef Node** DUIterator_Fast;
typedef Node** DUIterator_Last;
#endif

typedef ResizeableResourceHashtable<Node*, Node*, AnyObj::RESOURCE_AREA, mtCompiler> OrigToNewHashtable;

// Node Sentinel
#define NodeSentinel (Node*)-1

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/replacednodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void ReplacedNodes::apply(Compile* C, Node* ctl) {
hash_table_size++;
}
// Map from current node to cloned/replaced node
ResizeableResourceHashtable<Node*, Node*, AnyObj::RESOURCE_AREA, mtCompiler> clones(hash_table_size, hash_table_size);
OrigToNewHashtable clones(hash_table_size, hash_table_size);
// Record mapping from initial to improved nodes
for (int i = 0; i < _replaced_nodes->length(); i++) {
ReplacedNode replaced = _replaced_nodes->at(i);
Expand Down

0 comments on commit a569132

Please sign in to comment.