Skip to content
Permalink
Browse files
8252981: ObjectMonitor::object() cleanup changes extracted from JDK-8…
…247281

Co-authored-by: Erik Österlund <erik.osterlund@oracle.com>
Co-authored-by: Daniel Daugherty <daniel.daugherty@oracle.com>
Reviewed-by: rehn, coleenp, eosterlund
  • Loading branch information
3 people committed Sep 11, 2020
1 parent 040c8f5 commit e7a1b9bf81c78e8c90310c0cdc4e6e0384956448
Showing 8 changed files with 44 additions and 44 deletions.
@@ -663,13 +663,13 @@ JvmtiEnvBase::get_current_contended_monitor(JavaThread *calling_thread, JavaThre
mon = java_thread->current_pending_monitor();
if (mon != NULL) {
// The thread is trying to enter() an ObjectMonitor.
obj = (oop)mon->object();
obj = mon->object();
assert(obj != NULL, "ObjectMonitor should have a valid object!");
}
// implied else: no contended ObjectMonitor
} else {
// thread is doing an Object.wait() call
obj = (oop)mon->object();
obj = mon->object();
assert(obj != NULL, "Object.wait() should have an object");
}

@@ -741,7 +741,7 @@ JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread
// Save object of current wait() call (if any) for later comparison.
ObjectMonitor *mon = java_thread->current_waiting_monitor();
if (mon != NULL) {
wait_obj = (oop)mon->object();
wait_obj = mon->object();
}
}
oop pending_obj = NULL;
@@ -752,7 +752,7 @@ JvmtiEnvBase::get_locked_objects_in_frame(JavaThread* calling_thread, JavaThread
// Save object of current enter() call (if any) for later comparison.
ObjectMonitor *mon = java_thread->current_pending_monitor();
if (mon != NULL) {
pending_obj = (oop)mon->object();
pending_obj = mon->object();
}
}

