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:15 +02:00
parent 0c6942b658
commit cf914cb140
3 changed files with 9 additions and 29 deletions

View File

@ -2583,7 +2583,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

@ -1304,13 +1304,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;
@ -1796,22 +1796,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)
{
@ -1826,7 +1810,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 *
@ -3858,7 +3842,7 @@ out:
goto restart;
}
rt->SetGCLastBytes(rt->gcBytes);
rt->gcLastBytes = rt->gcBytes;
done_running:
rt->gcLevel = 0;
rt->gcRunning = JS_FALSE;