diff --git a/js/src/gc/GCInternals.h b/js/src/gc/GCInternals.h index 713ef3af61..7d2340e36a 100644 --- a/js/src/gc/GCInternals.h +++ b/js/src/gc/GCInternals.h @@ -215,9 +215,11 @@ RelocationOverlay::forwardTo(Cell* cell) MOZ_ASSERT(!isForwarded()); // The location of magic_ is important because it must never be valid to see // the value Relocated there in a GC thing that has not been moved. - static_assert(offsetof(RelocationOverlay, magic_) == offsetof(JSObject, group_) && - offsetof(RelocationOverlay, magic_) == offsetof(js::Shape, base_) && - offsetof(RelocationOverlay, magic_) == offsetof(JSString, d.u1.flags), + static_assert(offsetof(RelocationOverlay, magic_) == offsetof(JSObject, group_) + sizeof(uint32_t), + "RelocationOverlay::magic_ is in the wrong location"); + static_assert(offsetof(RelocationOverlay, magic_) == offsetof(js::Shape, base_) + sizeof(uint32_t), + "RelocationOverlay::magic_ is in the wrong location"); + static_assert(offsetof(RelocationOverlay, magic_) == offsetof(JSString, d.u1.length), "RelocationOverlay::magic_ is in the wrong location"); magic_ = Relocated; newLocation_ = cell; diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 6f4c4bfa8d..3013802113 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -587,7 +587,7 @@ struct String { static const uint32_t INLINE_CHARS_BIT = JS_BIT(2); static const uint32_t LATIN1_CHARS_BIT = JS_BIT(6); - static const uint32_t ROPE_FLAGS = 0; + static const uint32_t ROPE_FLAGS = NON_ATOM_BIT; static const uint32_t TYPE_FLAGS_MASK = JS_BIT(6) - 1; uint32_t flags; uint32_t length; diff --git a/js/src/vm/String.h b/js/src/vm/String.h index 309e0ceafc..1250959a3a 100644 --- a/js/src/vm/String.h +++ b/js/src/vm/String.h @@ -251,11 +251,11 @@ class JSString : public js::gc::TenuredCell static const uint32_t INLINE_CHARS_BIT = JS_BIT(2); static const uint32_t ATOM_BIT = JS_BIT(3); - static const uint32_t ROPE_FLAGS = 0; - static const uint32_t DEPENDENT_FLAGS = HAS_BASE_BIT; - static const uint32_t UNDEPENDED_FLAGS = FLAT_BIT | HAS_BASE_BIT; - static const uint32_t EXTENSIBLE_FLAGS = FLAT_BIT | JS_BIT(4); - static const uint32_t EXTERNAL_FLAGS = JS_BIT(5); + static const uint32_t ROPE_FLAGS = NON_ATOM_BIT; + static const uint32_t DEPENDENT_FLAGS = NON_ATOM_BIT | HAS_BASE_BIT; + static const uint32_t UNDEPENDED_FLAGS = NON_ATOM_BIT | FLAT_BIT | HAS_BASE_BIT; + static const uint32_t EXTENSIBLE_FLAGS = NON_ATOM_BIT | FLAT_BIT | JS_BIT(4); + static const uint32_t EXTERNAL_FLAGS = NON_ATOM_BIT | JS_BIT(5); static const uint32_t FAT_INLINE_MASK = INLINE_CHARS_BIT | JS_BIT(4); static const uint32_t PERMANENT_ATOM_MASK = ATOM_BIT | JS_BIT(5); @@ -506,11 +506,12 @@ class JSString : public js::gc::TenuredCell static const JS::TraceKind TraceKind = JS::TraceKind::String; JS::Zone* zone() const { - if (isTenured()) { + if (isTenured()) { // Allow permanent atoms to be accessed across zones and runtimes. if (isPermanentAtom()) return zoneFromAnyThread(); return asTenured().zone(); + } return js::Nursery::getStringZone(this); } @@ -1588,4 +1589,15 @@ JSAtom::asPropertyName() return static_cast(this); } +namespace js { +namespace gc { +template<> +inline JSString* +Cell::as() { + MOZ_ASSERT(is()); + return reinterpret_cast(this); +} +} +} + #endif /* vm_String_h */