提交 f541523d 编写于 作者: Z zgu

8055007: NMT2: emptyStack missing in minimal build

Summary: Refactored emptyStack to a static member of NativeCallStack, which is accessible in minimal build.
Reviewed-by: coleenp, dholmes
上级 4c7d14c1
...@@ -32,13 +32,14 @@ ...@@ -32,13 +32,14 @@
#include "services/allocationSite.hpp" #include "services/allocationSite.hpp"
#include "services/mallocTracker.hpp" #include "services/mallocTracker.hpp"
#include "services/nmtCommon.hpp" #include "services/nmtCommon.hpp"
#include "utilities/nativeCallStack.hpp"
// MallocSite represents a code path that eventually calls // MallocSite represents a code path that eventually calls
// os::malloc() to allocate memory // os::malloc() to allocate memory
class MallocSite : public AllocationSite<MemoryCounter> { class MallocSite : public AllocationSite<MemoryCounter> {
public: public:
MallocSite() : MallocSite() :
AllocationSite<MemoryCounter>(emptyStack) { } AllocationSite<MemoryCounter>(NativeCallStack::EMPTY_STACK) { }
MallocSite(const NativeCallStack& stack) : MallocSite(const NativeCallStack& stack) :
AllocationSite<MemoryCounter>(stack) { } AllocationSite<MemoryCounter>(stack) { }
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
volatile NMT_TrackingLevel MemTracker::_tracking_level = NMT_unknown; volatile NMT_TrackingLevel MemTracker::_tracking_level = NMT_unknown;
NMT_TrackingLevel MemTracker::_cmdline_tracking_level = NMT_unknown; NMT_TrackingLevel MemTracker::_cmdline_tracking_level = NMT_unknown;
NativeCallStack emptyStack(0, false);
MemBaseline MemTracker::_baseline; MemBaseline MemTracker::_baseline;
Mutex* MemTracker::_query_lock = NULL; Mutex* MemTracker::_query_lock = NULL;
bool MemTracker::_is_nmt_env_valid = true; bool MemTracker::_is_nmt_env_valid = true;
...@@ -69,6 +67,10 @@ NMT_TrackingLevel MemTracker::init_tracking_level() { ...@@ -69,6 +67,10 @@ NMT_TrackingLevel MemTracker::init_tracking_level() {
os::unsetenv(buf); os::unsetenv(buf);
} }
// Construct NativeCallStack::EMPTY_STACK. It may get constructed twice,
// but it is benign, the results are the same.
::new ((void*)&NativeCallStack::EMPTY_STACK) NativeCallStack(0, false);
if (!MallocTracker::initialize(level) || if (!MallocTracker::initialize(level) ||
!VirtualMemoryTracker::initialize(level)) { !VirtualMemoryTracker::initialize(level)) {
level = NMT_off; level = NMT_off;
......
...@@ -26,14 +26,13 @@ ...@@ -26,14 +26,13 @@
#define SHARE_VM_SERVICES_MEM_TRACKER_HPP #define SHARE_VM_SERVICES_MEM_TRACKER_HPP
#include "services/nmtCommon.hpp" #include "services/nmtCommon.hpp"
#include "utilities/nativeCallStack.hpp"
class NativeCallStack;
extern NativeCallStack emptyStack;
#if !INCLUDE_NMT #if !INCLUDE_NMT
#define CURRENT_PC emptyStack #define CURRENT_PC NativeCallStack::EMPTY_STACK
#define CALLER_PC emptyStack #define CALLER_PC NativeCallStack::EMPTY_STACK
class Tracker : public StackObj { class Tracker : public StackObj {
public: public:
...@@ -83,9 +82,9 @@ class MemTracker : AllStatic { ...@@ -83,9 +82,9 @@ class MemTracker : AllStatic {
extern volatile bool NMT_stack_walkable; extern volatile bool NMT_stack_walkable;
#define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \ #define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \
NativeCallStack(0, true) : emptyStack) NativeCallStack(0, true) : NativeCallStack::EMPTY_STACK)
#define CALLER_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \ #define CALLER_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \
NativeCallStack(1, true) : emptyStack) NativeCallStack(1, true) : NativeCallStack::EMPTY_STACK)
class MemBaseline; class MemBaseline;
class Mutex; class Mutex;
......
...@@ -50,9 +50,6 @@ enum NMT_TrackingLevel { ...@@ -50,9 +50,6 @@ enum NMT_TrackingLevel {
// build time decision. // build time decision.
const int NMT_TrackingStackDepth = 4; const int NMT_TrackingStackDepth = 4;
class NativeCallStack;
extern NativeCallStack emptyStack;
// A few common utilities for native memory tracking // A few common utilities for native memory tracking
class NMTUtil : AllStatic { class NMTUtil : AllStatic {
public: public:
......
...@@ -167,7 +167,7 @@ bool ReservedMemoryRegion::remove_uncommitted_region(address addr, size_t sz) { ...@@ -167,7 +167,7 @@ bool ReservedMemoryRegion::remove_uncommitted_region(address addr, size_t sz) {
// higher part // higher part
address high_base = addr + sz; address high_base = addr + sz;
size_t high_size = top - high_base; size_t high_size = top - high_base;
CommittedMemoryRegion high_rgn(high_base, high_size, emptyStack); CommittedMemoryRegion high_rgn(high_base, high_size, NativeCallStack::EMPTY_STACK);
return add_committed_region(high_rgn); return add_committed_region(high_rgn);
} else { } else {
return false; return false;
......
...@@ -320,7 +320,7 @@ class ReservedMemoryRegion : public VirtualMemoryRegion { ...@@ -320,7 +320,7 @@ class ReservedMemoryRegion : public VirtualMemoryRegion {
ReservedMemoryRegion(address base, size_t size) : ReservedMemoryRegion(address base, size_t size) :
VirtualMemoryRegion(base, size), _stack(emptyStack), _flag(mtNone), VirtualMemoryRegion(base, size), _stack(NativeCallStack::EMPTY_STACK), _flag(mtNone),
_all_committed(false) { } _all_committed(false) { }
// Copy constructor // Copy constructor
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
#include "utilities/nativeCallStack.hpp" #include "utilities/nativeCallStack.hpp"
const NativeCallStack NativeCallStack::EMPTY_STACK(0, false);
NativeCallStack::NativeCallStack(int toSkip, bool fillStack) : NativeCallStack::NativeCallStack(int toSkip, bool fillStack) :
_hash_value(0) { _hash_value(0) {
......
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
* from it. * from it.
*/ */
class NativeCallStack : public StackObj { class NativeCallStack : public StackObj {
public:
static const NativeCallStack EMPTY_STACK;
private: private:
address _stack[NMT_TrackingStackDepth]; address _stack[NMT_TrackingStackDepth];
int _hash_value; int _hash_value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册