mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8375624: G1: Convert G1JavaThreadsListClaimer to use Atomic<T>
Reviewed-by: kbarrett, shade
This commit is contained in:
parent
afbb3a0415
commit
8c615190e6
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -54,6 +54,7 @@
|
|||||||
#include "memory/allocation.hpp"
|
#include "memory/allocation.hpp"
|
||||||
#include "memory/iterator.hpp"
|
#include "memory/iterator.hpp"
|
||||||
#include "memory/memRegion.hpp"
|
#include "memory/memRegion.hpp"
|
||||||
|
#include "runtime/atomic.hpp"
|
||||||
#include "runtime/mutexLocker.hpp"
|
#include "runtime/mutexLocker.hpp"
|
||||||
#include "runtime/threadSMR.hpp"
|
#include "runtime/threadSMR.hpp"
|
||||||
#include "utilities/bitMap.hpp"
|
#include "utilities/bitMap.hpp"
|
||||||
@ -124,7 +125,7 @@ class G1JavaThreadsListClaimer : public StackObj {
|
|||||||
ThreadsListHandle _list;
|
ThreadsListHandle _list;
|
||||||
uint _claim_step;
|
uint _claim_step;
|
||||||
|
|
||||||
volatile uint _cur_claim;
|
Atomic<uint> _cur_claim;
|
||||||
|
|
||||||
// Attempts to claim _claim_step JavaThreads, returning an array of claimed
|
// Attempts to claim _claim_step JavaThreads, returning an array of claimed
|
||||||
// JavaThread* with count elements. Returns null (and a zero count) if there
|
// JavaThread* with count elements. Returns null (and a zero count) if there
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,7 +41,6 @@
|
|||||||
#include "gc/shared/markBitMap.inline.hpp"
|
#include "gc/shared/markBitMap.inline.hpp"
|
||||||
#include "gc/shared/taskqueue.inline.hpp"
|
#include "gc/shared/taskqueue.inline.hpp"
|
||||||
#include "oops/stackChunkOop.hpp"
|
#include "oops/stackChunkOop.hpp"
|
||||||
#include "runtime/atomicAccess.hpp"
|
|
||||||
#include "runtime/threadSMR.inline.hpp"
|
#include "runtime/threadSMR.inline.hpp"
|
||||||
#include "utilities/bitMap.inline.hpp"
|
#include "utilities/bitMap.inline.hpp"
|
||||||
|
|
||||||
@ -53,10 +52,10 @@ inline bool G1STWIsAliveClosure::do_object_b(oop p) {
|
|||||||
|
|
||||||
inline JavaThread* const* G1JavaThreadsListClaimer::claim(uint& count) {
|
inline JavaThread* const* G1JavaThreadsListClaimer::claim(uint& count) {
|
||||||
count = 0;
|
count = 0;
|
||||||
if (AtomicAccess::load(&_cur_claim) >= _list.length()) {
|
if (_cur_claim.load_relaxed() >= _list.length()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
uint claim = AtomicAccess::fetch_then_add(&_cur_claim, _claim_step);
|
uint claim = _cur_claim.fetch_then_add(_claim_step);
|
||||||
if (claim >= _list.length()) {
|
if (claim >= _list.length()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user