Skip to content

Commit

Permalink
8247218: Add default constructor to VectorSet to use Thread::current(…
Browse files Browse the repository at this point in the history
…)->resource_area() as arena by default

Add a default construction to VectorSet and clean up uses of the old constructor.

Reviewed-by: kvn, thartmann
  • Loading branch information
chhagedorn committed Jun 29, 2020
1 parent fe14564 commit 840867e
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 130 deletions.
5 changes: 2 additions & 3 deletions src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,8 @@ void G1BarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase phase) co
// Verify G1 pre-barriers
const int marking_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset());

ResourceArea *area = Thread::current()->resource_area();
Unique_Node_List visited(area);
Node_List worklist(area);
Unique_Node_List visited;
Node_List worklist;
// We're going to walk control flow backwards starting from the Root
worklist.push(compile->root());
while (worklist.size() > 0) {
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,8 @@ void ShenandoahBarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase p
// Verify G1 pre-barriers
const int marking_offset = in_bytes(ShenandoahThreadLocalData::satb_mark_queue_active_offset());

ResourceArea *area = Thread::current()->resource_area();
Unique_Node_List visited(area);
Node_List worklist(area);
Unique_Node_List visited;
Node_List worklist;
// We're going to walk control flow backwards starting from the Root
worklist.push(compile->root());
while (worklist.size() > 0) {
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void ShenandoahBarrierC2Support::verify(RootNode* root) {
GrowableArray<Node*> barriers;
Unique_Node_List barriers_used;
Node_Stack phis(0);
VectorSet visited(Thread::current()->resource_area());
VectorSet visited;
const bool trace = false;
const bool verify_no_useless_barrier = false;

Expand Down Expand Up @@ -766,7 +766,7 @@ Node* ShenandoahBarrierC2Support::no_branches(Node* c, Node* dom, bool allow_one

Node* ShenandoahBarrierC2Support::dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase) {
ResourceMark rm;
VectorSet wq(Thread::current()->resource_area());
VectorSet wq;
wq.set(mem->_idx);
mem_ctrl = phase->ctrl_or_self(mem);
while (!phase->is_dominator(mem_ctrl, ctrl) || mem_ctrl == ctrl) {
Expand Down Expand Up @@ -1184,7 +1184,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
call->extract_projections(&projs, false, false);

#ifdef ASSERT
VectorSet cloned(Thread::current()->resource_area());
VectorSet cloned;
#endif
Node* lrb_clone = lrb->clone();
phase->register_new_node(lrb_clone, projs.catchall_catchproj);
Expand Down Expand Up @@ -1354,7 +1354,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {

Node* addr;
if (ShenandoahSelfFixing) {
VectorSet visited(Thread::current()->resource_area());
VectorSet visited;
addr = get_load_addr(phase, visited, lrb);
} else {
addr = phase->igvn().zerocon(T_OBJECT);
Expand Down Expand Up @@ -1818,7 +1818,7 @@ void ShenandoahBarrierC2Support::optimize_after_expansion(VectorSet &visited, No
}

if (!phase->C->major_progress()) {
VectorSet seen(Thread::current()->resource_area());
VectorSet seen;
for (uint i = 0; i < heap_stable_tests.size(); i++) {
Node* n = heap_stable_tests.at(i);
IdealLoopTree* loop = phase->get_loop(n);
Expand Down Expand Up @@ -2090,7 +2090,7 @@ static bool has_never_branch(Node* root) {

void MemoryGraphFixer::collect_memory_nodes() {
Node_Stack stack(0);
VectorSet visited(Thread::current()->resource_area());
VectorSet visited;
Node_List regions;

// Walk the raw memory graph and create a mapping from CFG node to
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void ZBarrierSetC2::analyze_dominating_barriers() const {
// Dominating block? Look around for safepoints
ResourceMark rm;
Block_List stack;
VectorSet visited(Thread::current()->resource_area());
VectorSet visited;
stack.push(load_block);
bool safepoint_found = block_has_safepoint(load_block);
while (!safepoint_found && stack.size() > 0) {
Expand Down
19 changes: 14 additions & 5 deletions src/hotspot/share/libadt/vectset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,24 @@

#include "precompiled.hpp"
#include "libadt/vectset.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/arena.hpp"
#include "memory/resourceArea.hpp"
#include "utilities/count_leading_zeros.hpp"
#include "utilities/powerOfTwo.hpp"

VectorSet::VectorSet(Arena *arena) : _size(2),
_data(NEW_ARENA_ARRAY(arena, uint32_t, 2)),
_data_size(2),
_set_arena(arena) {
VectorSet::VectorSet() {
init(Thread::current()->resource_area());
}

VectorSet::VectorSet(Arena* arena) {
init(arena);
}

void VectorSet::init(Arena* arena) {
_size = 2;
_data = NEW_ARENA_ARRAY(arena, uint32_t, 2);
_data_size = 2;
_set_arena = arena;
_data[0] = 0;
_data[1] = 0;
}
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/libadt/vectset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ class VectorSet : public ResourceObj {
uint _data_size;
Arena* _set_arena;

void init(Arena* arena);
// Grow vector to required word capacity
void grow(uint new_word_capacity);
public:
VectorSet(Arena *arena);
VectorSet();
VectorSet(Arena* arena);
~VectorSet() {}

void insert(uint elem);
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/opto/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,10 @@ PhaseCFG::PhaseCFG(Arena* arena, RootNode* root, Matcher& matcher)
// The RootNode both starts and ends it's own block. Do this with a recursive
// backwards walk over the control edges.
uint PhaseCFG::build_cfg() {
Arena *a = Thread::current()->resource_area();
VectorSet visited(a);
VectorSet visited;

// Allocate stack with enough space to avoid frequent realloc
Node_Stack nstack(a, C->live_nodes() >> 1);
Node_Stack nstack(C->live_nodes() >> 1);
nstack.push(_root, 0);
uint sum = 0; // Counter for blocks

Expand Down
12 changes: 5 additions & 7 deletions src/hotspot/share/opto/cfgnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,8 @@ bool RegionNode::is_unreachable_region(PhaseGVN *phase) const {
// Unsafe case - check if the Region node is reachable from root.
ResourceMark rm;

Arena *a = Thread::current()->resource_area();
Node_List nstack(a);
VectorSet visited(a);
Node_List nstack;
VectorSet visited;

// Mark all control nodes reachable from root outputs
Node *n = (Node*)phase->C->root();
Expand Down Expand Up @@ -1040,7 +1039,7 @@ void PhiNode::verify_adr_type(bool recursive) const {
"Phi::adr_type must be pre-normalized");

if (recursive) {
VectorSet visited(Thread::current()->resource_area());
VectorSet visited;
verify_adr_type(visited, _adr_type);
}
}
Expand Down Expand Up @@ -1780,9 +1779,8 @@ bool PhiNode::is_unsafe_data_reference(Node *in) const {

ResourceMark rm;

Arena *a = Thread::current()->resource_area();
Node_List nstack(a);
VectorSet visited(a);
Node_List nstack;
VectorSet visited;

nstack.push(in); // Start with unique input.
visited.set(in->_idx);
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/opto/chaitin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ PhaseChaitin::PhaseChaitin(uint unique, PhaseCFG &cfg, Matcher &matcher, bool sc
#endif
)
, _live(0)
, _spilled_once(Thread::current()->resource_area())
, _spilled_twice(Thread::current()->resource_area())
, _lo_degree(0), _lo_stk_degree(0), _hi_degree(0), _simplified(0)
, _oldphi(unique)
#ifndef PRODUCT
Expand Down
11 changes: 4 additions & 7 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2684,8 +2684,7 @@ struct Final_Reshape_Counts : public StackObj {

Final_Reshape_Counts() :
_call_count(0), _float_count(0), _double_count(0),
_java_call_count(0), _inner_loop_count(0),
_visited( Thread::current()->resource_area() ) { }
_java_call_count(0), _inner_loop_count(0) { }

void inc_call_count () { _call_count ++; }
void inc_float_count () { _float_count ++; }
Expand Down Expand Up @@ -3505,8 +3504,7 @@ void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& f
// Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
// requires that the walk visits a node's inputs before visiting the node.
void Compile::final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc ) {
ResourceArea *area = Thread::current()->resource_area();
Unique_Node_List sfpt(area);
Unique_Node_List sfpt;

frc._visited.set(root->_idx); // first, mark node as visited
uint cnt = root->req();
Expand Down Expand Up @@ -3868,14 +3866,13 @@ bool Compile::needs_clinit_barrier(ciInstanceKlass* holder, ciMethod* accessing_
// between Use-Def edges and Def-Use edges in the graph.
void Compile::verify_graph_edges(bool no_dead_code) {
if (VerifyGraphEdges) {
ResourceArea *area = Thread::current()->resource_area();
Unique_Node_List visited(area);
Unique_Node_List visited;
// Call recursive graph walk to check edges
_root->verify_edges(visited);
if (no_dead_code) {
// Now make sure that no visited node is used by an unvisited node.
bool dead_nodes = false;
Unique_Node_List checked(area);
Unique_Node_List checked;
while (visited.size() > 0) {
Node* n = visited.pop();
checked.push(n);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/domgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void PhaseIdealLoop::Dominators() {

// Tarjan's algorithm, almost verbatim:
// Step 1:
VectorSet visited(Thread::current()->resource_area());
VectorSet visited;
int dfsnum = NTarjan::DFS( ntarjan, visited, this, dfsorder);

// Tarjan is using 1-based arrays, so these are some initialize flags
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/opto/escape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2935,8 +2935,7 @@ void ConnectionGraph::split_unique_types(GrowableArray<Node *> &alloc_worklist,
GrowableArray<PhiNode *> orig_phis;
PhaseIterGVN *igvn = _igvn;
uint new_index_start = (uint) _compile->num_alias_types();
Arena* arena = Thread::current()->resource_area();
VectorSet visited(arena);
VectorSet visited;
ideal_nodes.clear(); // Reset for use with set_map/get_map.
uint unique_old = _compile->unique();

Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/opto/gcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,15 +1396,14 @@ void PhaseCFG::global_code_motion() {
}

// Set the basic block for Nodes pinned into blocks
Arena* arena = Thread::current()->resource_area();
VectorSet visited(arena);
VectorSet visited;
schedule_pinned_nodes(visited);

// Find the earliest Block any instruction can be placed in. Some
// instructions are pinned into Blocks. Unpinned instructions can
// appear in last block in which all their inputs occur.
visited.clear();
Node_Stack stack(arena, (C->live_nodes() >> 2) + 16); // pre-grow
Node_Stack stack((C->live_nodes() >> 2) + 16); // pre-grow
if (!schedule_early(visited, stack)) {
// Bailout without retry
C->record_method_not_compilable("early schedule failed");
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/idealGraphPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) {
void IdealGraphPrinter::walk_nodes(Node *start, bool edges, VectorSet* temp_set) {


VectorSet visited(Thread::current()->resource_area());
VectorSet visited;
GrowableArray<Node *> nodeStack(Thread::current()->resource_area(), 0, 0, NULL);
nodeStack.push(start);
visited.test_set(start->_idx);
Expand Down Expand Up @@ -646,7 +646,7 @@ void IdealGraphPrinter::print(const char *name, Node *node) {
print_attr(GRAPH_NAME_PROPERTY, (const char *)name);
end_head();

VectorSet temp_set(Thread::current()->resource_area());
VectorSet temp_set;

head(NODES_ELEMENT);
walk_nodes(node, false, &temp_set);
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/opto/lcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo

// Search the successor block for a load or store who's base value is also
// the tested value. There may be several.
Node_List *out = new Node_List(Thread::current()->resource_area());
MachNode *best = NULL; // Best found so far
for (DUIterator i = val->outs(); val->has_out(i); i++) {
Node *m = val->out(i);
Expand Down Expand Up @@ -1231,7 +1230,7 @@ Node* PhaseCFG::catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *
if( j == def_blk->_num_succs ) {
// Block at same level in dom-tree is not a successor. It needs a
// PhiNode, the PhiNode uses from the def and IT's uses need fixup.
Node_Array inputs = new Node_List(Thread::current()->resource_area());
Node_Array inputs = new Node_List();
for(uint k = 1; k < use_blk->num_preds(); k++) {
Block* block = get_block_for_node(use_blk->pred(k));
inputs.map(k, catch_cleanup_find_cloned_def(block, def, def_blk, n_clone_idx));
Expand Down Expand Up @@ -1342,7 +1341,7 @@ void PhaseCFG::call_catch_cleanup(Block* block) {
uint n_clone_idx = i2-beg+1; // Index of clone of n in each successor block
Node *n = block->get_node(i2); // Node that got cloned
// Need DU safe iterator because of edge manipulation in calls.
Unique_Node_List *out = new Unique_Node_List(Thread::current()->resource_area());
Unique_Node_List* out = new Unique_Node_List();
for (DUIterator_Fast j1max, j1 = n->fast_outs(j1max); j1 < j1max; j1++) {
out->push(n->fast_out(j1));
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void PhaseLive::compute(uint maxlrg) {
_free_IndexSet = NULL;

// Blocks having done pass-1
VectorSet first_pass(Thread::current()->resource_area());
VectorSet first_pass;

// Outer loop: must compute local live-in sets and push into predecessors.
for (uint j = _cfg.number_of_blocks(); j > 0; j--) {
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/opto/loopPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,17 +1337,17 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
ConNode* zero = _igvn.intcon(0);
set_ctrl(zero, C->root());

ResourceArea *area = Thread::current()->resource_area();
ResourceArea* area = Thread::current()->resource_area();
Invariance invar(area, loop);

// Create list of if-projs such that a newer proj dominates all older
// projs in the list, and they all dominate loop->tail()
Node_List if_proj_list(area);
Node_List regions(area);
Node *current_proj = loop->tail(); //start from tail
Node_List if_proj_list;
Node_List regions;
Node* current_proj = loop->tail(); // start from tail


Node_List controls(area);
Node_List controls;
while (current_proj != head) {
if (loop == get_loop(current_proj) && // still in the loop ?
current_proj->is_Proj() && // is a projection ?
Expand Down Expand Up @@ -1416,7 +1416,7 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {

// And look into all branches
Node_Stack stack(0);
VectorSet seen(Thread::current()->resource_area());
VectorSet seen;
Node_List if_proj_list_freq(area);
while (regions.size() > 0) {
Node* c = regions.pop();
Expand Down
17 changes: 7 additions & 10 deletions src/hotspot/share/opto/loopTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,8 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n
outer_main_head->set_req(LoopNode::EntryControl, min_taken);
set_idom(outer_main_head, min_taken, dd_main_head);

Arena *a = Thread::current()->resource_area();
VectorSet visited(a);
Node_Stack clones(a, main_head->back_control()->outcnt());
VectorSet visited;
Node_Stack clones(main_head->back_control()->outcnt());
// Step B3: Make the fall-in values to the main-loop come from the
// fall-out values of the pre-loop.
for (DUIterator_Fast i2max, i2 = main_head->fast_outs(i2max); i2 < i2max; i2++) {
Expand Down Expand Up @@ -1751,9 +1750,8 @@ Node *PhaseIdealLoop::insert_post_loop(IdealLoopTree *loop, Node_List &old_new,
post_head->set_req(LoopNode::EntryControl, zer_taken);
set_idom(post_head, zer_taken, dd_main_exit);

Arena *a = Thread::current()->resource_area();
VectorSet visited(a);
Node_Stack clones(a, main_head->back_control()->outcnt());
VectorSet visited;
Node_Stack clones(main_head->back_control()->outcnt());
// Step A3: Make the fall-in values to the post-loop come from the
// fall-out values of the main-loop.
for (DUIterator_Fast imax, i = main_head->fast_outs(imax); i < imax; i++) {
Expand Down Expand Up @@ -1848,10 +1846,9 @@ void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adj
}

if (C->do_vector_loop() && (PrintOpto && (VerifyLoopOptimizations || TraceLoopOpts))) {
Arena* arena = Thread::current()->resource_area();
Node_Stack stack(arena, C->live_nodes() >> 2);
Node_Stack stack(C->live_nodes() >> 2);
Node_List rpo_list;
VectorSet visited(arena);
VectorSet visited;
visited.set(loop_head->_idx);
rpo(loop_head, stack, visited, rpo_list);
dump(loop, rpo_list.size(), rpo_list);
Expand Down Expand Up @@ -3598,7 +3595,7 @@ bool PhaseIdealLoop::match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& st
}

// No make sure all the other nodes in the loop can be handled
VectorSet ok(Thread::current()->resource_area());
VectorSet ok;

// store related values are ok
ok.set(store->_idx);
Expand Down

0 comments on commit 840867e

Please sign in to comment.