Abstraction around a SpiderMonkey JSContext.
More...
#include <ScriptContext.h>
Abstraction around a SpiderMonkey JSContext.
A single ScriptContext, with the associated context, should only be used on a single thread.
(One means to share data between threads and contexts is to create a Script::StructuredClone.)
◆ ScriptContext()
ScriptContext::ScriptContext |
( |
int |
contextSize, |
|
|
int |
heapGrowthBytesGCTrigger |
|
) |
| |
◆ ~ScriptContext()
ScriptContext::~ScriptContext |
( |
| ) |
|
◆ CreateContext()
Returns a context, in which any number of ScriptInterfaces compartments can live.
Each context should only ever be used on a single thread.
- Parameters
-
parentContext | Parent context from the parent thread, with which we share some thread-safe data |
contextSize | Maximum size in bytes of the new context |
heapGrowthBytesGCTrigger | Size in bytes of cumulated allocations after which a GC will be triggered |
◆ GetGeneralJSContext()
JSContext * ScriptContext::GetGeneralJSContext |
( |
| ) |
const |
|
inline |
GetGeneralJSContext returns the context without starting a GC request and without entering any compartment.
It should only be used in specific situations, such as creating a new compartment, or when initializing a persistent rooted. If you need the compartmented context of a ScriptInterface, you should create a ScriptRequest and use the context from that.
◆ MaybeIncrementalGC()
void ScriptContext::MaybeIncrementalGC |
( |
double |
delay | ) |
|
MaybeIncrementalGC tries to determine whether a context-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.
◆ PrepareZonesForIncrementalGC()
void ScriptContext::PrepareZonesForIncrementalGC |
( |
| ) |
const |
|
private |
◆ RegisterRealm()
void ScriptContext::RegisterRealm |
( |
JS::Realm * |
realm | ) |
|
This is used to keep track of realms which should be prepared for a GC.
◆ RunJobs()
void ScriptContext::RunJobs |
( |
| ) |
|
Runs the promise continuation.
On contexts where promises can be used this function has to be called. This function has to be called frequently.
◆ ShrinkingGC()
void ScriptContext::ShrinkingGC |
( |
| ) |
|
◆ UnRegisterRealm()
void ScriptContext::UnRegisterRealm |
( |
JS::Realm * |
realm | ) |
|
◆ m_ContextSize
int ScriptContext::m_ContextSize |
|
private |
◆ m_cx
JSContext* ScriptContext::m_cx |
|
private |
◆ m_HeapGrowthBytesGCTrigger
int ScriptContext::m_HeapGrowthBytesGCTrigger |
|
private |
◆ m_JobQueue
◆ m_LastGCBytes
int ScriptContext::m_LastGCBytes {0} |
|
private |
◆ m_LastGCCheck
double ScriptContext::m_LastGCCheck {0.0} |
|
private |
◆ m_Realms
std::list<JS::Realm*> ScriptContext::m_Realms |
|
private |
The documentation for this class was generated from the following files:
- /home/docker/jenkins/workspace/technical-docs/source/scriptinterface/ScriptContext.h
- /home/docker/jenkins/workspace/technical-docs/source/scriptinterface/ScriptContext.cpp