diff --git a/hphp/runtime/base/hphp_array.cpp b/hphp/runtime/base/hphp_array.cpp index 040afaa62..6538fc39f 100644 --- a/hphp/runtime/base/hphp_array.cpp +++ b/hphp/runtime/base/hphp_array.cpp @@ -1397,7 +1397,7 @@ ArrayData* HphpArray::nvNew(TypedValue*& ret, bool copy) { // nvGetKey does not touch out->_count, so can be used // for inner or outer cells. void HphpArray::NvGetKeyVec(const ArrayData* ad, TypedValue* out, ssize_t pos) { - auto a = asVector(ad); + DEBUG_ONLY auto a = asVector(ad); assert(pos != ArrayData::invalid_index); assert(!isTombstone(a->m_data[pos].data.m_type)); out->m_data.num = pos; diff --git a/hphp/runtime/vm/jit/translator-x64.cpp b/hphp/runtime/vm/jit/translator-x64.cpp index a3dffb0b8..500e76197 100644 --- a/hphp/runtime/vm/jit/translator-x64.cpp +++ b/hphp/runtime/vm/jit/translator-x64.cpp @@ -59,6 +59,7 @@ #include "hphp/util/timer.h" #include "hphp/util/trace.h" #include "hphp/util/meta.h" +#include "hphp/util/process.h" #include "hphp/util/util.h" #include "hphp/util/repo_schema.h" #include "hphp/util/cycles.h" @@ -3824,7 +3825,7 @@ TranslatorX64::requestExit() { } TRACE_MOD(txlease, 2, "%" PRIx64 " write lease stats: %15" PRId64 " kept, %15" PRId64 " grabbed\n", - pthread_self(), s_writeLease.m_hintKept, + Process::GetThreadIdForTrace(), s_writeLease.m_hintKept, s_writeLease.m_hintGrabbed); PendQ::drain(); Treadmill::finishRequest(g_vmContext->m_currentThreadIdx); diff --git a/hphp/runtime/vm/jit/write-lease.cpp b/hphp/runtime/vm/jit/write-lease.cpp index 6809bbc74..3a81a3128 100644 --- a/hphp/runtime/vm/jit/write-lease.cpp +++ b/hphp/runtime/vm/jit/write-lease.cpp @@ -14,6 +14,7 @@ +----------------------------------------------------------------------+ */ #include "hphp/runtime/vm/jit/write-lease.h" +#include "hphp/util/process.h" #include "hphp/util/timer.h" #include "hphp/runtime/vm/bytecode.h" #include "hphp/runtime/vm/jit/translator.h" @@ -77,7 +78,7 @@ bool Lease::acquire(bool blocking /* = false */ ) { pthread_mutex_lock(&m_lock) : pthread_mutex_trylock(&m_lock))) { TRACE(4, "thr%" PRIx64 ": acquired lease, called by %p,%p\n", - pthread_self(), __builtin_return_address(0), + Process::GetThreadIdForTrace(), __builtin_return_address(0), __builtin_return_address(1)); if (debug) { pushRank(RankWriteLease); @@ -86,7 +87,7 @@ bool Lease::acquire(bool blocking /* = false */ ) { TRACE(3, "thr%" PRIx64 ": acquired hinted lease" ", expired %" PRId64 "us ago\n", - pthread_self(), -expireDiff); + Process::GetThreadIdForTrace(), -expireDiff); } else if (expire != 0 && m_owner == pthread_self()) { m_hintKept++; } @@ -100,7 +101,7 @@ bool Lease::acquire(bool blocking /* = false */ ) { } if (blocking) { TRACE(3, "thr%" PRIx64 ": failed to acquired lease in blocking mode\n", - pthread_self()); + Process::GetThreadIdForTrace()); } return false; } @@ -108,7 +109,7 @@ bool Lease::acquire(bool blocking /* = false */ ) { void Lease::drop(int64_t hintExpireDelay) { assert(amOwner()); TRACE(4, "thr%" PRIx64 ": dropping lease, called by %p,%p\n", - pthread_self(), __builtin_return_address(0), + Process::GetThreadIdForTrace(), __builtin_return_address(0), __builtin_return_address(1)); if (debug) { popRank(RankWriteLease); diff --git a/hphp/util/process.h b/hphp/util/process.h index 686c22387..8b7f1cc7d 100644 --- a/hphp/util/process.h +++ b/hphp/util/process.h @@ -115,6 +115,21 @@ public: return pthread_self(); } + /** + * Current thread's identifier. + */ + static uint64_t GetThreadIdForTrace() { + // For tracing purposes this just needs to be unique, pthread_t is not + // portable but even if it's a pointer to a struct like on OSX this will + // produce a unique value. If we support platforms where this isn't the + // case we will need to revisit this. +#ifdef __linux__ + return pthread_self(); +#else + return (uint64_t)pthread_self(); +#endif + } + /* * Thread's process identifier. */ diff --git a/hphp/util/rank.cpp b/hphp/util/rank.cpp index 7bc370841..80f615e39 100644 --- a/hphp/util/rank.cpp +++ b/hphp/util/rank.cpp @@ -18,6 +18,7 @@ #include "hphp/util/base.h" #include "hphp/util/mutex.h" +#include "hphp/util/process.h" namespace HPHP { #ifdef DEBUG @@ -44,10 +45,10 @@ void checkRank(Rank r) { if (r == RankLeaf) { fprintf(stderr, "Rank violation in thr%" PRIx64 "! leaf lock from leaf rank; ", - pthread_self()); + Process::GetThreadIdForTrace()); } else { fprintf(stderr, "Rank violation in thr%" PRIx64 "! lock of rank %d; ", - pthread_self(), r); + Process::GetThreadIdForTrace(), r); } fprintf(stderr, "held locks:\n"); for (int i = tl_curRankDepth - 1; i >= 0; --i) {