提交 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 @@
#include "services/allocationSite.hpp"
#include "services/mallocTracker.hpp"
#include "services/nmtCommon.hpp"
#include "utilities/nativeCallStack.hpp"
// MallocSite represents a code path that eventually calls
// os::malloc() to allocate memory
class MallocSite : public AllocationSite<MemoryCounter> {
public:
MallocSite() :
AllocationSite<MemoryCounter>(emptyStack) { }
AllocationSite<MemoryCounter>(NativeCallStack::EMPTY_STACK) { }
MallocSite(const NativeCallStack& stack) :
AllocationSite<MemoryCounter>(stack) { }
......
......@@ -39,8 +39,6 @@
volatile NMT_TrackingLevel MemTracker::_tracking_level = NMT_unknown;
NMT_TrackingLevel MemTracker::_cmdline_tracking_level = NMT_unknown;
NativeCallStack emptyStack(0, false);
MemBaseline MemTracker::_baseline;
Mutex* MemTracker::_query_lock = NULL;
bool MemTracker::_is_nmt_env_valid = true;
......@@ -69,6 +67,10 @@ NMT_TrackingLevel MemTracker::init_tracking_level() {
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) ||
!VirtualMemoryTracker::initialize(level)) {
level = NMT_off;
......
......@@ -26,14 +26,13 @@
#define SHARE_VM_SERVICES_MEM_TRACKER_HPP
#include "services/nmtCommon.hpp"
#include "utilities/nativeCallStack.hpp"
class NativeCallStack;
extern NativeCallStack emptyStack;
#if !INCLUDE_NMT
#define CURRENT_PC emptyStack
#define CALLER_PC emptyStack
#define CURRENT_PC NativeCallStack::EMPTY_STACK
#define CALLER_PC NativeCallStack::EMPTY_STACK
class Tracker : public StackObj {
public:
......@@ -83,9 +82,9 @@ class MemTracker : AllStatic {
extern volatile bool 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) ? \
NativeCallStack(1, true) : emptyStack)
NativeCallStack(1, true) : NativeCallStack::EMPTY_STACK)
class MemBaseline;
class Mutex;
......
......@@ -50,9 +50,6 @@ enum NMT_TrackingLevel {
// build time decision.
const int NMT_TrackingStackDepth = 4;
class NativeCallStack;
extern NativeCallStack emptyStack;
// A few common utilities for native memory tracking
class NMTUtil : AllStatic {
public:
......
......@@ -167,7 +167,7 @@ bool ReservedMemoryRegion::remove_uncommitted_region(address addr, size_t sz) {
// higher part
address high_base = addr + sz;
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);
} else {
return false;
......
......@@ -320,7 +320,7 @@ class ReservedMemoryRegion : public VirtualMemoryRegion {
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) { }
// Copy constructor
......
......@@ -27,6 +27,7 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/nativeCallStack.hpp"
const NativeCallStack NativeCallStack::EMPTY_STACK(0, false);
NativeCallStack::NativeCallStack(int toSkip, bool fillStack) :
_hash_value(0) {
......
......@@ -52,6 +52,9 @@
* from it.
*/
class NativeCallStack : public StackObj {
public:
static const NativeCallStack EMPTY_STACK;
private:
address _stack[NMT_TrackingStackDepth];
int _hash_value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册