From 846f3968f90b3cf59d1243b4f552245b9b9405b0 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Tue, 24 Feb 2015 09:40:02 +0000 Subject: [PATCH] Bug 1135100 - Don't update GC thing pointers that haven't changed after marking r=terrence --- js/src/gc/Marking.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index d64c4e209aa4..8239e669dd65 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -691,14 +691,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(str)); + if (str != prior) + *id = NON_INTEGER_ATOM_TO_JSID(reinterpret_cast(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(); @@ -755,14 +759,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(thing); + MarkInternal(trc, &str); + if (str != thing) + v->setString(str); } else if (v->isObject()) { - v->setObjectOrNull((JSObject *)thing); + JSObject *obj = static_cast(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(thing); + MarkInternal(trc, &sym); + if (sym != thing) + v->setSymbol(sym); } } else { /* Unset realLocation manually if we do not call MarkInternal. */