class NativeCallStack : public StackObj { private:
address _stack[NMT_TrackingStackDepth]; staticconst NativeCallStack _empty_stack;
public:
enum class FakeMarker { its_fake }; #ifdef ASSERT static constexpr uintptr_t _fake_address = -2; // 0xFF...FE
inline void assert_not_fake() const {
assert(_stack[0] != (address)_fake_address, "Must not be a fake stack");
} #endif
// This "fake" constructor is only used in the CALLER_PC and CURRENT_PC macros // when NMT is off or in summary mode. In these cases, it does not need a // callstack, and we can leave the constructed object uninitialized. That will // cause the constructor call to be optimized away (see JDK-8296437).
explicit NativeCallStack(FakeMarker dummy) { #ifdef ASSERT
for (int i = 0; i < NMT_TrackingStackDepth; i++) {
_stack[i] = (address)_fake_address;
} #endif
}
// Default ctor creates an empty stack. // (it may make sense to remove this altogether but its used in a few places).
NativeCallStack() {
memset(_stack, 0, sizeof(_stack));
}
explicit NativeCallStack(int toSkip);
explicit NativeCallStack(address* pc, int frameCount);
inline address get_frame(int index) const {
assert(index >= 0 && index < NMT_TrackingStackDepth, "Index out of bound"); return _stack[index];
}
// Helper; calculates a hash value over the stack frames in this stack unsigned int calculate_hash() const {
DEBUG_ONLY(assert_not_fake();)
uintptr_t hash = 0;
for (int i = 0; i < NMT_TrackingStackDepth; i++) {
hash += (uintptr_t)_stack[i];
} return hash;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.