mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8375622: G1: Convert G1CodeRootSet to use Atomic<T>
Reviewed-by: shade, sjohanss
This commit is contained in:
parent
560a92a632
commit
4f87fb53ee
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,7 @@
|
||||
#include "gc/g1/g1HeapRegion.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "runtime/atomicAccess.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "utilities/concurrentHashTable.inline.hpp"
|
||||
#include "utilities/concurrentHashTableTasks.inline.hpp"
|
||||
|
||||
@ -60,7 +60,7 @@ class G1CodeRootSetHashTable : public CHeapObj<mtGC> {
|
||||
HashTable _table;
|
||||
HashTableScanTask _table_scanner;
|
||||
|
||||
size_t volatile _num_entries;
|
||||
Atomic<size_t> _num_entries;
|
||||
|
||||
bool is_empty() const { return number_of_entries() == 0; }
|
||||
|
||||
@ -120,7 +120,7 @@ public:
|
||||
bool grow_hint = false;
|
||||
bool inserted = _table.insert(Thread::current(), lookup, method, &grow_hint);
|
||||
if (inserted) {
|
||||
AtomicAccess::inc(&_num_entries);
|
||||
_num_entries.add_then_fetch(1u);
|
||||
}
|
||||
if (grow_hint) {
|
||||
_table.grow(Thread::current());
|
||||
@ -131,7 +131,7 @@ public:
|
||||
HashTableLookUp lookup(method);
|
||||
bool removed = _table.remove(Thread::current(), lookup);
|
||||
if (removed) {
|
||||
AtomicAccess::dec(&_num_entries);
|
||||
_num_entries.sub_then_fetch(1u);
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
@ -182,7 +182,7 @@ public:
|
||||
guarantee(succeeded, "unable to clean table");
|
||||
|
||||
if (num_deleted != 0) {
|
||||
size_t current_size = AtomicAccess::sub(&_num_entries, num_deleted);
|
||||
size_t current_size = _num_entries.sub_then_fetch(num_deleted);
|
||||
shrink_to_match(current_size);
|
||||
}
|
||||
}
|
||||
@ -226,7 +226,7 @@ public:
|
||||
|
||||
size_t mem_size() { return sizeof(*this) + _table.get_mem_size(Thread::current()); }
|
||||
|
||||
size_t number_of_entries() const { return AtomicAccess::load(&_num_entries); }
|
||||
size_t number_of_entries() const { return _num_entries.load_relaxed(); }
|
||||
};
|
||||
|
||||
uintx G1CodeRootSetHashTable::HashTableLookUp::get_hash() const {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user