@@ -1434,7 +1434,7 @@ JvmtiMonitorClosure::do_monitor(ObjectMonitor* mon) {
}
if (mon->owner() == _java_thread ) {
// Filter out on stack monitors collected during stack walk.
oop obj = (oop)mon->object();
oop obj = mon->object();
bool found = false;
for (int j = 0; j < _owned_monitors_list->length(); j++) {
jobject jobj = ((jvmtiMonitorStackDepthInfo*)_owned_monitors_list->at(j))->monitor;
@@ -2407,7 +2407,7 @@ void JvmtiExport::post_data_dump() {
}

void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor *obj_mntr) {
oop object = (oop)obj_mntr->object();
oop object = obj_mntr->object();
JvmtiThreadState *state = thread->jvmti_thread_state();
if (state == NULL) {
return;
@@ -2438,7 +2438,7 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor
}

void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonitor *obj_mntr) {
oop object = (oop)obj_mntr->object();
oop object = obj_mntr->object();
JvmtiThreadState *state = thread->jvmti_thread_state();
if (state == NULL) {
return;
@@ -2501,7 +2501,7 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object,
}

void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mntr, jboolean timed_out) {
oop object = (oop)obj_mntr->object();
oop object = obj_mntr->object();
JvmtiThreadState *state = thread->jvmti_thread_state();
if (state == NULL) {
return;
@@ -276,9 +276,9 @@ bool ObjectMonitor::enter(TRAPS) {
if (TrySpin(Self) > 0) {
assert(_owner == Self, "must be Self: owner=" INTPTR_FORMAT, p2i(_owner));
assert(_recursions == 0, "must be 0: recursions=" INTX_FORMAT, _recursions);
assert(((oop)object())->mark() == markWord::encode(this),
assert(object()->mark() == markWord::encode(this),
"object mark must match encoded this: mark=" INTPTR_FORMAT
", encoded this=" INTPTR_FORMAT, ((oop)object())->mark().value(),
", encoded this=" INTPTR_FORMAT, object()->mark().value(),
markWord::encode(this).value());
Self->_Stalled = 0;
return true;
@@ -296,7 +296,7 @@ bool ObjectMonitor::enter(TRAPS) {
// Async deflation is in progress and our contentions increment
// above lost the race to async deflation. Undo the work and
// force the caller to retry.
const oop l_object = (oop)object();
const oop l_object = object();
if (l_object != NULL) {
// Attempt to restore the header/dmw to the object's header so that
// we only retry once if the deflater thread happens to be slow.
@@ -310,8 +310,8 @@ bool ObjectMonitor::enter(TRAPS) {
JFR_ONLY(JfrConditionalFlushWithStacktrace<EventJavaMonitorEnter> flush(jt);)
EventJavaMonitorEnter event;
if (event.should_commit()) {
event.set_monitorClass(((oop)this->object())->klass());
event.set_address((uintptr_t)(this->object_addr()));
event.set_monitorClass(object()->klass());
event.set_address((uintptr_t)object_addr());
}

{ // Change java thread status to indicate blocked on monitor enter.
@@ -374,7 +374,7 @@ bool ObjectMonitor::enter(TRAPS) {
assert(_recursions == 0, "invariant");
assert(_owner == Self, "invariant");
assert(_succ != Self, "invariant");
assert(((oop)(object()))->mark() == markWord::encode(this), "invariant");
assert(object()->mark() == markWord::encode(this), "invariant");

// The thread -- now the owner -- is back in vm mode.
// Report the glorious news via TI,DTrace and jvmstat.
@@ -446,7 +446,7 @@ void ObjectMonitor::install_displaced_markword_in_object(const oop obj) {
OrderAccess::loadload();
}

const oop l_object = (oop)object();
const oop l_object = object();
if (l_object == NULL) {
// ObjectMonitor's object ref has already been cleared by async
// deflation so we're done here.
@@ -770,7 +770,7 @@ void ObjectMonitor::ReenterI(Thread * Self, ObjectWaiter * SelfNode) {
assert(SelfNode != NULL, "invariant");
assert(SelfNode->_thread == Self, "invariant");
assert(_waiters > 0, "invariant");
assert(((oop)(object()))->mark() == markWord::encode(this), "invariant");
assert(object()->mark() == markWord::encode(this), "invariant");

JavaThread * jt = Self->as_Java_thread();
assert(jt->thread_state() != _thread_blocked, "invariant");
@@ -839,7 +839,7 @@ void ObjectMonitor::ReenterI(Thread * Self, ObjectWaiter * SelfNode) {
// In addition, Self.TState is stable.

assert(_owner == Self, "invariant");
assert(((oop)(object()))->mark() == markWord::encode(this), "invariant");
assert(object()->mark() == markWord::encode(this), "invariant");
UnlinkAfterAcquire(Self, SelfNode);
if (_succ == Self) _succ = NULL;
assert(_succ != Self, "invariant");
@@ -1301,7 +1301,7 @@ static void post_monitor_wait_event(EventJavaMonitorWait* event,
bool timedout) {
assert(event != NULL, "invariant");
assert(monitor != NULL, "invariant");
event->set_monitorClass(((oop)monitor->object())->klass());
event->set_monitorClass(monitor->object()->klass());
event->set_timeout(timeout);
event->set_address((uintptr_t)monitor->object_addr());
event->set_notifier(notifier_tid);
@@ -1519,7 +1519,7 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) {
// Verify a few postconditions
assert(_owner == Self, "invariant");
assert(_succ != Self, "invariant");
assert(((oop)(object()))->mark() == markWord::encode(this), "invariant");
assert(object()->mark() == markWord::encode(this), "invariant");

// check if the notification happened
if (!WasNotified) {
@@ -2103,7 +2103,7 @@ void ObjectMonitor::print() const { print_on(tty); }
void ObjectMonitor::print_debug_style_on(outputStream* st) const {
st->print_cr("(ObjectMonitor*) " INTPTR_FORMAT " = {", p2i(this));
st->print_cr(" _header = " INTPTR_FORMAT, header().value());
st->print_cr(" _object = " INTPTR_FORMAT, p2i(_object));
st->print_cr(" _object = " INTPTR_FORMAT, p2i(object()));
st->print(" _allocation_state = ");
if (is_free()) {
st->print("Free");
@@ -328,9 +328,9 @@ class ObjectMonitor {

public:

void* object() const;
void* object_addr();
void set_object(void* obj);
oop object() const;
oop* object_addr();
void set_object(oop obj);
void release_set_allocation_state(AllocationState s);
void set_allocation_state(AllocationState s);
AllocationState allocation_state() const;
@@ -92,22 +92,22 @@ inline void ObjectMonitor::clear_common() {
assert(contentions() <= 0, "must not be positive: contentions=%d", contentions());
assert(_waiters == 0, "must be 0: waiters=%d", _waiters);
assert(_recursions == 0, "must be 0: recursions=" INTX_FORMAT, _recursions);
assert(_object != NULL, "must be non-NULL");
assert(object() != NULL, "must be non-NULL");

set_allocation_state(Free);
_object = NULL;
set_object(NULL);
}

inline void* ObjectMonitor::object() const {
return _object;
inline oop ObjectMonitor::object() const {
return (oop)_object;
}

inline void* ObjectMonitor::object_addr() {
return (void *)(&_object);
inline oop* ObjectMonitor::object_addr() {
return (oop*)&_object;
}

inline void ObjectMonitor::set_object(void* obj) {
_object = obj;
inline void ObjectMonitor::set_object(oop obj) {
_object = (void*)obj;
}

// Return number of threads contending for this monitor.
@@ -462,7 +462,7 @@ bool ObjectSynchronizer::quick_notify(oopDesc* obj, Thread* self, bool all) {

if (mark.has_monitor()) {
ObjectMonitor* const mon = mark.monitor();
assert(mon->object() == obj, "invariant");
assert(mon->object() == oop(obj), "invariant");
if (mon->owner() != self) return false; // slow-path for IMS exception

if (mon->first_waiter() != NULL) {
@@ -683,7 +683,7 @@ void ObjectSynchronizer::exit(oop object, BasicLock* lock, TRAPS) {
// Java Monitor can be asynchronously inflated by a thread that
// does not own the Java Monitor.
ObjectMonitor* m = mark.monitor();
assert(((oop)(m->object()))->mark() == mark, "invariant");
assert(m->object()->mark() == mark, "invariant");
assert(m->is_entered(THREAD), "invariant");
}
}
@@ -1425,7 +1425,7 @@ void ObjectSynchronizer::list_oops_do(ObjectMonitor* list, OopClosure* f) {
// so no need to lock ObjectMonitors for the list traversal.
for (ObjectMonitor* mid = list; mid != NULL; mid = unmarked_next(mid)) {
if (mid->object() != NULL) {
f->do_oop((oop*)mid->object_addr());
f->do_oop(mid->object_addr());
}
}
}
@@ -2146,7 +2146,7 @@ bool ObjectSynchronizer::deflate_monitor_using_JT(ObjectMonitor* mid,
"must be no entering threads: EntryList=" INTPTR_FORMAT,
p2i(mid->_EntryList));

const oop obj = (oop) mid->object();
const oop obj = mid->object();
if (log_is_enabled(Trace, monitorinflation)) {
ResourceMark rm;
log_trace(monitorinflation)("deflate_monitor_using_JT: "
@@ -2867,7 +2867,7 @@ void ObjectSynchronizer::chk_in_use_entry(JavaThread* jt, ObjectMonitor* n,
}
*error_cnt_p = *error_cnt_p + 1;
}
const oop obj = (oop)n->object();
const oop obj = n->object();
const markWord mark = obj->mark();
if (!mark.has_monitor()) {
if (jt != NULL) {
@@ -2977,7 +2977,7 @@ void ObjectSynchronizer::log_in_use_monitor_details(outputStream * out) {
if ((cur = get_list_head_locked(&om_list_globals._in_use_list)) != NULL) {
// Marked the global in-use list head so process the list.
while (true) {
const oop obj = (oop) cur->object();
const oop obj = cur->object();
const markWord mark = cur->header();
ResourceMark rm;
out->print(INTPTR_FORMAT " %d%d%d " INTPTR_FORMAT " %s", p2i(cur),
@@ -3007,7 +3007,7 @@ void ObjectSynchronizer::log_in_use_monitor_details(outputStream * out) {
if ((cur = get_list_head_locked(&jt->om_in_use_list)) != NULL) {
// Marked the global in-use list head so process the list.
while (true) {
const oop obj = (oop) cur->object();
const oop obj = cur->object();
const markWord mark = cur->header();
ResourceMark rm;
out->print(INTPTR_FORMAT " " INTPTR_FORMAT " %d%d%d " INTPTR_FORMAT
@@ -229,12 +229,12 @@ Handle ThreadService::get_current_contended_monitor(JavaThread* thread) {
oop obj = NULL;
if (wait_obj != NULL) {
// thread is doing an Object.wait() call
obj = (oop) wait_obj->object();
obj = wait_obj->object();
} else {
ObjectMonitor *enter_obj = thread->current_pending_monitor();
if (enter_obj != NULL) {
// thread is trying to enter() an ObjectMonitor.
obj = (oop) enter_obj->object();
obj = enter_obj->object();
}
}

@@ -625,7 +625,7 @@ class InflatedMonitorsClosure: public MonitorClosure {
}
void do_monitor(ObjectMonitor* mid) {
if (mid->owner() == _thread) {
oop object = (oop) mid->object();
oop object = mid->object();
if (!_stack_trace->is_owned_monitor_on_stack(object)) {
_stack_trace->add_jni_locked_monitor(object);
}
@@ -997,7 +997,7 @@ void DeadlockCycle::print_on_with(ThreadsList * t_list, outputStream* st) const

if (waitingToLockMonitor != NULL) {
st->print(" waiting to lock monitor " INTPTR_FORMAT, p2i(waitingToLockMonitor));
oop obj = (oop)waitingToLockMonitor->object();
oop obj = waitingToLockMonitor->object();
st->print(" (object " INTPTR_FORMAT ", a %s)", p2i(obj),
obj->klass()->external_name());

@@ -100,8 +100,8 @@ public int contentions() {
}

// FIXME
// void* object_addr();
// void set_object(void* obj);
// oop* object_addr();
// void set_object(oop obj);

// The following four either aren't expressed as typed fields in
// vmStructs.cpp because they aren't strongly typed in the VM, or

1 comment on commit e7a1b9b

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on e7a1b9b Sep 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.