Abstraction around a SpiderMonkey JSRuntime.
More...
#include <ScriptRuntime.h>
|
static void | GCCallback (JSRuntime *rt, JSGCStatus status, void *data) |
|
Abstraction around a SpiderMonkey JSRuntime.
Each ScriptRuntime can be used to initialize several ScriptInterface contexts which can then share data, but a single ScriptRuntime should only be used on a single thread.
(One means to share data between threads and runtimes is to create a ScriptInterface::StructuredClone.)
ScriptRuntime::ScriptRuntime |
( |
shared_ptr< ScriptRuntime > |
parentRuntime, |
|
|
int |
runtimeSize, |
|
|
int |
heapGrowthBytesGCTrigger |
|
) |
| |
ScriptRuntime::~ScriptRuntime |
( |
| ) |
|
void ScriptRuntime::AddDeferredFinalizationObject |
( |
const std::shared_ptr< void > & |
obj | ) |
|
Registers an object to be freed/finalized by the ScriptRuntime.
Freeing is guaranteed to happen after the next minor GC has completed, but might also happen a bit later. This is only needed in very special situations and you should only use it if you know exactly why you need it! Specify a deleter for the shared_ptr to free the void pointer correctly (by casting to the right type before calling delete for example).
void ScriptRuntime::GCCallback |
( |
JSRuntime * |
rt, |
|
|
JSGCStatus |
status, |
|
|
void * |
data |
|
) |
| |
|
staticprivate |
void ScriptRuntime::GCCallbackMember |
( |
| ) |
|
|
private |
void ScriptRuntime::MaybeIncrementalGC |
( |
double |
delay | ) |
|
MaybeIncrementalRuntimeGC tries to determine whether a runtime-wide garbage collection would free up enough memory to be worth the amount of time it would take.
It does this with our own logic and NOT some predefined JSAPI logic because such functionality currently isn't available out of the box. It does incremental GC which means it will collect one slice each time it's called until the garbage collection is done. This can and should be called quite regularly. The delay parameter allows you to specify a minimum time since the last GC in seconds (the delay should be a fraction of a second in most cases though). It will only start a new incremental GC or another GC slice if this time is exceeded. The user of this function is responsible for ensuring that GC can run with a small enough delay to get done with the work.
void ScriptRuntime::PrepareContextsForIncrementalGC |
( |
| ) |
|
|
private |
void ScriptRuntime::RegisterContext |
( |
JSContext * |
cx | ) |
|
void ScriptRuntime::ShrinkingGC |
( |
| ) |
|
void ScriptRuntime::UnRegisterContext |
( |
JSContext * |
cx | ) |
|
std::list<JSContext*> ScriptRuntime::m_Contexts |
|
private |
std::vector<std::shared_ptr<void> > ScriptRuntime::m_FinalizationListObjectIdCache |
|
private |
int ScriptRuntime::m_HeapGrowthBytesGCTrigger |
|
private |
int ScriptRuntime::m_LastGCBytes |
|
private |
double ScriptRuntime::m_LastGCCheck |
|
private |
JSRuntime* ScriptRuntime::m_rt |
int ScriptRuntime::m_RuntimeSize |
|
private |
The documentation for this class was generated from the following files: