Skip to content

Commit

Permalink
Bug 1135100 - Don't update GC thing pointers that haven't changed aft…
Browse files Browse the repository at this point in the history
…er marking r=terrence
  • Loading branch information
rmottola committed Aug 30, 2019
1 parent 3336fab commit 0df3ea8
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions js/src/gc/Marking.cpp
Expand Up @@ -714,14 +714,18 @@ MarkIdInternal(JSTracer *trc, jsid *id)
{
if (JSID_IS_STRING(*id)) {
JSString *str = JSID_TO_STRING(*id);
JSString *prior = str;
trc->setTracingLocation((void *)id);
MarkInternal(trc, &str);
*id = NON_INTEGER_ATOM_TO_JSID(reinterpret_cast<JSAtom *>(str));
if (str != prior)
*id = NON_INTEGER_ATOM_TO_JSID(reinterpret_cast<JSAtom *>(str));
} else if (JSID_IS_SYMBOL(*id)) {
JS::Symbol *sym = JSID_TO_SYMBOL(*id);
JS::Symbol *prior = sym;
trc->setTracingLocation((void *)id);
MarkInternal(trc, &sym);
*id = SYMBOL_TO_JSID(sym);
if (sym != prior)
*id = SYMBOL_TO_JSID(sym);
} else {
/* Unset realLocation manually if we do not call MarkInternal. */
trc->unsetTracingLocation();
Expand Down Expand Up @@ -778,14 +782,22 @@ MarkValueInternal(JSTracer *trc, Value *v)
MOZ_ASSERT(v->toGCThing());
void *thing = v->toGCThing();
trc->setTracingLocation((void *)v);
MarkKind(trc, &thing, v->gcKind());
if (v->isString()) {
v->setString((JSString *)thing);
JSString *str = static_cast<JSString*>(thing);
MarkInternal(trc, &str);
if (str != thing)
v->setString(str);
} else if (v->isObject()) {
v->setObjectOrNull((JSObject *)thing);
JSObject *obj = static_cast<JSObject*>(thing);
MarkInternal(trc, &obj);
if (obj != thing)
v->setObjectOrNull(obj);
} else {
MOZ_ASSERT(v->isSymbol());
v->setSymbol((JS::Symbol *)thing);
JS::Symbol *sym = static_cast<JS::Symbol*>(thing);
MarkInternal(trc, &sym);
if (sym != thing)
v->setSymbol(sym);
}
} else {
/* Unset realLocation manually if we do not call MarkInternal. */
Expand Down

0 comments on commit 0df3ea8

Please sign in to comment.