8309717: C2: Remove Arena::move_contents usage

Reviewed-by: thartmann, kvn
This commit is contained in:
Johan Sjölen 2023-06-15 08:36:35 +00:00
parent 6b94289386
commit 4c0e164238
5 changed files with 31 additions and 34 deletions

@ -231,23 +231,6 @@ Arena::Arena(MEMFLAGS flag) : _flags(flag), _size_in_bytes(0) {
set_size_in_bytes(Chunk::init_size);
}
Arena *Arena::move_contents(Arena *copy) {
copy->destruct_contents();
copy->_chunk = _chunk;
copy->_hwm = _hwm;
copy->_max = _max;
copy->_first = _first;
// workaround rare racing condition, which could double count
// the arena size by native memory tracking
size_t size = size_in_bytes();
set_size_in_bytes(0);
copy->set_size_in_bytes(size);
// Destroy original arena
reset();
return copy; // Return Arena with contents
}
Arena::~Arena() {
destruct_contents();
MemTracker::record_arena_free(_flags);

@ -158,9 +158,6 @@ protected:
void *Arealloc( void *old_ptr, size_t old_size, size_t new_size,
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
// Move contents of this arena into an empty arena
Arena *move_contents(Arena *empty_arena);
// Determine if pointer belongs to this Arena or not.
bool contains( const void *ptr ) const;
@ -173,7 +170,7 @@ protected:
private:
// Reset this Arena to empty, access will trigger grow if necessary
void reset(void) {
void reset(void) {
_first = _chunk = nullptr;
_hwm = _max = nullptr;
set_size_in_bytes(0);

@ -624,10 +624,12 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
_coarsened_locks (comp_arena(), 8, 0, nullptr),
_congraph(nullptr),
NOT_PRODUCT(_igv_printer(nullptr) COMMA)
_dead_node_list(comp_arena()),
_unique(0),
_dead_node_count(0),
_node_arena(mtCompiler),
_old_arena(mtCompiler),
_dead_node_list(comp_arena()),
_node_arena_one(mtCompiler),
_node_arena_two(mtCompiler),
_node_arena(&_node_arena_one),
_mach_constant_base_node(nullptr),
_Compile_types(mtCompiler),
_initial_gvn(nullptr),
@ -913,10 +915,12 @@ Compile::Compile( ciEnv* ci_env,
_failure_reason(nullptr),
_congraph(nullptr),
NOT_PRODUCT(_igv_printer(nullptr) COMMA)
_dead_node_list(comp_arena()),
_unique(0),
_dead_node_count(0),
_node_arena(mtCompiler),
_old_arena(mtCompiler),
_dead_node_list(comp_arena()),
_node_arena_one(mtCompiler),
_node_arena_two(mtCompiler),
_node_arena(&_node_arena_one),
_mach_constant_base_node(nullptr),
_Compile_types(mtCompiler),
_initial_gvn(nullptr),

@ -339,9 +339,9 @@ class Compile : public Phase {
// JSR 292
bool _has_method_handle_invokes; // True if this method has MethodHandle invokes.
bool _has_monitors; // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
RTMState _rtm_state; // State of Restricted Transactional Memory usage
int _loop_opts_cnt; // loop opts round
bool _clinit_barrier_on_entry; // True if clinit barrier is needed on nmethod entry
uint _stress_seed; // Seed for stress testing
// Compilation environment.
@ -369,14 +369,27 @@ class Compile : public Phase {
// Node management
uint _unique; // Counter for unique Node indices
VectorSet _dead_node_list; // Set of dead nodes
uint _dead_node_count; // Number of dead nodes; VectorSet::Size() is O(N).
// So use this to keep count and make the call O(1).
VectorSet _dead_node_list; // Set of dead nodes
DEBUG_ONLY(Unique_Node_List* _modified_nodes;) // List of nodes which inputs were modified
DEBUG_ONLY(bool _phase_optimize_finished;) // Used for live node verification while creating new nodes
Arena _node_arena; // Arena for new-space Nodes
Arena _old_arena; // Arena for old-space Nodes, lifetime during xform
// Arenas for new-space and old-space nodes.
// Swapped between using _node_arena.
// The lifetime of the old-space nodes is during xform.
Arena _node_arena_one;
Arena _node_arena_two;
Arena* _node_arena;
public:
Arena* swap_old_and_new() {
Arena* filled_arena_ptr = _node_arena;
Arena* old_arena_ptr = old_arena();
old_arena_ptr->destruct_contents();
_node_arena = old_arena_ptr;
return filled_arena_ptr;
}
private:
RootNode* _root; // Unique root of compilation, or null after bail-out.
Node* _top; // Unique top node. (Reset by various phases.)
@ -801,8 +814,8 @@ class Compile : public Phase {
uint unique() const { return _unique; }
uint next_unique() { return _unique++; }
void set_unique(uint i) { _unique = i; }
Arena* node_arena() { return &_node_arena; }
Arena* old_arena() { return &_old_arena; }
Arena* node_arena() { return _node_arena; }
Arena* old_arena() { return (&_node_arena_one == _node_arena) ? &_node_arena_two : &_node_arena_one; }
RootNode* root() const { return _root; }
void set_root(RootNode* r) { _root = r; }
StartNode* start() const; // (Derived from root.)

@ -335,7 +335,7 @@ void Matcher::match( ) {
Node* new_ideal_null = ConNode::make(TypePtr::NULL_PTR);
// Swap out to old-space; emptying new-space
Arena *old = C->node_arena()->move_contents(C->old_arena());
Arena* old = C->swap_old_and_new();
// Save debug and profile information for nodes in old space:
_old_node_note_array = C->node_note_array();