Bug 743047 - Make the script atoms HeapPointers; r=billm

These are only initialized and then read from, but we need to barrier the init
so that we will have a remembered set entry for atoms that are in the nursery.

--HG--
extra : rebase_source : 9a5a1eb3e0c76d4624a978627ff901d336b0c540
This commit is contained in:
Terrence Cole 2012-04-05 15:54:57 -07:00
Родитель 92ed04c94f
Коммит 8576312a1c
6 изменённых файлов: 25 добавлений и 17 удалений

Просмотреть файл

@ -502,8 +502,10 @@ js_DumpAtoms(JSContext *cx, FILE *fp)
JS_STATIC_ASSERT(TEMP_SIZE_START >= sizeof(JSHashTable));
namespace js {
void
js_InitAtomMap(JSContext *cx, AtomIndexMap *indices, JSAtom **atoms)
InitAtomMap(JSContext *cx, AtomIndexMap *indices, HeapPtrAtom *atoms)
{
if (indices->isMap()) {
typedef AtomIndexMap::WordMap WordMap;
@ -512,7 +514,7 @@ js_InitAtomMap(JSContext *cx, AtomIndexMap *indices, JSAtom **atoms)
JSAtom *atom = r.front().key;
jsatomid index = r.front().value;
JS_ASSERT(index < indices->count());
atoms[index] = atom;
atoms[index].init(atom);
}
} else {
for (const AtomIndexMap::InlineElem *it = indices->asInline(), *end = indices->inlineEnd();
@ -521,13 +523,11 @@ js_InitAtomMap(JSContext *cx, AtomIndexMap *indices, JSAtom **atoms)
if (!atom)
continue;
JS_ASSERT(it->value < indices->count());
atoms[it->value] = atom;
atoms[it->value].init(atom);
}
}
}
namespace js {
bool
IndexToIdSlow(JSContext *cx, uint32_t index, jsid *idp)
{

Просмотреть файл

@ -470,15 +470,15 @@ inline bool
js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
jsid *idp, js::Value *vp);
namespace js {
/*
* For all unmapped atoms recorded in al, add a mapping from the atom's index
* to its address. map->length must already be set to the number of atoms in
* the list and map->vector must point to pre-allocated memory.
*/
extern void
js_InitAtomMap(JSContext *cx, js::AtomIndexMap *indices, JSAtom **atoms);
namespace js {
InitAtomMap(JSContext *cx, AtomIndexMap *indices, HeapPtrAtom *atoms);
template<XDRMode mode>
bool

Просмотреть файл

@ -390,7 +390,7 @@ CallSetter(JSContext *cx, JSObject *obj, jsid id, StrictPropertyOp op, unsigned
return CallJSPropertyOpSetter(cx, op, obj, id, strict, vp);
}
static inline JSAtom **
static inline HeapPtrAtom *
FrameAtomBase(JSContext *cx, js::StackFrame *fp)
{
return fp->script()->atoms;

Просмотреть файл

@ -1509,7 +1509,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode)
* access. For less frequent object loads we have to recover the segment
* from atoms pointer first.
*/
JSAtom **atoms = script->atoms;
HeapPtrAtom *atoms = script->atoms;
#if JS_HAS_GENERATORS
if (JS_UNLIKELY(regs.fp()->isGeneratorFrame())) {

Просмотреть файл

@ -674,8 +674,16 @@ js::XDRScript(XDRState<mode> *xdr, JSScript **scriptp, JSScript *parentScript)
}
for (i = 0; i != natoms; ++i) {
if (!XDRAtom(xdr, &script->atoms[i]))
return false;
if (mode == XDR_DECODE) {
JSAtom *tmp = NULL;
if (!XDRAtom(xdr, &tmp))
return false;
script->atoms[i].init(tmp);
} else {
JSAtom *tmp = script->atoms[i];
if (!XDRAtom(xdr, &tmp))
return false;
}
}
/*
@ -1106,7 +1114,7 @@ JSScript::NewScript(JSContext *cx, uint32_t length, uint32_t nsrcnotes, uint32_t
if (natoms != 0) {
script->natoms = natoms;
script->atoms = reinterpret_cast<JSAtom **>(cursor);
script->atoms = reinterpret_cast<HeapPtrAtom *>(cursor);
cursor += natoms * sizeof(script->atoms[0]);
}
@ -1205,7 +1213,7 @@ JSScript::NewScriptFromEmitter(JSContext *cx, BytecodeEmitter *bce)
nfixed = bce->inFunction() ? bce->bindings.countVars() : 0;
JS_ASSERT(nfixed < SLOTNO_LIMIT);
script->nfixed = uint16_t(nfixed);
js_InitAtomMap(cx, bce->atomIndices.getMap(), script->atoms);
InitAtomMap(cx, bce->atomIndices.getMap(), script->atoms);
filename = bce->parser->tokenStream.getFilename();
if (filename) {
@ -1828,7 +1836,7 @@ JSScript::markChildren(JSTracer *trc)
for (uint32_t i = 0; i < natoms; ++i) {
if (atoms[i])
MarkStringUnbarriered(trc, &atoms[i], "atom");
MarkString(trc, &atoms[i], "atom");
}
if (JSScript::isValidOffset(objectsOffset)) {

Просмотреть файл

@ -409,7 +409,7 @@ struct JSScript : public js::gc::Cell
comment above NewScript() for details) */
const char *filename; /* source filename or null */
JSAtom **atoms; /* maps immediate index to literal struct */
js::HeapPtrAtom *atoms; /* maps immediate index to literal struct */
JSPrincipals *principals;/* principals for this script */
JSPrincipals *originPrincipals; /* see jsapi.h 'originPrincipals' comment */
@ -755,7 +755,7 @@ struct JSScript : public js::gc::Cell
return isValidOffset(closedVarsOffset) ? closedVars()->length : 0;
}
JSAtom *getAtom(size_t index) {
js::HeapPtrAtom &getAtom(size_t index) const {
JS_ASSERT(index < natoms);
return atoms[index];
}