Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8301404

Factor out os::malloc with os::realloc common code, so that we only have 1 code path

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Withdrawn
    • Icon: P4 P4
    • tbd
    • 21
    • hotspot

      We do not need both malloc and realloc.

      ptr = malloc(size)

      is equivalent to

      ptr = realloc(NULL, size)

      Yet, when I look at the code (haven't actually try it yet) I see some differences that suggests that we would not be able to do it right now. For example, our os:malloc() has this:

        if (DumpSharedSpaces) {
          // Need to deterministically fill all the alignment gaps in C++ structures.
          ::memset(inner_ptr, 0, size);
        } else {
          DEBUG_ONLY(::memset(inner_ptr, uninitBlockPad, size);)
        }

      and os:realloc() only has this (but only if NMT is enabled):

      #ifdef ASSERT
          size_t old_size = free_info.size;
          if (old_size < size) {
            // We also zap the newly extended region.
            ::memset((char*)new_inner_ptr + old_size, uninitBlockPad, size - old_size);
          }
      #endif

      Investigate and remove os:malloc() if we can, so we only need to support one codepath.

            gziemski Gerard Ziemski
            gziemski Gerard Ziemski
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: