mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 671482 - Rename some identifiers to improve clarity. r=anygregor.
This commit is contained in:
parent
6ccefeb374
commit
bc2ec1e581
@ -12,35 +12,37 @@
|
||||
|
||||
/* We allow to allocate 2 (system/user) chunks. */
|
||||
|
||||
/* XXX: using pool[0] and pool[1] is a hack; bug 669123 will fix this. */
|
||||
static const int SYSTEM = 0;
|
||||
static const int USER = 1;
|
||||
static const int N_POOLS = 2;
|
||||
|
||||
class CustomGCChunkAllocator: public js::GCChunkAllocator {
|
||||
public:
|
||||
CustomGCChunkAllocator() { pool[0] = NULL; pool[1] = NULL; }
|
||||
void *pool[2];
|
||||
CustomGCChunkAllocator() { pool[SYSTEM] = NULL; pool[USER] = NULL; }
|
||||
void *pool[N_POOLS];
|
||||
|
||||
private:
|
||||
|
||||
virtual void *doAlloc() {
|
||||
if (!pool[0] && !pool[1])
|
||||
if (!pool[SYSTEM] && !pool[USER])
|
||||
return NULL;
|
||||
void *chunk = NULL;
|
||||
if (pool[0]) {
|
||||
chunk = pool[0];
|
||||
pool[0] = NULL;
|
||||
if (pool[SYSTEM]) {
|
||||
chunk = pool[SYSTEM];
|
||||
pool[SYSTEM] = NULL;
|
||||
} else {
|
||||
chunk = pool[1];
|
||||
pool[1] = NULL;
|
||||
chunk = pool[USER];
|
||||
pool[USER] = NULL;
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
virtual void doFree(void *chunk) {
|
||||
JS_ASSERT(!pool[0] || !pool[1]);
|
||||
if (!pool[0]) {
|
||||
pool[0] = chunk;
|
||||
JS_ASSERT(!pool[SYSTEM] || !pool[USER]);
|
||||
if (!pool[SYSTEM]) {
|
||||
pool[SYSTEM] = chunk;
|
||||
} else {
|
||||
pool[1] = chunk;
|
||||
pool[USER] = chunk;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -81,8 +83,8 @@ BEGIN_TEST(testGCChunkAlloc)
|
||||
CHECK(!ok);
|
||||
CHECK(!JS_IsExceptionPending(cx));
|
||||
CHECK_EQUAL(errorCount, 1);
|
||||
CHECK(!customGCChunkAllocator.pool[0]);
|
||||
CHECK(!customGCChunkAllocator.pool[1]);
|
||||
CHECK(!customGCChunkAllocator.pool[SYSTEM]);
|
||||
CHECK(!customGCChunkAllocator.pool[USER]);
|
||||
JS_GC(cx);
|
||||
JS_ToggleOptions(cx, JSOPTION_JIT);
|
||||
EVAL("(function() {"
|
||||
@ -105,10 +107,10 @@ virtual JSRuntime * createRuntime() {
|
||||
if (!rt)
|
||||
return NULL;
|
||||
|
||||
customGCChunkAllocator.pool[0] = js::AllocGCChunk();
|
||||
customGCChunkAllocator.pool[1] = js::AllocGCChunk();
|
||||
JS_ASSERT(customGCChunkAllocator.pool[0]);
|
||||
JS_ASSERT(customGCChunkAllocator.pool[1]);
|
||||
customGCChunkAllocator.pool[SYSTEM] = js::AllocGCChunk();
|
||||
customGCChunkAllocator.pool[USER] = js::AllocGCChunk();
|
||||
JS_ASSERT(customGCChunkAllocator.pool[SYSTEM]);
|
||||
JS_ASSERT(customGCChunkAllocator.pool[USER]);
|
||||
|
||||
rt->setCustomGCChunkAllocator(&customGCChunkAllocator);
|
||||
return rt;
|
||||
@ -118,12 +120,12 @@ virtual void destroyRuntime() {
|
||||
JS_DestroyRuntime(rt);
|
||||
|
||||
/* We should get the initial chunk back at this point. */
|
||||
JS_ASSERT(customGCChunkAllocator.pool[0]);
|
||||
JS_ASSERT(customGCChunkAllocator.pool[1]);
|
||||
js::FreeGCChunk(customGCChunkAllocator.pool[0]);
|
||||
js::FreeGCChunk(customGCChunkAllocator.pool[1]);
|
||||
customGCChunkAllocator.pool[0] = NULL;
|
||||
customGCChunkAllocator.pool[1] = NULL;
|
||||
JS_ASSERT(customGCChunkAllocator.pool[SYSTEM]);
|
||||
JS_ASSERT(customGCChunkAllocator.pool[USER]);
|
||||
js::FreeGCChunk(customGCChunkAllocator.pool[SYSTEM]);
|
||||
js::FreeGCChunk(customGCChunkAllocator.pool[USER]);
|
||||
customGCChunkAllocator.pool[SYSTEM] = NULL;
|
||||
customGCChunkAllocator.pool[USER] = NULL;
|
||||
}
|
||||
|
||||
END_TEST(testGCChunkAlloc)
|
||||
|
@ -666,7 +666,7 @@ JSRuntime::init(uint32 maxbytes)
|
||||
return false;
|
||||
}
|
||||
|
||||
atomsCompartment->systemGCChunks = true;
|
||||
atomsCompartment->isSystemCompartment = true;
|
||||
atomsCompartment->setGCLastBytes(8192, GC_NORMAL);
|
||||
|
||||
if (!js_InitAtomState(this))
|
||||
|
@ -375,7 +375,7 @@ struct JSRuntime {
|
||||
uint32 protoHazardShape;
|
||||
|
||||
/* Garbage collector state, used by jsgc.c. */
|
||||
js::GCChunkSet gcChunkSet;
|
||||
js::GCChunkSet gcUserChunkSet;
|
||||
js::GCChunkSet gcSystemChunkSet;
|
||||
|
||||
js::RootedValueMap gcRootsHash;
|
||||
|
@ -397,7 +397,7 @@ struct JS_FRIEND_API(JSCompartment) {
|
||||
size_t gcLastBytes;
|
||||
|
||||
bool hold;
|
||||
bool systemGCChunks;
|
||||
bool isSystemCompartment;
|
||||
|
||||
#ifdef JS_TRACER
|
||||
private:
|
||||
|
@ -465,13 +465,14 @@ PickChunk(JSContext *cx)
|
||||
return chunk;
|
||||
|
||||
JSRuntime *rt = cx->runtime;
|
||||
bool systemGCChunks = cx->compartment->systemGCChunks;
|
||||
bool isSystemCompartment = cx->compartment->isSystemCompartment;
|
||||
|
||||
/*
|
||||
* The chunk used for the last allocation is full, search all chunks for
|
||||
* free arenas.
|
||||
*/
|
||||
GCChunkSet::Range r(systemGCChunks ? rt->gcSystemChunkSet.all() : rt->gcChunkSet.all());
|
||||
GCChunkSet::Range
|
||||
r(isSystemCompartment ? rt->gcSystemChunkSet.all() : rt->gcUserChunkSet.all());
|
||||
for (; !r.empty(); r.popFront()) {
|
||||
chunk = r.front();
|
||||
if (chunk->hasAvailableArenas()) {
|
||||
@ -483,7 +484,7 @@ PickChunk(JSContext *cx)
|
||||
chunk = AllocateGCChunk(rt);
|
||||
if (!chunk) {
|
||||
/* Our last chance is to find an empty chunk in the other chunk set. */
|
||||
GCChunkSet::Enum e(systemGCChunks ? rt->gcChunkSet : rt->gcSystemChunkSet);
|
||||
GCChunkSet::Enum e(isSystemCompartment ? rt->gcUserChunkSet : rt->gcSystemChunkSet);
|
||||
for (; !e.empty(); e.popFront()) {
|
||||
if (e.front()->info.numFree == ArenasPerChunk) {
|
||||
chunk = e.front();
|
||||
@ -500,17 +501,17 @@ PickChunk(JSContext *cx)
|
||||
* FIXME bug 583732 - chunk is newly allocated and cannot be present in
|
||||
* the table so using ordinary lookupForAdd is suboptimal here.
|
||||
*/
|
||||
GCChunkSet::AddPtr p = systemGCChunks ?
|
||||
GCChunkSet::AddPtr p = isSystemCompartment ?
|
||||
rt->gcSystemChunkSet.lookupForAdd(chunk) :
|
||||
rt->gcChunkSet.lookupForAdd(chunk);
|
||||
rt->gcUserChunkSet.lookupForAdd(chunk);
|
||||
JS_ASSERT(!p);
|
||||
if (systemGCChunks) {
|
||||
if (isSystemCompartment) {
|
||||
if (!rt->gcSystemChunkSet.add(p, chunk)) {
|
||||
ReleaseGCChunk(rt, chunk);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (!rt->gcChunkSet.add(p, chunk)) {
|
||||
if (!rt->gcUserChunkSet.add(p, chunk)) {
|
||||
ReleaseGCChunk(rt, chunk);
|
||||
return NULL;
|
||||
}
|
||||
@ -531,7 +532,7 @@ ExpireGCChunks(JSRuntime *rt, JSGCInvocationKind gckind)
|
||||
AutoLockGC lock(rt);
|
||||
|
||||
rt->gcChunksWaitingToExpire = 0;
|
||||
for (GCChunkSet::Enum e(rt->gcChunkSet); !e.empty(); e.popFront()) {
|
||||
for (GCChunkSet::Enum e(rt->gcUserChunkSet); !e.empty(); e.popFront()) {
|
||||
Chunk *chunk = e.front();
|
||||
JS_ASSERT(chunk->info.runtime == rt);
|
||||
if (chunk->unused()) {
|
||||
@ -596,7 +597,7 @@ js_InitGC(JSRuntime *rt, uint32 maxbytes)
|
||||
* Make room for at least 16 chunks so the table would not grow before
|
||||
* the browser starts up.
|
||||
*/
|
||||
if (!rt->gcChunkSet.init(16))
|
||||
if (!rt->gcUserChunkSet.init(16))
|
||||
return false;
|
||||
|
||||
if (!rt->gcSystemChunkSet.init(16))
|
||||
@ -741,7 +742,7 @@ MarkIfGCThingWord(JSTracer *trc, jsuword w)
|
||||
|
||||
Chunk *chunk = Chunk::fromAddress(addr);
|
||||
|
||||
if (!trc->context->runtime->gcChunkSet.has(chunk) &&
|
||||
if (!trc->context->runtime->gcUserChunkSet.has(chunk) &&
|
||||
!trc->context->runtime->gcSystemChunkSet.has(chunk))
|
||||
return CGCT_NOTCHUNK;
|
||||
|
||||
@ -949,11 +950,11 @@ js_FinishGC(JSRuntime *rt)
|
||||
rt->compartments.clear();
|
||||
rt->atomsCompartment = NULL;
|
||||
|
||||
for (GCChunkSet::Range r(rt->gcChunkSet.all()); !r.empty(); r.popFront())
|
||||
for (GCChunkSet::Range r(rt->gcUserChunkSet.all()); !r.empty(); r.popFront())
|
||||
ReleaseGCChunk(rt, r.front());
|
||||
for (GCChunkSet::Range r(rt->gcSystemChunkSet.all()); !r.empty(); r.popFront())
|
||||
ReleaseGCChunk(rt, r.front());
|
||||
rt->gcChunkSet.clear();
|
||||
rt->gcUserChunkSet.clear();
|
||||
rt->gcSystemChunkSet.clear();
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
@ -2279,7 +2280,7 @@ MarkAndSweep(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind GCTIM
|
||||
JS_ASSERT(gcmarker.getMarkColor() == BLACK);
|
||||
rt->gcMarkingTracer = &gcmarker;
|
||||
|
||||
for (GCChunkSet::Range r(rt->gcChunkSet.all()); !r.empty(); r.popFront())
|
||||
for (GCChunkSet::Range r(rt->gcUserChunkSet.all()); !r.empty(); r.popFront())
|
||||
r.front()->bitmap.clear();
|
||||
|
||||
for (GCChunkSet::Range r(rt->gcSystemChunkSet.all()); !r.empty(); r.popFront())
|
||||
@ -2877,7 +2878,7 @@ NewCompartment(JSContext *cx, JSPrincipals *principals)
|
||||
JSRuntime *rt = cx->runtime;
|
||||
JSCompartment *compartment = cx->new_<JSCompartment>(rt);
|
||||
if (compartment && compartment->init()) {
|
||||
compartment->systemGCChunks = principals && !strcmp(principals->codebase, "[System Principal]");
|
||||
compartment->isSystemCompartment = principals && !strcmp(principals->codebase, "[System Principal]");
|
||||
if (principals) {
|
||||
compartment->principals = principals;
|
||||
JSPRINCIPALS_HOLD(cx, principals);
|
||||
|
Loading…
Reference in New Issue
Block a user