bug 113738 Cost of malloc into trace-malloc log r=blythe, sr=brendan
This commit is contained in:
@@ -138,14 +138,16 @@ DHWImportHooker &getMallocHooker()
|
||||
|
||||
void * __cdecl dhw_malloc( size_t size )
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* result = DHW_ORIGINAL(MALLOC_, getMallocHooker())(size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return result;
|
||||
g_lockOut = TRUE;
|
||||
#ifdef VERBOSE
|
||||
printf("* malloc called to get %d bytes. returned %#x\n", size, result);
|
||||
#endif
|
||||
MallocCallback(result, size);
|
||||
MallocCallback(result, size, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
@@ -162,13 +164,16 @@ DHWImportHooker &getCallocHooker()
|
||||
|
||||
void * __cdecl dhw_calloc( size_t count, size_t size )
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* result = DHW_ORIGINAL(CALLOC_, getCallocHooker())(count,size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return result;
|
||||
g_lockOut = TRUE;
|
||||
#ifdef VERBOSE
|
||||
printf("* calloc called to get %d many of %d bytes. returned %#x\n", count, size, result);
|
||||
#endif CallocCallback(result, count, size);
|
||||
#endif
|
||||
CallocCallback(result, count, size, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
@@ -184,14 +189,16 @@ DHWImportHooker &getFreeHooker()
|
||||
|
||||
void __cdecl dhw_free( void* p )
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
DHW_ORIGINAL(FREE_, getFreeHooker())(p);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return;
|
||||
g_lockOut = TRUE;
|
||||
#ifdef VERBOSE
|
||||
printf("* free called for %#x\n", p);
|
||||
#endif
|
||||
FreeCallback(p);
|
||||
FreeCallback(p, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
@@ -207,7 +214,9 @@ DHWImportHooker &getReallocHooker()
|
||||
|
||||
void * __cdecl dhw_realloc(void * pin, size_t size)
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* pout = DHW_ORIGINAL(REALLOC_, getReallocHooker())(pin, size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return pout;
|
||||
g_lockOut = TRUE;
|
||||
@@ -216,7 +225,7 @@ void * __cdecl dhw_realloc(void * pin, size_t size)
|
||||
printf("* realloc called to resize to %d. old ptr: %#x. new ptr: %#x\n",
|
||||
size, pin, pout);
|
||||
#endif
|
||||
ReallocCallback(pin,pout,size);
|
||||
ReallocCallback(pin, pout, size, start, end);
|
||||
// dumpStack();
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
@@ -233,8 +242,9 @@ DHWImportHooker &getNewHooker()
|
||||
|
||||
void * __cdecl dhw_new(size_t size)
|
||||
{
|
||||
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
void* result = DHW_ORIGINAL(NEW_, getNewHooker())(size);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return result;
|
||||
g_lockOut = TRUE;
|
||||
@@ -243,7 +253,7 @@ void * __cdecl dhw_new(size_t size)
|
||||
printf("* new called to get %d bytes. returned %#x\n", size, result);
|
||||
dumpStack();
|
||||
#endif
|
||||
MallocCallback(result,size);//do we need a different one for new?
|
||||
MallocCallback(result, size, start, end);//do we need a different one for new?
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
return result;
|
||||
@@ -259,7 +269,9 @@ DHWImportHooker &getDeleteHooker()
|
||||
|
||||
void __cdecl dhw_delete(void* p)
|
||||
{
|
||||
PRUint32 start = PR_IntervalNow();
|
||||
DHW_ORIGINAL(DELETE_, getDeleteHooker())(p);
|
||||
PRUint32 end = PR_IntervalNow();
|
||||
if (g_lockOut)
|
||||
return;
|
||||
g_lockOut = TRUE;
|
||||
@@ -267,7 +279,7 @@ void __cdecl dhw_delete(void* p)
|
||||
printf("* delete called for %#x\n", p);
|
||||
dumpStack();
|
||||
#endif
|
||||
FreeCallback(p);
|
||||
FreeCallback(p, start, end);
|
||||
// printf("\n");
|
||||
g_lockOut = FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user