From 2f9550d600e1c2b10e85e4ce00749ab1a160344e 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 bother to check if things we don't relocate have been forwarded r=terrence --- js/src/jsgc.cpp | 11 +++++++++++ js/src/jsgc.h | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index f4faaa2abc16..c291df45d850 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1935,6 +1935,12 @@ CanRelocateAllocKind(AllocKind kind) return kind <= FINALIZE_OBJECT_LAST; } +static bool +CanRelocateTraceKind(JSGCTraceKind kind) +{ + return kind == JSTRACE_OBJECT; +} + size_t ArenaHeader::countFreeCells() { @@ -2249,6 +2255,11 @@ void MovingTracer::Visit(JSTracer *jstrc, void **thingp, JSGCTraceKind kind) { TenuredCell *thing = TenuredCell::fromPointer(*thingp); + if (!CanRelocateTraceKind(kind)) { + MOZ_ASSERT(!IsForwarded(thing)); + return; + } + Zone *zone = thing->zoneFromAnyThread(); if (!zone->isGCCompacting()) { MOZ_ASSERT(!IsForwarded(thing)); diff --git a/js/src/jsgc.h b/js/src/jsgc.h index 1e0bd41c7f85..a49bc4720553 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -1186,11 +1186,36 @@ class RelocationOverlay /* Functions for checking and updating things that might be moved by compacting GC. */ +#define TYPE_MIGHT_BE_FORWARDED(T, value) \ + inline bool \ + TypeMightBeForwarded(T *thing) \ + { \ + return value; \ + } \ + +TYPE_MIGHT_BE_FORWARDED(Cell, true) +TYPE_MIGHT_BE_FORWARDED(JSObject, true) +TYPE_MIGHT_BE_FORWARDED(JSString, false) +TYPE_MIGHT_BE_FORWARDED(JS::Symbol, false) +TYPE_MIGHT_BE_FORWARDED(JSScript, false) +TYPE_MIGHT_BE_FORWARDED(Shape, false) +TYPE_MIGHT_BE_FORWARDED(BaseShape, false) +TYPE_MIGHT_BE_FORWARDED(jit::JitCode, false) +TYPE_MIGHT_BE_FORWARDED(LazyScript, false) +TYPE_MIGHT_BE_FORWARDED(ObjectGroup, false) + +#undef TYPE_MIGHT_BE_FORWARDED + template inline bool IsForwarded(T *t) { RelocationOverlay *overlay = RelocationOverlay::fromCell(t); + if (!TypeMightBeForwarded(t)) { + MOZ_ASSERT(!overlay->isForwarded()); + return false; + } + return overlay->isForwarded(); }