RFR: 8309044: Replace NULL with nullptr, final sweep of hotspot code [v2]

Doug Simon dnsimon at openjdk.org
Thu Jun 1 10:16:24 UTC 2023


On Tue, 30 May 2023 19:15:38 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> A final sweep of Hotspot to remove all re-added NULLs. With only 110 changes I'd appreciate if this was considered trivial.
>
> Johan Sjölen has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Align
>  - Suggestions

It may be simpler to use simple grepping + an allow list. For example using [`ag`](https://github.com/ggreer/the_silver_searcher) and `grep` seems to catch the few remaining offenders:

> ag NULL src/hotspot/ --cpp | grep -v _NULL | grep -v NULL_ | grep -v -E '[A-Z]NULL' | grep -v -E '//.*NULL' | grep -v '"NULL"'
src/hotspot/cpu/ppc/macroAssembler_ppc.hpp:735:  void load_klass_check_null(Register dst, Register src, Label* is_null = NULL);
src/hotspot/cpu/ppc/stubGenerator_ppc.cpp:4700:    if (UnsafeCopyMemory::_table == NULL) {
src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp:191:    if (nop == NULL) {
src/hotspot/cpu/riscv/codeBuffer_riscv.cpp:74:  if (cb->stubs()->maybe_expand_to_ensure_remaining(total_requested_size) && cb->blob() == NULL) {
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:4019:    if (UnsafeCopyMemory::_table == NULL) {
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:4077:    if (bs_nm != NULL) {
src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp:125:  NativeCall* call = NULL;
src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp:158:    if (nop == NULL) {
src/hotspot/share/jfr/dcmd/jfrDcmds.hpp:162:    JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
src/hotspot/share/jfr/dcmd/jfrDcmds.hpp:187:    JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
src/hotspot/share/include/jvm.h:423: * Find a class from a boot class loader. Returns NULL if class not found.
src/hotspot/share/prims/jvmtiAgent.cpp:375:  const jint err = (*on_load_entry)(&main_vm, const_cast<char*>(agent->options()), NULL);
src/hotspot/share/prims/whitebox.cpp:1885:  if (cp->cache() == NULL) {
src/hotspot/share/prims/whitebox.cpp:1894:  if (cp->cache() == NULL) {
src/hotspot/share/classfile/stringTable.hpp:150:  static oop init_shared_table(const DumpedInternedStrings* dumped_interned_strings) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
src/hotspot/share/utilities/globalDefinitions_xlc.hpp:95:  #undef NULL
src/hotspot/share/utilities/globalDefinitions_xlc.hpp:96:  #define NULL 0L
src/hotspot/share/utilities/globalDefinitions_xlc.hpp:98:  #ifndef NULL
src/hotspot/share/utilities/globalDefinitions_xlc.hpp:99:    #define NULL 0
src/hotspot/share/cds/filemap.cpp:363:  assert(ent != NULL, "sanity");
src/hotspot/share/utilities/globalDefinitions_visCPP.hpp:65:#undef NULL
src/hotspot/share/utilities/globalDefinitions_visCPP.hpp:69:#define NULL 0LL
src/hotspot/share/utilities/globalDefinitions_visCPP.hpp:71:#ifndef NULL
src/hotspot/share/utilities/globalDefinitions_visCPP.hpp:72:#define NULL 0
src/hotspot/share/utilities/globalDefinitions.cpp:162:  static_assert(sizeof(NULL) == sizeof(char*), "NULL must be same size as pointer");
src/hotspot/share/adlc/output_c.cpp:279:  for (pipeline->_reslist.reset(); (resource = pipeline->_reslist.iter()) != NULL;) {
src/hotspot/share/adlc/output_c.cpp:305:  for (pipeline->_reslist.reset(); (resource = pipeline->_reslist.iter()) != NULL;) {
src/hotspot/share/adlc/output_c.cpp:368:  for (pipeline->_reslist.reset(); (resource = pipeline->_reslist.iter()) != NULL;) {
src/hotspot/share/adlc/output_c.cpp:393:  for (pipeline->_reslist.reset(); (resource = pipeline->_reslist.iter()) != NULL;) {
src/hotspot/share/adlc/output_c.cpp:1009:  for (_pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL;) {
src/hotspot/share/gc/x/xBarrierSet.inline.hpp:187:    return Raw::oop_arraycopy_in_heap(nullptr, 0, src, NULL, 0, dst, length);
src/hotspot/share/gc/x/xPageTable.inline.hpp:43:    if (entry != NULL && entry != _prev) {
src/hotspot/share/gc/x/xBarrier.cpp:242:  return NULL;
src/hotspot/share/oops/cpCache.cpp:888:  LogStream* log_stream = NULL;
src/hotspot/share/oops/cpCache.cpp:906:    assert(resolved_references->obj_at(appendix_index) == NULL, "init just once");
src/hotspot/share/oops/cpCache.cpp:914:  if (log_stream != NULL) {
src/hotspot/share/opto/runtime.cpp:491:  fields[TypeFunc::Parms+0] = NULL; // void
src/hotspot/share/jvmci/jvmciEnv.cpp:366:    if (ex != NULL) {

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14198#issuecomment-1571756690


More information about the hotspot-dev mailing list