8227692: Remove develop feature PrintMallocStatistics
Reviewed-by: coleenp, dcubed
--- a/src/hotspot/share/memory/allocation.cpp Thu Jul 18 14:01:54 2019 +0200
+++ b/src/hotspot/share/memory/allocation.cpp Fri Jul 19 10:18:48 2019 +0200
@@ -259,25 +259,6 @@
st->print("AllocatedObj(" INTPTR_FORMAT ")", p2i(this));
}
-AllocStats::AllocStats() {
- start_mallocs = os::num_mallocs;
- start_frees = os::num_frees;
- start_malloc_bytes = os::alloc_bytes;
- start_mfree_bytes = os::free_bytes;
- start_res_bytes = Arena::_bytes_allocated;
-}
-
-julong AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; }
-julong AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; }
-julong AllocStats::num_frees() { return os::num_frees - start_frees; }
-julong AllocStats::free_bytes() { return os::free_bytes - start_mfree_bytes; }
-julong AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; }
-void AllocStats::print() {
- tty->print_cr(UINT64_FORMAT " mallocs (" UINT64_FORMAT "MB), "
- UINT64_FORMAT " frees (" UINT64_FORMAT "MB), " UINT64_FORMAT "MB resrc",
- num_mallocs(), alloc_bytes()/M, num_frees(), free_bytes()/M, resource_bytes()/M);
-}
-
ReallocMark::ReallocMark() {
#ifdef ASSERT
Thread *thread = Thread::current();
--- a/src/hotspot/share/memory/allocation.hpp Thu Jul 18 14:01:54 2019 +0200
+++ b/src/hotspot/share/memory/allocation.hpp Fri Jul 19 10:18:48 2019 +0200
@@ -507,23 +507,6 @@
#define FREE_C_HEAP_OBJ(objname)\
FreeHeap((char*)objname);
-// for statistics
-#ifndef PRODUCT
-class AllocStats : StackObj {
- julong start_mallocs, start_frees;
- julong start_malloc_bytes, start_mfree_bytes, start_res_bytes;
- public:
- AllocStats();
-
- julong num_mallocs(); // since creation of receiver
- julong alloc_bytes();
- julong num_frees();
- julong free_bytes();
- julong resource_bytes();
- void print();
-};
-#endif
-
//------------------------------ReallocMark---------------------------------
// Code which uses REALLOC_RESOURCE_ARRAY should check an associated
--- a/src/hotspot/share/memory/allocation.inline.hpp Thu Jul 18 14:01:54 2019 +0200
+++ b/src/hotspot/share/memory/allocation.inline.hpp Fri Jul 19 10:18:48 2019 +0200
@@ -34,16 +34,13 @@
// Explicit C-heap memory management
#ifndef PRODUCT
-// Increments unsigned long value for statistics (not atomic on MP).
+// Increments unsigned long value for statistics (not atomic on MP, but avoids word-tearing on 32 bit).
inline void inc_stat_counter(volatile julong* dest, julong add_value) {
-#if defined(SPARC) || defined(X86)
- // Sparc and X86 have atomic jlong (8 bytes) instructions
+#ifdef _LP64
+ *dest += add_value;
+#else
julong value = Atomic::load(dest);
- value += add_value;
- Atomic::store(value, dest);
-#else
- // possible word-tearing during load/store
- *dest += add_value;
+ Atomic::store(value + add_value, dest);
#endif
}
#endif
--- a/src/hotspot/share/memory/arena.cpp Thu Jul 18 14:01:54 2019 +0200
+++ b/src/hotspot/share/memory/arena.cpp Fri Jul 19 10:18:48 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -475,10 +475,6 @@
#ifndef PRODUCT
-julong Arena::_bytes_allocated = 0;
-
-void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); }
-
// debugging code
inline void Arena::free_all(char** start, char** end) {
for (char** p = start; p < end; p++) if (*p) os::free(*p);
--- a/src/hotspot/share/memory/arena.hpp Thu Jul 18 14:01:54 2019 +0200
+++ b/src/hotspot/share/memory/arena.hpp Fri Jul 19 10:18:48 2019 +0200
@@ -106,11 +106,8 @@
void* grow(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
size_t _size_in_bytes; // Size of arena (used for native memory tracking)
- NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start
- friend class AllocStats;
debug_only(void* malloc(size_t size);)
debug_only(void* internal_malloc_4(size_t x);)
- NOT_PRODUCT(void inc_bytes_allocated(size_t x);)
void signal_out_of_memory(size_t request, const char* whence) const;
@@ -148,7 +145,6 @@
debug_only(if (UseMallocOnly) return malloc(x);)
if (!check_for_overflow(x, "Arena::Amalloc", alloc_failmode))
return NULL;
- NOT_PRODUCT(inc_bytes_allocated(x);)
if (_hwm + x > _max) {
return grow(x, alloc_failmode);
} else {
@@ -163,7 +159,6 @@
debug_only(if (UseMallocOnly) return malloc(x);)
if (!check_for_overflow(x, "Arena::Amalloc_4", alloc_failmode))
return NULL;
- NOT_PRODUCT(inc_bytes_allocated(x);)
if (_hwm + x > _max) {
return grow(x, alloc_failmode);
} else {
@@ -185,7 +180,6 @@
#endif
if (!check_for_overflow(x, "Arena::Amalloc_D", alloc_failmode))
return NULL;
- NOT_PRODUCT(inc_bytes_allocated(x);)
if (_hwm + x > _max) {
return grow(x, alloc_failmode); // grow() returns a result aligned >= 8 bytes.
} else {
--- a/src/hotspot/share/runtime/globals.hpp Thu Jul 18 14:01:54 2019 +0200
+++ b/src/hotspot/share/runtime/globals.hpp Fri Jul 19 10:18:48 2019 +0200
@@ -466,9 +466,6 @@
develop(bool, UseMallocOnly, false, \
"Use only malloc/free for allocation (no resource area/arena)") \
\
- develop(bool, PrintMallocStatistics, false, \
- "Print malloc/free statistics") \
- \
develop(bool, ZapResourceArea, trueInDebug, \
"Zap freed resource/arena space with 0xABABABAB") \
\
--- a/src/hotspot/share/runtime/java.cpp Thu Jul 18 14:01:54 2019 +0200
+++ b/src/hotspot/share/runtime/java.cpp Fri Jul 19 10:18:48 2019 +0200
@@ -203,9 +203,6 @@
}
}
-AllocStats alloc_stats;
-
-
// General statistics printing (profiling ...)
void print_statistics() {
@@ -329,11 +326,6 @@
}
print_bytecode_count();
- if (PrintMallocStatistics) {
- tty->print("allocation stats: ");
- alloc_stats.print();
- tty->cr();
- }
if (PrintSystemDictionaryAtExit) {
ResourceMark rm;