8324242: Avoid null check for OopHandle::ptr_raw()
Reviewed-by: shade, jsjolen, coleenp
This commit is contained in:
parent
929af9ed03
commit
3059c3b69e
@ -838,10 +838,10 @@ OopHandle ClassLoaderData::add_handle(Handle h) {
|
||||
|
||||
void ClassLoaderData::remove_handle(OopHandle h) {
|
||||
assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading");
|
||||
oop* ptr = h.ptr_raw();
|
||||
if (ptr != nullptr) {
|
||||
assert(_handles.owner_of(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
|
||||
NativeAccess<>::oop_store(ptr, oop(nullptr));
|
||||
if (!h.is_empty()) {
|
||||
assert(_handles.owner_of(h.ptr_raw()),
|
||||
"Got unexpected handle " PTR_FORMAT, p2i(h.ptr_raw()));
|
||||
h.replace(oop(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2024, 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
|
||||
@ -582,7 +582,7 @@ protected:
|
||||
if (has_archived_mirror_index()) {
|
||||
// _java_mirror is not a valid OopHandle but rather an encoded reference in the shared heap
|
||||
return false;
|
||||
} else if (_java_mirror.ptr_raw() == nullptr) {
|
||||
} else if (_java_mirror.is_empty()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2024, 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
|
||||
@ -57,9 +57,8 @@ inline void OopHandle::release(OopStorage* storage) {
|
||||
}
|
||||
|
||||
inline void OopHandle::replace(oop obj) {
|
||||
oop* ptr = ptr_raw();
|
||||
assert(ptr != nullptr, "should not use replace");
|
||||
NativeAccess<>::oop_store(ptr, obj);
|
||||
assert(!is_empty(), "should not use replace");
|
||||
NativeAccess<>::oop_store(_obj, obj);
|
||||
}
|
||||
|
||||
inline oop OopHandle::xchg(oop new_value) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, Azul Systems, Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -194,7 +194,7 @@ oop JavaThread::scopedValueCache() const {
|
||||
}
|
||||
|
||||
void JavaThread::set_scopedValueCache(oop p) {
|
||||
if (_scopedValueCache.ptr_raw() != nullptr) { // i.e. if the OopHandle has been allocated
|
||||
if (!_scopedValueCache.is_empty()) { // i.e. if the OopHandle has been allocated
|
||||
_scopedValueCache.replace(p);
|
||||
} else {
|
||||
assert(p == nullptr, "not yet initialized");
|
||||
|
Loading…
Reference in New Issue
Block a user