mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-12 00:50:40 +00:00
Bug 1721333 part 5 - Use a reserved slot instead of private slot for DebuggerInstanceObject. r=jonco
Depends on D120310 Differential Revision: https://phabricator.services.mozilla.com/D120311
This commit is contained in:
parent
0cb0639db2
commit
35bbd0896d
@ -17,7 +17,8 @@
|
||||
/* static */ inline js::Debugger* js::Debugger::fromJSObject(
|
||||
const JSObject* obj) {
|
||||
MOZ_ASSERT(obj->is<DebuggerInstanceObject>());
|
||||
return (Debugger*)obj->as<NativeObject>().getPrivate();
|
||||
auto* dbg = &obj->as<DebuggerInstanceObject>();
|
||||
return dbg->maybePtrFromReservedSlot<Debugger>(JSSLOT_DEBUG_DEBUGGER);
|
||||
}
|
||||
|
||||
inline bool js::Debugger::isHookCallAllowed(JSContext* cx) const {
|
||||
|
@ -4015,9 +4015,7 @@ const JSClassOps DebuggerInstanceObject::classOps_ = {
|
||||
};
|
||||
|
||||
const JSClass DebuggerInstanceObject::class_ = {
|
||||
"Debugger",
|
||||
JSCLASS_HAS_PRIVATE |
|
||||
JSCLASS_HAS_RESERVED_SLOTS(Debugger::JSSLOT_DEBUG_COUNT),
|
||||
"Debugger", JSCLASS_HAS_RESERVED_SLOTS(Debugger::JSSLOT_DEBUG_COUNT),
|
||||
&classOps_};
|
||||
|
||||
static Debugger* Debugger_fromThisValue(JSContext* cx, const CallArgs& args,
|
||||
@ -4635,7 +4633,7 @@ bool Debugger::construct(JSContext* cx, unsigned argc, Value* vp) {
|
||||
|
||||
// The object owns the released pointer.
|
||||
debugger = dbg.release();
|
||||
InitObjectPrivate(obj, debugger, MemoryUse::Debugger);
|
||||
InitReservedSlot(obj, JSSLOT_DEBUG_DEBUGGER, debugger, MemoryUse::Debugger);
|
||||
}
|
||||
|
||||
// Add the initial debuggees, if any.
|
||||
|
@ -541,6 +541,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
HookCount
|
||||
};
|
||||
enum {
|
||||
JSSLOT_DEBUG_DEBUGGER,
|
||||
JSSLOT_DEBUG_PROTO_START,
|
||||
JSSLOT_DEBUG_FRAME_PROTO = JSSLOT_DEBUG_PROTO_START,
|
||||
JSSLOT_DEBUG_ENV_PROTO,
|
||||
|
@ -1179,6 +1179,12 @@ class NativeObject : public JSObject {
|
||||
fixedSlots()[slot].init(this, HeapSlot::Slot, slot, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* maybePtrFromReservedSlot(uint32_t slot) const {
|
||||
Value v = getReservedSlot(slot);
|
||||
return v.isUndefined() ? nullptr : static_cast<T*>(v.toPrivate());
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the number of dynamic slots to allocate to cover the properties
|
||||
* in an object with the given number of fixed slots and slot span.
|
||||
|
Loading…
Reference in New Issue
Block a user