Bug 558861 - Compartmental GC (r=gal)
This commit is contained in:
@@ -65,8 +65,7 @@
|
||||
#include "jsobjinlines.h"
|
||||
|
||||
using namespace js;
|
||||
|
||||
using namespace js;
|
||||
using namespace js::gc;
|
||||
|
||||
/*
|
||||
* ATOM_HASH assumes that JSHashNumber is 32-bit even on 64-bit systems.
|
||||
@@ -444,8 +443,8 @@ js_SweepAtomState(JSContext *cx)
|
||||
AtomEntryType entry = e.front();
|
||||
if (AtomEntryFlags(entry) & (ATOM_PINNED | ATOM_INTERNED)) {
|
||||
/* Pinned or interned key cannot be finalized. */
|
||||
JS_ASSERT(!js_IsAboutToBeFinalized(AtomEntryToKey(entry)));
|
||||
} else if (js_IsAboutToBeFinalized(AtomEntryToKey(entry))) {
|
||||
JS_ASSERT(!IsAboutToBeFinalized(AtomEntryToKey(entry)));
|
||||
} else if (IsAboutToBeFinalized(AtomEntryToKey(entry))) {
|
||||
e.removeFront();
|
||||
}
|
||||
}
|
||||
@@ -500,7 +499,7 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||
JSAtomState *state = &cx->runtime->atomState;
|
||||
AtomSet &atoms = state->atoms;
|
||||
|
||||
JS_LOCK(cx, &state->lock);
|
||||
AutoLockDefaultCompartment lock(cx);
|
||||
AtomSet::AddPtr p = atoms.lookupForAdd(str);
|
||||
|
||||
/* Hashing the string should have flattened it if it was a rope. */
|
||||
@@ -521,9 +520,8 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||
key = str;
|
||||
atoms.add(p, StringToInitialAtomEntry(key));
|
||||
} else {
|
||||
JS_UNLOCK(cx, &state->lock);
|
||||
|
||||
if (flags & ATOM_TMPSTR) {
|
||||
JSAutoEnterCompartment ac(cx, cx->runtime->defaultCompartment);
|
||||
if (flags & ATOM_NOCOPY) {
|
||||
key = js_NewString(cx, str->flatChars(), str->flatLength());
|
||||
if (!key)
|
||||
@@ -543,9 +541,7 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||
key = str;
|
||||
}
|
||||
|
||||
JS_LOCK(cx, &state->lock);
|
||||
if (!atoms.relookupOrAdd(p, key, StringToInitialAtomEntry(key))) {
|
||||
JS_UNLOCK(cx, &state->lock);
|
||||
JS_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report */
|
||||
return NULL;
|
||||
}
|
||||
@@ -557,7 +553,6 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
|
||||
|
||||
JS_ASSERT(key->isAtomized());
|
||||
JSAtom *atom = STRING_TO_ATOM(key);
|
||||
JS_UNLOCK(cx, &state->lock);
|
||||
return atom;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user