mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 00:54:38 +02:00
8253262: Allocate in DumpRegion is not thread safe
Reviewed-by: ccheung
This commit is contained in:
parent
3570f5a924
commit
12dfe1c9b6
3 changed files with 12 additions and 7 deletions
|
@ -35,6 +35,7 @@
|
||||||
#include "memory/universe.hpp"
|
#include "memory/universe.hpp"
|
||||||
#include "oops/symbol.hpp"
|
#include "oops/symbol.hpp"
|
||||||
#include "runtime/atomic.hpp"
|
#include "runtime/atomic.hpp"
|
||||||
|
#include "runtime/mutexLocker.hpp"
|
||||||
#include "runtime/os.hpp"
|
#include "runtime/os.hpp"
|
||||||
#include "runtime/signature.hpp"
|
#include "runtime/signature.hpp"
|
||||||
#include "utilities/utf8.hpp"
|
#include "utilities/utf8.hpp"
|
||||||
|
@ -63,13 +64,14 @@ Symbol::Symbol(const u1* name, int length, int refcount) {
|
||||||
void* Symbol::operator new(size_t sz, int len) throw() {
|
void* Symbol::operator new(size_t sz, int len) throw() {
|
||||||
#if INCLUDE_CDS
|
#if INCLUDE_CDS
|
||||||
if (DumpSharedSpaces) {
|
if (DumpSharedSpaces) {
|
||||||
// To get deterministic output from -Xshare:dump, we ensure that Symbols are allocated in
|
MutexLocker ml(DumpRegion_lock, Mutex::_no_safepoint_check_flag);
|
||||||
// increasing addresses. When the symbols are copied into the archive, we preserve their
|
// To get deterministic output from -Xshare:dump, we ensure that Symbols are allocated in
|
||||||
// relative address order (see SortedSymbolClosure in metaspaceShared.cpp)
|
// increasing addresses. When the symbols are copied into the archive, we preserve their
|
||||||
//
|
// relative address order (sorted, see ArchiveBuilder::gather_klasses_and_symbols).
|
||||||
// We cannot use arena because arena chunks are allocated by the OS. As a result, for example,
|
//
|
||||||
// the archived symbol of "java/lang/Object" may sometimes be lower than "java/lang/String", and
|
// We cannot use arena because arena chunks are allocated by the OS. As a result, for example,
|
||||||
// sometimes be higher. This would cause non-deterministic contents in the archive.
|
// the archived symbol of "java/lang/Object" may sometimes be lower than "java/lang/String", and
|
||||||
|
// sometimes be higher. This would cause non-deterministic contents in the archive.
|
||||||
DEBUG_ONLY(static void* last = 0);
|
DEBUG_ONLY(static void* last = 0);
|
||||||
void* p = (void*)MetaspaceShared::symbol_space_alloc(size(len)*wordSize);
|
void* p = (void*)MetaspaceShared::symbol_space_alloc(size(len)*wordSize);
|
||||||
assert(p > last, "must increase monotonically");
|
assert(p > last, "must increase monotonically");
|
||||||
|
|
|
@ -151,6 +151,7 @@ Mutex* CDSClassFileStream_lock = NULL;
|
||||||
#endif
|
#endif
|
||||||
Mutex* DumpTimeTable_lock = NULL;
|
Mutex* DumpTimeTable_lock = NULL;
|
||||||
Mutex* CDSLambda_lock = NULL;
|
Mutex* CDSLambda_lock = NULL;
|
||||||
|
Mutex* DumpRegion_lock = NULL;
|
||||||
#endif // INCLUDE_CDS
|
#endif // INCLUDE_CDS
|
||||||
|
|
||||||
#if INCLUDE_JVMCI
|
#if INCLUDE_JVMCI
|
||||||
|
@ -346,6 +347,7 @@ void mutex_init() {
|
||||||
#endif
|
#endif
|
||||||
def(DumpTimeTable_lock , PaddedMutex , leaf - 1, true, _safepoint_check_never);
|
def(DumpTimeTable_lock , PaddedMutex , leaf - 1, true, _safepoint_check_never);
|
||||||
def(CDSLambda_lock , PaddedMutex , leaf, true, _safepoint_check_never);
|
def(CDSLambda_lock , PaddedMutex , leaf, true, _safepoint_check_never);
|
||||||
|
def(DumpRegion_lock , PaddedMutex , leaf, true, _safepoint_check_never);
|
||||||
#endif // INCLUDE_CDS
|
#endif // INCLUDE_CDS
|
||||||
|
|
||||||
#if INCLUDE_JVMCI
|
#if INCLUDE_JVMCI
|
||||||
|
|
|
@ -130,6 +130,7 @@ extern Mutex* CDSClassFileStream_lock; // FileMapInfo::open_stream_for
|
||||||
#endif
|
#endif
|
||||||
extern Mutex* DumpTimeTable_lock; // SystemDictionaryShared::find_or_allocate_info_for
|
extern Mutex* DumpTimeTable_lock; // SystemDictionaryShared::find_or_allocate_info_for
|
||||||
extern Mutex* CDSLambda_lock; // SystemDictionaryShared::get_shared_lambda_proxy_class
|
extern Mutex* CDSLambda_lock; // SystemDictionaryShared::get_shared_lambda_proxy_class
|
||||||
|
extern Mutex* DumpRegion_lock; // Symbol::operator new(size_t sz, int len)
|
||||||
#endif // INCLUDE_CDS
|
#endif // INCLUDE_CDS
|
||||||
#if INCLUDE_JFR
|
#if INCLUDE_JFR
|
||||||
extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table
|
extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue