Backed out changeset 2073d5aae8b6 (Avoid integer math for GC trigger factor calculation in allocation path (bug 503463)).

This commit is contained in:
Peter Van der Beken 2009-07-14 11:49:43 +02:00
commit 50446c955e
3 changed files with 9 additions and 29 deletions

View File

@ -2585,7 +2585,7 @@ JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32 value)
default:
JS_ASSERT(key == JSGC_TRIGGER_FACTOR);
JS_ASSERT(value >= 100);
rt->SetGCTriggerFactor(value);
rt->gcTriggerFactor = value;
return;
}
}

View File

@ -369,16 +369,15 @@ struct JSRuntime {
JSDHashTable gcRootsHash;
JSDHashTable *gcLocksHash;
jsrefcount gcKeepAtoms;
size_t gcBytes;
size_t gcLastBytes;
size_t gcMaxBytes;
size_t gcMaxMallocBytes;
uint32 gcBytes;
uint32 gcLastBytes;
uint32 gcMaxBytes;
uint32 gcMaxMallocBytes;
uint32 gcEmptyArenaPoolLifespan;
uint32 gcLevel;
uint32 gcNumber;
JSTracer *gcMarkingTracer;
uint32 gcTriggerFactor;
size_t gcTriggerBytes;
volatile JSBool gcIsNeeded;
/*
@ -683,9 +682,6 @@ struct JSRuntime {
JSFunctionMeter functionMeter;
char lastScriptFilename[1024];
#endif
void SetGCTriggerFactor(uint32 factor);
void SetGCLastBytes(size_t lastBytes);
};
/* Common macros to access thread-local caches in JSThread or JSRuntime. */

View File

@ -1308,13 +1308,13 @@ js_InitGC(JSRuntime *rt, uint32 maxbytes)
* By default the trigger factor gets maximum possible value. This
* means that GC will not be triggered by growth of GC memory (gcBytes).
*/
rt->SetGCTriggerFactor((uint32) -1);
rt->gcTriggerFactor = (uint32) -1;
/*
* The assigned value prevents GC from running when GC memory is too low
* (during JS engine start).
*/
rt->SetGCLastBytes(8192);
rt->gcLastBytes = 8192;
METER(memset(&rt->gcStats, 0, sizeof rt->gcStats));
return JS_TRUE;
@ -1800,22 +1800,6 @@ EnsureLocalFreeList(JSContext *cx)
#endif
void
JSRuntime::SetGCTriggerFactor(uint32 factor)
{
JS_ASSERT(factor >= 100);
gcTriggerFactor = factor;
SetGCLastBytes(gcLastBytes);
}
void
JSRuntime::SetGCLastBytes(size_t lastBytes)
{
gcLastBytes = lastBytes;
gcTriggerBytes = lastBytes * gcTriggerFactor / 100;
}
static JS_INLINE bool
IsGCThresholdReached(JSRuntime *rt)
{
@ -1830,7 +1814,7 @@ IsGCThresholdReached(JSRuntime *rt)
* the gcBytes value is close to zero at the JS engine start.
*/
return rt->gcMallocBytes >= rt->gcMaxMallocBytes ||
rt->gcBytes >= rt->gcTriggerBytes;
rt->gcBytes / rt->gcTriggerFactor >= rt->gcLastBytes / 100;
}
void *
@ -3862,7 +3846,7 @@ out:
goto restart;
}
rt->SetGCLastBytes(rt->gcBytes);
rt->gcLastBytes = rt->gcBytes;
done_running:
rt->gcLevel = 0;
rt->gcRunning = JS_FALSE;