mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-27 03:50:36 +00:00
8f529f64f5
- Bug 932865 - Add ThreadHangStats for collecting background hang telemetry; r=vladan (2f08a076b)
- Bug 932865 - Add way for telemetry to iterate over active threads; r=froydnj (535615d3d)
- Bug 1128768: Part 3 - Update BHR to allow for hang annotations; r=vladan (0b880a667)
- Bug 935092 - Add ThreadStackHelper to get a thread's pesudo-stack; r=BenWa (1422cfe4d)
- Bug 942488 - Don't report pseudo-stacks without SPS profiler. r=nchen (e160a7a08)
- Bug 946817 - Don't assert mPseudoStack on B2G. r=BenWa (9f846df3b)
- Bug 951431 - Don't get stacks during profiler runs on Linux; r=BenWa (15036e907)
- Bug 978262 - Ignore duplicate frames when getting BHR stack. r=froydnj (964721b1b)
- Bug 985155 - Add signal trampoline on ARM Linux to work around kernel bug. r=snorp (cb8a7846c)
- Bug 995730 - Convert xpcom/threads/ to Gecko style. r=froydnj (fe150404e)
- Bug 1013326 - Distinguish chrome and content scripts in pseudostack; r=snorp (81273c977)
- Bug 1023461 - Remove temporary stack buffer in ThreadStackHelper; r=snorp (cf5a717c2)
- Bug 1023461 - Record filename and line number for chrome JS entries; r=snorp (10c89808f)
- Bug 1022456 - Fix modelines in xpcom/{base,glue,io,string,threads}/. (48dbc0416)
- Bug 1016441 - Switch to using real-time signal in ThreadStackHelper; (2c5f818be)
- Bug 1016629 - b. Use RAII class to assign mStackToFill; r=snorp (769eae130)
- Bug 1016629 - c. Add define for ThreadStackHelper pseudostack support; r=snorp (67def0d2f)
- Bug 1016629 - d. Add and implement GetNativeStack method in ThreadStackHelper; r=snorp r=jseward (46c52f2be)
- Bug 1016629 - e. Implement platform-specific code for filling in context; r=snorp r=jseward (e6a66858b)
- Bug 1016629 - g. Avoid ASan flag when copying stack; r=snorp (0159628b5)
- Bug 1045176 - Unbreak build on non-SPS platforms after bug 1016629. (f1d60d838)
- Bug 1047123 - ThreadStackHelper should use UniquePtr<uint8_t[]>, not ScopedDeleteArray. r=jchen (0e4af313c)
- Bug 1049161 - Fix ThreadStackHelper thread handle permissions on Windows; r=snorp (c05172b1c)
- Bug 1050185 - Make ThreadStackHelper::FillThreadContext Valgrind-friendly. r=nchen (368725774)
- Bug 1050440 - Remove repeated js::RunScript frames in ThreadStackHelper (2a79600b3)
- Bug 1046841 - Fix more style violations in previously touched .cpp files in xpcom/. r=froydnj (02afe2493)
- Bug 1069694 - Remove or move around functions in OldDebugAPI. r=shu (177197302)
- Bug 1069694 - Remove OldDebugAPI from the browser. r=shu (b8c917d42)
- Bug 1100911 - For MacOS builds running on Valgrind, make ThreadStackHelper::GetStack be a no-op. r=nchen. (d99c02e16)
- Bug 1091758 - Report full paths for most chrome scripts; r=snorp (2b72e7878)
- Bug 1109291 - Include better paths for hanging chrome scripts in profile extensions directory; r=snorp r=bsmedberg (1997b9532)
- Bug 1113416 - Don't read stack labels inside hang monitor sighandler; r=nfroyd r=snorp (9688f6069)
- bug 1146027 - more final r=froydnj (7b0f295e5)
- Bug 1164090 - Check for Windows path separator in BHR file name; r=snorp (f014b4d78)
- Bug 1169034 - include <cstdlib> in ThreadStackHelper.cpp to declare correct overload for std::abs; r=jseward (874d4447e)
- Bug 1182996 - Fix and add missing namespace comments. rs=ehsan (054fc00b2)
- Bug 932865 - Collect thread hang stats in BackgroundHangMonitor; (ac80c8e9f)
- minor anticipated fixes to get it compiling (2bd701d15)
193 lines
4.1 KiB
C++
193 lines
4.1 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "CacheHashUtils.h"
|
|
|
|
#include "plstr.h"
|
|
|
|
namespace mozilla {
|
|
namespace net {
|
|
|
|
/**
|
|
* CacheHash::Hash(const char * key, uint32_t initval)
|
|
*
|
|
* See http://burtleburtle.net/bob/hash/evahash.html for more information
|
|
* about this hash function.
|
|
*
|
|
* This algorithm is used to check the data integrity.
|
|
*/
|
|
|
|
static inline void hashmix(uint32_t& a, uint32_t& b, uint32_t& c)
|
|
{
|
|
a -= b; a -= c; a ^= (c>>13);
|
|
b -= c; b -= a; b ^= (a<<8);
|
|
c -= a; c -= b; c ^= (b>>13);
|
|
a -= b; a -= c; a ^= (c>>12);
|
|
b -= c; b -= a; b ^= (a<<16);
|
|
c -= a; c -= b; c ^= (b>>5);
|
|
a -= b; a -= c; a ^= (c>>3);
|
|
b -= c; b -= a; b ^= (a<<10);
|
|
c -= a; c -= b; c ^= (b>>15);
|
|
}
|
|
|
|
CacheHash::Hash32_t
|
|
CacheHash::Hash(const char *aData, uint32_t aSize, uint32_t aInitval)
|
|
{
|
|
const uint8_t *k = reinterpret_cast<const uint8_t*>(aData);
|
|
uint32_t a, b, c, len;
|
|
|
|
// length = PL_strlen(key);
|
|
/* Set up the internal state */
|
|
len = aSize;
|
|
a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
|
|
c = aInitval; /* variable initialization of internal state */
|
|
|
|
/*---------------------------------------- handle most of the key */
|
|
while (len >= 12)
|
|
{
|
|
a += k[0] + (uint32_t(k[1])<<8) + (uint32_t(k[2])<<16) + (uint32_t(k[3])<<24);
|
|
b += k[4] + (uint32_t(k[5])<<8) + (uint32_t(k[6])<<16) + (uint32_t(k[7])<<24);
|
|
c += k[8] + (uint32_t(k[9])<<8) + (uint32_t(k[10])<<16) + (uint32_t(k[11])<<24);
|
|
hashmix(a, b, c);
|
|
k += 12; len -= 12;
|
|
}
|
|
|
|
/*------------------------------------- handle the last 11 bytes */
|
|
c += aSize;
|
|
switch(len) { /* all the case statements fall through */
|
|
case 11: c += (uint32_t(k[10])<<24);
|
|
case 10: c += (uint32_t(k[9])<<16);
|
|
case 9 : c += (uint32_t(k[8])<<8);
|
|
/* the low-order byte of c is reserved for the length */
|
|
case 8 : b += (uint32_t(k[7])<<24);
|
|
case 7 : b += (uint32_t(k[6])<<16);
|
|
case 6 : b += (uint32_t(k[5])<<8);
|
|
case 5 : b += k[4];
|
|
case 4 : a += (uint32_t(k[3])<<24);
|
|
case 3 : a += (uint32_t(k[2])<<16);
|
|
case 2 : a += (uint32_t(k[1])<<8);
|
|
case 1 : a += k[0];
|
|
/* case 0: nothing left to add */
|
|
}
|
|
hashmix(a, b, c);
|
|
|
|
return c;
|
|
}
|
|
|
|
CacheHash::Hash16_t
|
|
CacheHash::Hash16(const char *aData, uint32_t aSize, uint32_t aInitval)
|
|
{
|
|
Hash32_t hash = Hash(aData, aSize, aInitval);
|
|
return (hash & 0xFFFF);
|
|
}
|
|
|
|
NS_IMPL_ISUPPORTS0(CacheHash)
|
|
|
|
CacheHash::CacheHash(uint32_t aInitval)
|
|
: mA(0x9e3779b9)
|
|
, mB(0x9e3779b9)
|
|
, mC(aInitval)
|
|
, mPos(0)
|
|
, mBuf(0)
|
|
, mBufPos(0)
|
|
, mLength(0)
|
|
, mFinalized(false)
|
|
{}
|
|
|
|
void
|
|
CacheHash::Feed(uint32_t aVal, uint8_t aLen)
|
|
{
|
|
switch (mPos) {
|
|
case 0:
|
|
mA += aVal;
|
|
mPos ++;
|
|
break;
|
|
|
|
case 1:
|
|
mB += aVal;
|
|
mPos ++;
|
|
break;
|
|
|
|
case 2:
|
|
mPos = 0;
|
|
if (aLen == 4) {
|
|
mC += aVal;
|
|
hashmix(mA, mB, mC);
|
|
}
|
|
else {
|
|
mC += aVal << 8;
|
|
}
|
|
}
|
|
|
|
mLength += aLen;
|
|
}
|
|
|
|
void
|
|
CacheHash::Update(const char *aData, uint32_t aLen)
|
|
{
|
|
const uint8_t *data = reinterpret_cast<const uint8_t*>(aData);
|
|
|
|
MOZ_ASSERT(!mFinalized);
|
|
|
|
if (mBufPos) {
|
|
while (mBufPos != 4 && aLen) {
|
|
mBuf += uint32_t(*data) << 8*mBufPos;
|
|
data++;
|
|
mBufPos++;
|
|
aLen--;
|
|
}
|
|
|
|
if (mBufPos == 4) {
|
|
mBufPos = 0;
|
|
Feed(mBuf);
|
|
mBuf = 0;
|
|
}
|
|
}
|
|
|
|
if (!aLen)
|
|
return;
|
|
|
|
while (aLen >= 4) {
|
|
Feed(data[0] + (uint32_t(data[1]) << 8) + (uint32_t(data[2]) << 16) +
|
|
(uint32_t(data[3]) << 24));
|
|
data += 4;
|
|
aLen -= 4;
|
|
}
|
|
|
|
switch (aLen) {
|
|
case 3: mBuf += data[2] << 16;
|
|
case 2: mBuf += data[1] << 8;
|
|
case 1: mBuf += data[0];
|
|
}
|
|
|
|
mBufPos = aLen;
|
|
}
|
|
|
|
CacheHash::Hash32_t
|
|
CacheHash::GetHash()
|
|
{
|
|
if (!mFinalized)
|
|
{
|
|
if (mBufPos) {
|
|
Feed(mBuf, mBufPos);
|
|
}
|
|
mC += mLength;
|
|
hashmix(mA, mB, mC);
|
|
mFinalized = true;
|
|
}
|
|
|
|
return mC;
|
|
}
|
|
|
|
CacheHash::Hash16_t
|
|
CacheHash::GetHash16()
|
|
{
|
|
Hash32_t hash = GetHash();
|
|
return (hash & 0xFFFF);
|
|
}
|
|
|
|
} // namespace net
|
|
} // namespace mozilla
|
|
|