8245594: Remove volatile-qualified member functions and parameters from oop class
Remove volatile qualifications in oop and derived classes; use Atomic for access. Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
bc822ffad8
commit
d3042cc401
@ -41,17 +41,7 @@ class ShenandoahVerifierTask {
|
||||
public:
|
||||
ShenandoahVerifierTask(oop o = NULL, int idx = 0): _obj(o) { }
|
||||
ShenandoahVerifierTask(oop o, size_t idx): _obj(o) { }
|
||||
ShenandoahVerifierTask(const ShenandoahVerifierTask& t): _obj(t._obj) { }
|
||||
|
||||
ShenandoahVerifierTask& operator =(const ShenandoahVerifierTask& t) {
|
||||
_obj = t._obj;
|
||||
return *this;
|
||||
}
|
||||
volatile ShenandoahVerifierTask&
|
||||
operator =(const volatile ShenandoahVerifierTask& t) volatile {
|
||||
(void)const_cast<oop&>(_obj = t._obj);
|
||||
return *this;
|
||||
}
|
||||
// Trivially copyable.
|
||||
|
||||
inline oop obj() const { return _obj; }
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2020, 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
|
||||
@ -87,7 +87,7 @@ inline void ZPhantomKeepAliveOopClosure::do_oop(narrowOop* p) {
|
||||
inline void ZPhantomCleanOopClosure::do_oop(oop* p) {
|
||||
// Read the oop once, to make sure the liveness check
|
||||
// and the later clearing uses the same value.
|
||||
const oop obj = *(volatile oop*)p;
|
||||
const oop obj = Atomic::load(p);
|
||||
if (ZBarrier::is_alive_barrier_on_phantom_oop(obj)) {
|
||||
ZBarrier::keep_alive_barrier_on_phantom_oop_field(p);
|
||||
} else {
|
||||
|
@ -80,36 +80,28 @@ class oop {
|
||||
void register_oop();
|
||||
void unregister_oop();
|
||||
|
||||
public:
|
||||
void set_obj(const void* p) {
|
||||
_o = (oopDesc*)p;
|
||||
void register_if_checking() {
|
||||
if (CheckUnhandledOops) register_oop();
|
||||
}
|
||||
|
||||
oop() { set_obj(NULL); }
|
||||
oop(const oop& o) { set_obj(o.obj()); }
|
||||
oop(const volatile oop& o) { set_obj(o.obj()); }
|
||||
oop(const void* p) { set_obj(p); }
|
||||
public:
|
||||
oop() : _o(NULL) { register_if_checking(); }
|
||||
oop(const oop& o) : _o(o._o) { register_if_checking(); }
|
||||
oop(const void* p) : _o((oopDesc*)p) { register_if_checking(); }
|
||||
~oop() {
|
||||
if (CheckUnhandledOops) unregister_oop();
|
||||
}
|
||||
|
||||
oopDesc* obj() const volatile { return _o; }
|
||||
oopDesc* obj() const { return _o; }
|
||||
oopDesc* operator->() const { return _o; }
|
||||
operator oopDesc* () const { return _o; }
|
||||
|
||||
// General access
|
||||
oopDesc* operator->() const { return obj(); }
|
||||
bool operator==(const oop o) const { return obj() == o.obj(); }
|
||||
bool operator==(void *p) const { return obj() == p; }
|
||||
bool operator!=(const volatile oop o) const { return obj() != o.obj(); }
|
||||
bool operator!=(void *p) const { return obj() != p; }
|
||||
bool operator==(const oop& o) const { return _o == o._o; }
|
||||
bool operator==(void *p) const { return _o == p; }
|
||||
bool operator!=(const oop& o) const { return _o != o._o; }
|
||||
bool operator!=(void *p) const { return _o != p; }
|
||||
|
||||
// Assignment
|
||||
oop& operator=(const oop& o) { _o = o.obj(); return *this; }
|
||||
volatile oop& operator=(const oop& o) volatile { _o = o.obj(); return *this; }
|
||||
volatile oop& operator=(const volatile oop& o) volatile { _o = o.obj(); return *this; }
|
||||
|
||||
// Explict user conversions
|
||||
operator oopDesc* () const volatile { return obj(); }
|
||||
oop& operator=(const oop& o) { _o = o._o; return *this; }
|
||||
};
|
||||
|
||||
template<>
|
||||
@ -128,7 +120,6 @@ struct PrimitiveConversions::Translate<oop> : public TrueType {
|
||||
type##Oop() : oop() {} \
|
||||
type##Oop(const type##Oop& o) : oop(o) {} \
|
||||
type##Oop(const oop& o) : oop(o) {} \
|
||||
type##Oop(const volatile oop& o) : oop(o) {} \
|
||||
type##Oop(const void* p) : oop(p) {} \
|
||||
operator type##OopDesc* () const { return (type##OopDesc*)obj(); } \
|
||||
type##OopDesc* operator->() const { \
|
||||
@ -138,14 +129,6 @@ struct PrimitiveConversions::Translate<oop> : public TrueType {
|
||||
oop::operator=(o); \
|
||||
return *this; \
|
||||
} \
|
||||
volatile type##Oop& operator=(const type##Oop& o) volatile { \
|
||||
(void)const_cast<oop&>(oop::operator=(o)); \
|
||||
return *this; \
|
||||
} \
|
||||
volatile type##Oop& operator=(const volatile type##Oop& o) volatile {\
|
||||
(void)const_cast<oop&>(oop::operator=(o)); \
|
||||
return *this; \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
template<> \
|
||||
|
@ -1665,7 +1665,7 @@ void JavaThread::initialize() {
|
||||
}
|
||||
#endif // INCLUDE_JVMCI
|
||||
_reserved_stack_activation = NULL; // stack base not known yet
|
||||
(void)const_cast<oop&>(_exception_oop = oop(NULL));
|
||||
set_exception_oop(oop());
|
||||
_exception_pc = 0;
|
||||
_exception_handler_pc = 0;
|
||||
_is_method_handle_return = 0;
|
||||
@ -2252,6 +2252,13 @@ bool JavaThread::is_lock_owned(address adr) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
oop JavaThread::exception_oop() const {
|
||||
return Atomic::load(&_exception_oop);
|
||||
}
|
||||
|
||||
void JavaThread::set_exception_oop(oop o) {
|
||||
Atomic::store(&_exception_oop, o);
|
||||
}
|
||||
|
||||
void JavaThread::add_monitor_chunk(MonitorChunk* chunk) {
|
||||
chunk->set_next(monitor_chunks());
|
||||
|
@ -1574,12 +1574,12 @@ class JavaThread: public Thread {
|
||||
#endif // INCLUDE_JVMCI
|
||||
|
||||
// Exception handling for compiled methods
|
||||
oop exception_oop() const { return _exception_oop; }
|
||||
oop exception_oop() const;
|
||||
address exception_pc() const { return _exception_pc; }
|
||||
address exception_handler_pc() const { return _exception_handler_pc; }
|
||||
bool is_method_handle_return() const { return _is_method_handle_return == 1; }
|
||||
|
||||
void set_exception_oop(oop o) { (void)const_cast<oop&>(_exception_oop = o); }
|
||||
void set_exception_oop(oop o);
|
||||
void set_exception_pc(address a) { _exception_pc = a; }
|
||||
void set_exception_handler_pc(address a) { _exception_handler_pc = a; }
|
||||
void set_is_method_handle_return(bool value) { _is_method_handle_return = value ? 1 : 0; }
|
||||
|
@ -38,10 +38,8 @@
|
||||
#include "services/gcNotifier.hpp"
|
||||
#include "utilities/dtrace.hpp"
|
||||
|
||||
MemoryManager::MemoryManager(const char* name) : _name(name) {
|
||||
_num_pools = 0;
|
||||
(void)const_cast<instanceOop&>(_memory_mgr_obj = instanceOop(NULL));
|
||||
}
|
||||
MemoryManager::MemoryManager(const char* name) :
|
||||
_num_pools(0), _name(name), _memory_mgr_obj() {}
|
||||
|
||||
int MemoryManager::add_pool(MemoryPool* pool) {
|
||||
int index = _num_pools;
|
||||
@ -54,6 +52,10 @@ int MemoryManager::add_pool(MemoryPool* pool) {
|
||||
return index;
|
||||
}
|
||||
|
||||
bool MemoryManager::is_manager(instanceHandle mh) const {
|
||||
return mh() == Atomic::load(&_memory_mgr_obj);
|
||||
}
|
||||
|
||||
MemoryManager* MemoryManager::get_code_cache_memory_manager() {
|
||||
return new MemoryManager("CodeCacheManager");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, 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
|
||||
@ -70,7 +70,7 @@ public:
|
||||
|
||||
int add_pool(MemoryPool* pool);
|
||||
|
||||
bool is_manager(instanceHandle mh) { return mh() == _memory_mgr_obj; }
|
||||
bool is_manager(instanceHandle mh) const;
|
||||
|
||||
virtual instanceOop get_memory_manager_instance(TRAPS);
|
||||
virtual bool is_gc_memory_manager() { return false; }
|
||||
|
@ -42,24 +42,27 @@ MemoryPool::MemoryPool(const char* name,
|
||||
size_t init_size,
|
||||
size_t max_size,
|
||||
bool support_usage_threshold,
|
||||
bool support_gc_threshold) {
|
||||
_name = name;
|
||||
_initial_size = init_size;
|
||||
_max_size = max_size;
|
||||
(void)const_cast<instanceOop&>(_memory_pool_obj = instanceOop(NULL));
|
||||
_available_for_allocation = true;
|
||||
_num_managers = 0;
|
||||
_type = type;
|
||||
|
||||
// initialize the max and init size of collection usage
|
||||
_after_gc_usage = MemoryUsage(_initial_size, 0, 0, _max_size);
|
||||
|
||||
_usage_sensor = NULL;
|
||||
_gc_usage_sensor = NULL;
|
||||
bool support_gc_threshold) :
|
||||
_name(name),
|
||||
_type(type),
|
||||
_initial_size(init_size),
|
||||
_max_size(max_size),
|
||||
_available_for_allocation(true),
|
||||
_managers(),
|
||||
_num_managers(0),
|
||||
_peak_usage(),
|
||||
_after_gc_usage(init_size, 0, 0, max_size),
|
||||
// usage threshold supports both high and low threshold
|
||||
_usage_threshold = new ThresholdSupport(support_usage_threshold, support_usage_threshold);
|
||||
_usage_threshold(new ThresholdSupport(support_usage_threshold, support_usage_threshold)),
|
||||
// gc usage threshold supports only high threshold
|
||||
_gc_usage_threshold = new ThresholdSupport(support_gc_threshold, support_gc_threshold);
|
||||
_gc_usage_threshold(new ThresholdSupport(support_gc_threshold, support_gc_threshold)),
|
||||
_usage_sensor(),
|
||||
_gc_usage_sensor(),
|
||||
_memory_pool_obj()
|
||||
{}
|
||||
|
||||
bool MemoryPool::is_pool(instanceHandle pool) const {
|
||||
return pool() == Atomic::load(&_memory_pool_obj);
|
||||
}
|
||||
|
||||
void MemoryPool::add_manager(MemoryManager* mgr) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, 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
|
||||
@ -95,7 +95,7 @@ class MemoryPool : public CHeapObj<mtInternal> {
|
||||
// max size could be changed
|
||||
virtual size_t max_size() const { return _max_size; }
|
||||
|
||||
bool is_pool(instanceHandle pool) { return pool() == _memory_pool_obj; }
|
||||
bool is_pool(instanceHandle pool) const;
|
||||
|
||||
bool available_for_allocation() { return _available_for_allocation; }
|
||||
bool set_available_for_allocation(bool value) {
|
||||
|
Loading…
Reference in New Issue
Block a user