RFR: JDK-8301072: Replace NULL with nullptr in share/oops/
Stefan Karlsson
stefank at openjdk.org
Fri Jan 27 11:36:32 UTC 2023
On Wed, 25 Jan 2023 11:46:23 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
> Hi, this PR changes all occurrences of NULL to nullptr for the subdirectory share/oops/. Unfortunately the script that does the change isn't perfect, and so we
> need to comb through these manually to make sure nothing has gone wrong. I also review these changes but things slip past my eyes sometimes.
>
> Here are some typical things to look out for:
>
> 1. No changes but copyright header changed (probably because I reverted some changes but forgot the copyright).
> 2. Macros having their NULL changed to nullptr, these are added to the script when I find them. They should be NULL.
> 3. nullptr in comments and logs. We try to use lower case "null" in these cases as it reads better. An exception is made when code expressions are in a comment.
>
> An example of this:
>
> ```c++
> // This function returns null
> void* ret_null();
> // This function returns true if *x == nullptr
> bool is_nullptr(void** x);
>
>
> Note how `nullptr` participates in a code expression here, we really are talking about the specific value `nullptr`.
>
> Thanks!
Changes requested by stefank (Reviewer).
src/hotspot/share/oops/compressedOops.inline.hpp line 63:
> 61:
> 62: inline oop CompressedOops::decode(narrowOop v) {
> 63: return is_null(v) ? (oop)nullptr : decode_not_null(v);
Seems like we should be able to remove the `(oop)` cast after this change.
src/hotspot/share/oops/compressedOops.inline.hpp line 140:
> 138:
> 139: inline Klass* CompressedKlassPointers::decode(narrowKlass v) {
> 140: return is_null(v) ? (Klass*)nullptr : decode_not_null(v);
Seems like we should be able to remove the `(Klass*)` cast after this change.
src/hotspot/share/oops/constantPool.hpp line 189:
> 187: Symbol* generic_signature() const {
> 188: return (_generic_signature_index == 0) ?
> 189: (Symbol*)nullptr : symbol_at(_generic_signature_index);
Remove cast?
src/hotspot/share/oops/constantPool.hpp line 197:
> 195: Symbol* source_file_name() const {
> 196: return (_source_file_name_index == 0) ?
> 197: (Symbol*)nullptr : symbol_at(_source_file_name_index);
Remove cast?
src/hotspot/share/oops/generateOopMap.cpp line 677:
> 675: #define ALLOC_RESOURCE_ARRAY(var, type, count) \
> 676: var = NEW_RESOURCE_ARRAY_RETURN_NULL(type, count); \
> 677: if (var == nullptr) { \
Could you fix the alignment of the backslashes?
src/hotspot/share/oops/instanceKlass.cpp line 2166:
> 2164: if (jmeths == nullptr || // no cache yet
> 2165: length <= idnum || // cache is too short
> 2166: id == nullptr) { // cache doesn't contain entry
Comments seems to be misaligned now.
src/hotspot/share/oops/instanceKlass.cpp line 2259:
> 2257:
> 2258: if (jmeths == nullptr || // no cache yet
> 2259: (length = (size_t)jmeths[0]) <= idnum) { // cache is too short
Alignment of comments
src/hotspot/share/oops/instanceKlass.cpp line 2318:
> 2316: if (jmeths != NULL && // If there is a cache
> 2317: (length = (size_t)jmeths[0]) > idnum) { // and if it is long enough,
> 2318: id = jmeths[idnum+1]; // Look up the id (may be NULL)
Alignment of comments
src/hotspot/share/oops/klass.cpp line 433:
> 431: if (super == NULL) return; // special case: class Object
> 432: assert((!super->is_interface() // interfaces cannot be supers
> 433: && (super->superklass() == NULL || !is_interface())),
Alignment of comments
src/hotspot/share/oops/method.hpp line 167:
> 165:
> 166: // generics support
> 167: Symbol* generic_signature() const { int idx = generic_signature_index(); return ((idx != 0) ? constants()->symbol_at(idx) : (Symbol*)nullptr); }
Remove cast?
src/hotspot/share/oops/oopHandle.inline.hpp line 34:
> 32:
> 33: inline oop OopHandle::resolve() const {
> 34: return (_obj == nullptr) ? (oop)nullptr : NativeAccess<>::oop_load(_obj);
Remove cast?
src/hotspot/share/oops/oopHandle.inline.hpp line 38:
> 36:
> 37: inline oop OopHandle::peek() const {
> 38: return (_obj == nullptr) ? (oop)nullptr : NativeAccess<AS_NO_KEEPALIVE>::oop_load(_obj);
Remove cast?
src/hotspot/share/oops/oopHandle.inline.hpp line 53:
> 51: if (_obj != nullptr) {
> 52: // Clear the OopHandle first
> 53: NativeAccess<>::oop_store(_obj, (oop)nullptr);
Remove cast?
src/hotspot/share/oops/weakHandle.cpp line 54:
> 52: // Clear the WeakHandle. For race in creating ClassLoaderData, we can release this
> 53: // WeakHandle before it is cleared by GC.
> 54: NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(_obj, (oop)nullptr);
Remove cast?
-------------
PR: https://git.openjdk.org/jdk/pull/12186
More information about the hotspot-dev
mailing list