From ec95991470a99c917f757614fc6d2cd883bdb39b Mon Sep 17 00:00:00 2001 From: Damon Fenacci Date: Mon, 19 Dec 2022 08:47:04 +0000 Subject: [PATCH] 8298736: Revisit usages of log10 in compiler code Reviewed-by: thartmann, chagedorn, epeter --- src/hotspot/share/opto/loopnode.cpp | 2 +- src/hotspot/share/opto/node.cpp | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index 44e5ccbd0b2..13b404c6da3 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -6193,7 +6193,7 @@ void PhaseIdealLoop::get_idoms(Node* n, const uint count, Unique_Node_List& idom void PhaseIdealLoop::dump_idoms_in_reverse(const Node* n, const Node_List& idom_list) const { Node* next; uint padding = 3; - uint node_index_padding_width = static_cast(log10(C->unique())) + 1; + uint node_index_padding_width = static_cast(log10(static_cast(C->unique()))) + 1; for (int i = idom_list.size() - 1; i >= 0; i--) { if (i == 9 || i == 99) { padding++; diff --git a/src/hotspot/share/opto/node.cpp b/src/hotspot/share/opto/node.cpp index 4790d1b010d..fe0ac92a6c1 100644 --- a/src/hotspot/share/opto/node.cpp +++ b/src/hotspot/share/opto/node.cpp @@ -2392,17 +2392,6 @@ void Node::dump_bfs(const int max_distance) const { dump_bfs(max_distance, nullptr, nullptr); } -// log10 rounded down -uint log10(const uint i) { - uint v = 10; - uint e = 0; - while(v <= i) { - v *= 10; - e++; - } - return e; -} - // -----------------------------dump_idx--------------------------------------- void Node::dump_idx(bool align, outputStream* st, DumpConfig* dc) const { if (dc != nullptr) { @@ -2412,9 +2401,9 @@ void Node::dump_idx(bool align, outputStream* st, DumpConfig* dc) const { bool is_new = C->node_arena()->contains(this); if (align) { // print prefix empty spaces$ // +1 for leading digit, +1 for "o" - uint max_width = log10(C->unique()) + 2; + uint max_width = static_cast(log10(static_cast(C->unique()))) + 2; // +1 for leading digit, maybe +1 for "o" - uint width = log10(_idx) + 1 + (is_new ? 0 : 1); + uint width = static_cast(log10(static_cast(_idx))) + 1 + (is_new ? 0 : 1); while (max_width > width) { st->print(" "); width++;