Currently ::malloc() can be called by many places, including
ResourceObj::operator new()
-> AllocateHeap()
-> os::malloc(size_t, MEMFLAGS flags, const NativeCallStack&)
Inside os::malloc(), many checks are done related to NMT (and afterJDK-8253495, checking DumpSharedSpaces).
During the review ofJDK-8253495, it was suggested that we should try to reduce the overheads in os::malloc(). Maybe we should have a fast path when both NMT and DumpSharedSpaces, we should directly call into os::malloc() and avoid all the unnecessary checks.
I.e., add something like this at various places??
char* AllocateHeap(size_t size,
MEMFLAGS flags,
const NativeCallStack& stack,
AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) {
+ if (_os_malloc_fast_path) {
+ return os::fast_malloc(size);
+ }
char* p = (char*) os::malloc(size, flags, stack);
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
}
return p;
}
(Note: it's unclear how much this would save.)
ResourceObj::operator new()
-> AllocateHeap()
-> os::malloc(size_t, MEMFLAGS flags, const NativeCallStack&)
Inside os::malloc(), many checks are done related to NMT (and after
During the review of
I.e., add something like this at various places??
char* AllocateHeap(size_t size,
MEMFLAGS flags,
const NativeCallStack& stack,
AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) {
+ if (_os_malloc_fast_path) {
+ return os::fast_malloc(size);
+ }
char* p = (char*) os::malloc(size, flags, stack);
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
}
return p;
}
(Note: it's unclear how much this would save.)