diff --git a/js/src/gc/Cell.h b/js/src/gc/Cell.h index 6fa72f5568..b9243e0898 100644 --- a/js/src/gc/Cell.h +++ b/js/src/gc/Cell.h @@ -420,7 +420,8 @@ static MOZ_ALWAYS_INLINE void AssertValidToSkipBarrier(TenuredCell* thing) { MOZ_ASSERT(!IsInsideNursery(thing)); - MOZ_ASSERT_IF(thing, MapAllocToTraceKind(thing->getAllocKind()) != JS::TraceKind::Object); + MOZ_ASSERT_IF(thing, MapAllocToTraceKind(thing->getAllocKind()) != JS::TraceKind::Object && + MapAllocToTraceKind(thing->getAllocKind()) != JS::TraceKind::String); } /* static */ MOZ_ALWAYS_INLINE void diff --git a/js/src/gc/RelocationOverlay.h b/js/src/gc/RelocationOverlay.h index 43e80f517f..a1f514d7c5 100644 --- a/js/src/gc/RelocationOverlay.h +++ b/js/src/gc/RelocationOverlay.h @@ -15,6 +15,9 @@ #include +#include "js/HeapAPI.h" +#include "vm/Shape.h" +#include "jsobj.h" namespace js { namespace gc { @@ -26,11 +29,22 @@ struct Cell; */ class RelocationOverlay { - /* The low bit is set so this should never equal a normal pointer. */ - static const uintptr_t Relocated = uintptr_t(0xbad0bad1); + /* See comment in js/public/HeapAPI.h. */ + static const uint32_t Relocated = js::gc::Relocated; + +#if MOZ_LITTLE_ENDIAN + /* + * Keep the low 32 bits untouched. Use them to distinguish strings from + * objects in the nursery. + */ + uint32_t preserve_; /* Set to Relocated when moved. */ - uintptr_t magic_; + uint32_t magic_; +#else + uint32_t magic_; + uint32_t preserve_; +#endif /* The location |this| was moved to. */ Cell* newLocation_; @@ -39,16 +53,15 @@ class RelocationOverlay RelocationOverlay* next_; public: + static const RelocationOverlay* fromCell(const Cell* cell) { + return reinterpret_cast(cell); + } static RelocationOverlay* fromCell(Cell* cell) { return reinterpret_cast(cell); } - // ADD THIS: Const-friendly version - static const RelocationOverlay* fromCell(const Cell* cell) { - return reinterpret_cast(cell); - } - bool isForwarded() const { + (void) preserve_; // Suppress warning return magic_ == Relocated; } @@ -69,7 +82,7 @@ class RelocationOverlay return next_; } - static bool isCellForwarded(Cell* cell) { + static bool isCellForwarded(const Cell* cell) { return fromCell(cell)->isForwarded(); } }; diff --git a/js/src/gc/StoreBuffer-inl.h b/js/src/gc/StoreBuffer-inl.h index 7ef6b10c5c..b244b7672f 100644 --- a/js/src/gc/StoreBuffer-inl.h +++ b/js/src/gc/StoreBuffer-inl.h @@ -10,6 +10,7 @@ #include "gc/Cell.h" #include "gc/Heap.h" +#include "gc/Cell.h" namespace js { namespace gc {