diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h index 70c4fb525358..a156ea1d4d16 100644 --- a/js/public/GCAPI.h +++ b/js/public/GCAPI.h @@ -289,7 +289,7 @@ ExposeGCThingToActiveJS(void *thing, JSGCTraceKind kind) * All live objects in the nursery are moved to tenured at the beginning of * each GC slice, so the gray marker never sees nursery things. */ - if (uintptr_t(thing) >= rt->gcNurseryStart_ && uintptr_t(thing) < rt->gcNurseryEnd_) + if (js::gc::IsInsideNursery(rt, thing)) return; #endif if (IsIncrementalBarrierNeededOnGCThing(rt, thing, kind)) diff --git a/js/public/HeapAPI.h b/js/public/HeapAPI.h index 057c7f3b6238..505c90af0e6f 100644 --- a/js/public/HeapAPI.h +++ b/js/public/HeapAPI.h @@ -149,6 +149,16 @@ GetGCThingArena(void *thing) return reinterpret_cast(addr); } +JS_ALWAYS_INLINE bool +IsInsideNursery(const JS::shadow::Runtime *runtime, const void *p) +{ +#ifdef JSGC_GENERATIONAL + return uintptr_t(p) >= runtime->gcNurseryStart_ && uintptr_t(p) < runtime->gcNurseryEnd_; +#else + return false; +#endif +} + } /* namespace gc */ } /* namespace js */ @@ -178,7 +188,7 @@ GCThingIsMarkedGray(void *thing) * each GC slice, so the gray marker never sees nursery things. */ JS::shadow::Runtime *rt = js::gc::GetGCThingRuntime(thing); - if (uintptr_t(thing) >= rt->gcNurseryStart_ && uintptr_t(thing) < rt->gcNurseryEnd_) + if (js::gc::IsInsideNursery(rt, thing)) return false; #endif uintptr_t *word, mask; diff --git a/js/src/gc/Heap.h b/js/src/gc/Heap.h index e8be86561188..2ae6ac20b6fe 100644 --- a/js/src/gc/Heap.h +++ b/js/src/gc/Heap.h @@ -1049,7 +1049,7 @@ Cell::isTenured() const { #ifdef JSGC_GENERATIONAL JS::shadow::Runtime *rt = js::gc::GetGCThingRuntime(this); - return uintptr_t(this) < rt->gcNurseryStart_ || uintptr_t(this) >= rt->gcNurseryEnd_; + return !IsInsideNursery(rt, this); #endif return true; } diff --git a/js/src/gc/Nursery.h b/js/src/gc/Nursery.h index d2d802b261d5..d782691d5926 100644 --- a/js/src/gc/Nursery.h +++ b/js/src/gc/Nursery.h @@ -66,7 +66,7 @@ class Nursery template JS_ALWAYS_INLINE bool isInside(const T *p) const { - return uintptr_t(p) >= start() && uintptr_t(p) < heapEnd(); + return gc::IsInsideNursery((JS::shadow::Runtime *)runtime_, p); } /* diff --git a/js/src/jsgcinlines.h b/js/src/jsgcinlines.h index abab06b00ad0..b0cbd1c04667 100644 --- a/js/src/jsgcinlines.h +++ b/js/src/jsgcinlines.h @@ -91,15 +91,6 @@ ShouldNurseryAllocate(const Nursery &nursery, AllocKind kind, InitialHeap heap) } #endif -inline bool -IsInsideNursery(JSRuntime *rt, const void *thing) -{ -#ifdef JSGC_GENERATIONAL - return rt->gcNursery.isInside(thing); -#endif - return false; -} - inline JSGCTraceKind GetGCThingTraceKind(const void *thing) {