mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8376131
Hi all, please review this conversions of `ContiguousSpace` to use `Atomic<T>`. Testing: gha, tier1-5 Thanks, Thomas
This commit is contained in:
parent
025041ba04
commit
9ff4dd1325
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
@ -30,7 +30,6 @@
|
||||
#include "memory/iterator.inline.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "runtime/atomicAccess.hpp"
|
||||
#include "runtime/java.hpp"
|
||||
#include "runtime/safepoint.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
@ -69,7 +68,7 @@ void ContiguousSpace::clear(bool mangle_space) {
|
||||
#ifndef PRODUCT
|
||||
|
||||
void ContiguousSpace::mangle_unused_area() {
|
||||
mangle_unused_area(MemRegion(_top, _end));
|
||||
mangle_unused_area(MemRegion(top(), _end));
|
||||
}
|
||||
|
||||
void ContiguousSpace::mangle_unused_area(MemRegion mr) {
|
||||
@ -128,11 +127,8 @@ inline HeapWord* ContiguousSpace::par_allocate_impl(size_t size) {
|
||||
HeapWord* obj = top();
|
||||
if (pointer_delta(end(), obj) >= size) {
|
||||
HeapWord* new_top = obj + size;
|
||||
HeapWord* result = AtomicAccess::cmpxchg(top_addr(), obj, new_top);
|
||||
// result can be one of two:
|
||||
// the old top value: the exchange succeeded
|
||||
// otherwise: the new value of the top is returned.
|
||||
if (result == obj) {
|
||||
// Retry if we did not successfully updated the top pointers.
|
||||
if (_top.compare_set(obj, new_top)) {
|
||||
assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 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
|
||||
@ -32,6 +32,7 @@
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/memRegion.hpp"
|
||||
#include "oops/markWord.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
@ -53,7 +54,7 @@ class ContiguousSpace: public CHeapObj<mtGC> {
|
||||
private:
|
||||
HeapWord* _bottom;
|
||||
HeapWord* _end;
|
||||
HeapWord* _top;
|
||||
Atomic<HeapWord*> _top;
|
||||
|
||||
// Allocation helpers (return null if full).
|
||||
inline HeapWord* allocate_impl(size_t word_size);
|
||||
@ -64,12 +65,12 @@ public:
|
||||
|
||||
// Accessors
|
||||
HeapWord* bottom() const { return _bottom; }
|
||||
HeapWord* end() const { return _end; }
|
||||
HeapWord* top() const { return _top; }
|
||||
HeapWord* end() const { return _end; }
|
||||
HeapWord* top() const { return _top.load_relaxed(); }
|
||||
|
||||
void set_bottom(HeapWord* value) { _bottom = value; }
|
||||
void set_end(HeapWord* value) { _end = value; }
|
||||
void set_top(HeapWord* value) { _top = value; }
|
||||
void set_top(HeapWord* value) { _top.store_relaxed(value); }
|
||||
|
||||
// Testers
|
||||
bool is_empty() const { return used() == 0; }
|
||||
@ -121,9 +122,6 @@ public:
|
||||
// Iteration
|
||||
void object_iterate(ObjectClosure* blk);
|
||||
|
||||
// Addresses for inlined allocation
|
||||
HeapWord** top_addr() { return &_top; }
|
||||
|
||||
// Debugging
|
||||
void verify() const;
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 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
|
||||
@ -97,7 +97,7 @@
|
||||
\
|
||||
nonstatic_field(ContiguousSpace, _bottom, HeapWord*) \
|
||||
nonstatic_field(ContiguousSpace, _end, HeapWord*) \
|
||||
nonstatic_field(ContiguousSpace, _top, HeapWord*) \
|
||||
nonstatic_field(ContiguousSpace, _top, Atomic<HeapWord*>) \
|
||||
\
|
||||
nonstatic_field(MemRegion, _start, HeapWord*) \
|
||||
nonstatic_field(MemRegion, _word_size, size_t)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
@ -901,6 +901,7 @@
|
||||
/*****************************/ \
|
||||
\
|
||||
declare_toplevel_type(void*) \
|
||||
declare_toplevel_type(Atomic<HeapWord*>) \
|
||||
declare_toplevel_type(int*) \
|
||||
declare_toplevel_type(char*) \
|
||||
declare_toplevel_type(char**) \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user