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.
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.
- links to
-
Review(master) openjdk/jdk/12621
-
Review(master) openjdk/jdk/23994
-
Review(master) openjdk/jdk/24189