--- old/src/share/vm/utilities/nativeCallStack.cpp 2016-07-31 23:33:19.975301387 -0700 +++ new/src/share/vm/utilities/nativeCallStack.cpp 2016-07-31 23:33:19.912301202 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -33,6 +33,19 @@ _hash_value(0) { if (fillStack) { + // We need to skip the NativeCallStack::NativeCallStack frame if a tail call is NOT used + // to call os::get_native_stack. A tail call is used if _NMT_NOINLINE_ is not defined + // (which means this is not a slowdebug build), and we are on 64-bit (except Windows). + // This is not necessarily a rule, but what has been obvserved to date. +#define TAIL_CALL (!defined(_NMT_NOINLINE_) && !defined(WINDOWS) && defined(_LP64)) +#if !TAIL_CALL + toSkip++; +#if (defined(_NMT_NOINLINE_) && defined(BSD) && defined(_LP64)) + // Mac OS X slowdebug builds have this odd behavior where NativeCallStack::NativeCallStack + // appears as two frames, so we need to skip an extra frame. + toSkip++; +#endif +#endif os::get_native_stack(_stack, NMT_TrackingStackDepth, toSkip); } else { for (int index = 0; index < NMT_TrackingStackDepth; index ++) {