mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1896973 - Part 1: Tidy some JS::Heap methods r=sfink
This renames address() and unsafeGet() methods to be const and non-const versions of unsafeAddress. The unnecessary operator bool() overload is removed. Differential Revision: https://phabricator.services.mozilla.com/D212260
This commit is contained in:
parent
cd67cc3619
commit
5e6632a42b
@ -4239,7 +4239,7 @@ JS::Handle<JSObject*> GetPerInterfaceObjectHandle(
|
||||
const JS::Heap<JSObject*>& entrySlot =
|
||||
protoAndIfaceCache.EntrySlotMustExist(aSlotId);
|
||||
JS::AssertObjectIsNotGray(entrySlot);
|
||||
return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
|
||||
return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.unsafeAddress());
|
||||
}
|
||||
|
||||
namespace binding_detail {
|
||||
|
@ -3883,7 +3883,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||
fill(
|
||||
"""
|
||||
JS::AssertObjectIsNotGray(*protoCache);
|
||||
JS::Handle<JSObject*> proto = JS::Handle<JSObject*>::fromMarkedLocation(protoCache->address());
|
||||
JS::Handle<JSObject*> proto = JS::Handle<JSObject*>::fromMarkedLocation(protoCache->unsafeAddress());
|
||||
if (!proto) {
|
||||
$*{failureCode}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ class NativeThenHandler<ResolveCallback, RejectCallback, std::tuple<Args...>,
|
||||
template <typename T>
|
||||
static JS::Handle<T> GetJSArgHandleForCall(JS::Heap<T>& aArg) {
|
||||
aArg.exposeToActiveJS();
|
||||
return JS::Handle<T>::fromMarkedLocation(aArg.address());
|
||||
return JS::Handle<T>::fromMarkedLocation(aArg.unsafeAddress());
|
||||
}
|
||||
|
||||
template <typename TCallback, size_t... Indices, size_t... JSIndices>
|
||||
|
@ -343,8 +343,6 @@ class MOZ_NON_MEMMOVABLE Heap : public js::HeapOperations<T, Heap<T>> {
|
||||
DECLARE_POINTER_CONSTREF_OPS(T);
|
||||
DECLARE_POINTER_ASSIGN_OPS(Heap, T);
|
||||
|
||||
const T* address() const { return &ptr; }
|
||||
|
||||
void exposeToActiveJS() const { js::BarrierMethods<T>::exposeToJS(ptr); }
|
||||
|
||||
const T& get() const {
|
||||
@ -362,17 +360,14 @@ class MOZ_NON_MEMMOVABLE Heap : public js::HeapOperations<T, Heap<T>> {
|
||||
ptr = newPtr;
|
||||
postWriteBarrier(tmp, ptr);
|
||||
}
|
||||
|
||||
T* unsafeGet() { return &ptr; }
|
||||
|
||||
void unbarrieredSet(const T& newPtr) { ptr = newPtr; }
|
||||
|
||||
T* unsafeAddress() { return &ptr; }
|
||||
const T* unsafeAddress() const { return &ptr; }
|
||||
|
||||
explicit operator bool() const {
|
||||
return bool(js::BarrierMethods<T>::asGCThingOrNull(ptr));
|
||||
}
|
||||
explicit operator bool() {
|
||||
return bool(js::BarrierMethods<T>::asGCThingOrNull(ptr));
|
||||
}
|
||||
|
||||
private:
|
||||
void postWriteBarrier(const T& prev, const T& next) {
|
||||
@ -526,9 +521,6 @@ class TenuredHeap : public js::HeapOperations<T, TenuredHeap<T>> {
|
||||
explicit operator bool() const {
|
||||
return bool(js::BarrierMethods<T>::asGCThingOrNull(unbarrieredGetPtr()));
|
||||
}
|
||||
explicit operator bool() {
|
||||
return bool(js::BarrierMethods<T>::asGCThingOrNull(unbarrieredGetPtr()));
|
||||
}
|
||||
|
||||
TenuredHeap<T>& operator=(T p) {
|
||||
setPtr(p);
|
||||
|
@ -348,7 +348,7 @@ template <typename T>
|
||||
inline void TraceEdge(JSTracer* trc, JS::Heap<T>* thingp, const char* name) {
|
||||
MOZ_ASSERT(thingp);
|
||||
if (*thingp) {
|
||||
js::gc::TraceExternalEdge(trc, thingp->unsafeGet(), name);
|
||||
js::gc::TraceExternalEdge(trc, thingp->unsafeAddress(), name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2607,7 +2607,7 @@ namespace js::gc {
|
||||
|
||||
template <typename T>
|
||||
JS_PUBLIC_API bool TraceWeakEdge(JSTracer* trc, JS::Heap<T>* thingp) {
|
||||
return TraceEdgeInternal(trc, gc::ConvertToBase(thingp->unsafeGet()),
|
||||
return TraceEdgeInternal(trc, gc::ConvertToBase(thingp->unsafeAddress()),
|
||||
"JS::Heap edge");
|
||||
}
|
||||
|
||||
|
@ -615,7 +615,7 @@ void nsXPCWrappedJS::SystemIsBeingShutDown() {
|
||||
// containing mJSObj, which may have been freed at this point. This is safe
|
||||
// if we are not currently running an incremental GC.
|
||||
MOZ_ASSERT(!JS::IsIncrementalGCInProgress(xpc_GetSafeJSContext()));
|
||||
*mJSObj.unsafeGet() = nullptr;
|
||||
mJSObj.unbarrieredSet(nullptr);
|
||||
if (isInList()) {
|
||||
remove();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user