mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::js: Functions to get current zone; debug callbacks for zone; etc.
This commit is contained in:
parent
c70ddd5a80
commit
12c1755899
3 changed files with 55 additions and 13 deletions
|
@ -117,6 +117,8 @@ JSCompartment *current_compartment(context &);
|
|||
JSCompartment *current_compartment();
|
||||
JSObject *current_global(context &c);
|
||||
JSObject *current_global(); // thread_local
|
||||
JS::Zone *current_zone(context &);
|
||||
JS::Zone *current_zone();
|
||||
|
||||
// Memory
|
||||
void set(context &c, const JSGCParamKey &, const uint32_t &val);
|
||||
|
@ -183,6 +185,18 @@ pending_exception(const context &c)
|
|||
return JS_IsExceptionPending(c);
|
||||
}
|
||||
|
||||
inline JS::Zone *
|
||||
current_zone()
|
||||
{
|
||||
return current_zone(*cx);
|
||||
}
|
||||
|
||||
inline JS::Zone *
|
||||
current_zone(context &c)
|
||||
{
|
||||
return ::js::GetContextZone(c);
|
||||
}
|
||||
|
||||
inline JSObject *
|
||||
current_global()
|
||||
{
|
||||
|
@ -195,6 +209,18 @@ current_global(context &c)
|
|||
return JS::CurrentGlobalOrNull(c);
|
||||
}
|
||||
|
||||
inline JSCompartment *
|
||||
current_compartment()
|
||||
{
|
||||
return current_compartment(*cx);
|
||||
}
|
||||
|
||||
inline JSCompartment *
|
||||
current_compartment(context &c)
|
||||
{
|
||||
return ::js::GetContextCompartment(c);
|
||||
}
|
||||
|
||||
inline void
|
||||
priv(context &c,
|
||||
privdata *const &ptr)
|
||||
|
|
|
@ -34,6 +34,8 @@ class runtime
|
|||
static void handle_gc(JSRuntime *, JSGCStatus, void *) noexcept;
|
||||
static void handle_finalize(JSFreeOp *, JSFinalizeStatus, bool is_compartment, void *) noexcept;
|
||||
static void handle_telemetry(int id, uint32_t sample, const char *key) noexcept;
|
||||
static void handle_zone_sweep(JS::Zone *) noexcept;
|
||||
static void handle_zone_destroy(JS::Zone *) noexcept;
|
||||
static void handle_compartment_name(JSRuntime *, JSCompartment *, char *buf, size_t) noexcept;
|
||||
static void handle_compartment_destroy(JSFreeOp *, JSCompartment *) noexcept;
|
||||
static bool handle_context(JSContext *, uint op, void *) noexcept;
|
||||
|
|
40
ircd/js.cc
40
ircd/js.cc
|
@ -2216,18 +2216,6 @@ ircd::js::set(context &c,
|
|||
JS_SetGCParameter(c.runtime(), key, val);
|
||||
}
|
||||
|
||||
JSCompartment *
|
||||
ircd::js::current_compartment()
|
||||
{
|
||||
return current_compartment(*cx);
|
||||
}
|
||||
|
||||
JSCompartment *
|
||||
ircd::js::current_compartment(context &c)
|
||||
{
|
||||
return ::js::GetContextCompartment(c);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ircd/js/timer.h
|
||||
|
@ -2410,6 +2398,8 @@ ircd::js::runtime::runtime(const struct opts &opts,
|
|||
JS_SetGCCallback(get(), handle_gc, nullptr);
|
||||
JS_AddFinalizeCallback(get(), handle_finalize, nullptr);
|
||||
JS_SetAccumulateTelemetryCallback(get(), handle_telemetry);
|
||||
JS_SetSweepZoneCallback(get(), handle_zone_sweep);
|
||||
JS_SetDestroyZoneCallback(get(), handle_zone_destroy);
|
||||
JS_SetCompartmentNameCallback(get(), handle_compartment_name);
|
||||
JS_SetDestroyCompartmentCallback(get(), handle_compartment_destroy);
|
||||
JS_SetContextCallback(get(), handle_context, nullptr);
|
||||
|
@ -2504,9 +2494,11 @@ ircd::js::runtime::handle_compartment_destroy(JSFreeOp *const fop,
|
|||
JSCompartment *const compartment)
|
||||
noexcept
|
||||
{
|
||||
log.debug("runtime(%p): compartment(%p) destroy: fop(%p)",
|
||||
log.debug("runtime(%p): compartment: %p %s%sdestroy: fop(%p)",
|
||||
(const void *)(our_runtime(*fop).ptr()),
|
||||
(const void *)compartment,
|
||||
::js::IsSystemCompartment(compartment)? "[system] " : "",
|
||||
::js::IsAtomsCompartment(compartment)? "[atoms] " : "",
|
||||
(const void *)fop);
|
||||
}
|
||||
|
||||
|
@ -2524,6 +2516,28 @@ noexcept
|
|||
max);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::js::runtime::handle_zone_destroy(JS::Zone *const zone)
|
||||
noexcept
|
||||
{
|
||||
log.debug("runtime(%p): zone: %p %s%sdestroy",
|
||||
(const void *)rt,
|
||||
(const void *)zone,
|
||||
::js::IsSystemZone(zone)? "[system] " : "",
|
||||
::js::IsAtomsZone(zone)? "[atoms] " : "");
|
||||
}
|
||||
|
||||
void
|
||||
ircd::js::runtime::handle_zone_sweep(JS::Zone *const zone)
|
||||
noexcept
|
||||
{
|
||||
log.debug("runtime(%p): zone: %p %s%ssweep",
|
||||
(const void *)rt,
|
||||
(const void *)zone,
|
||||
::js::IsSystemZone(zone)? "[system] " : "",
|
||||
::js::IsAtomsZone(zone)? "[atoms] " : "");
|
||||
}
|
||||
|
||||
void
|
||||
ircd::js::runtime::handle_telemetry(const int id,
|
||||
const uint32_t sample,
|
||||
|
|
Loading…
Reference in a new issue