mrdocs::js::Scope
A JavaScript scope for value lifetime management.
Description
Scope serves two purposes:
1. Value batch tracking: Tracks JavaScript values created within the scope and releases one reference to each when the scope ends. Values that were copied elsewhere (e.g., returned from functions, stored in containers) survive because they hold their own references. Values that remained local to the scope are freed.
2. Thread safety: Each Scope operation briefly locks the Context's mutex and activates the context (sets TLS). This allows multiple threads to share a Context while serializing access to the interpreter. Values obtained from a Scope can be used from other threads; they will acquire the lock as needed.
This provides deterministic cleanup similar to stack‐based engines (Lua, Duktape) while working with JerryScript's reference‐counted heap.
|
Multiple Scopes can exist for the same Context (even in different threads), but operations are serialized by the Context's mutex. |
Member Functions
Name |
Description |
|
Constructor. |
|
Destructor. |
Compile a script and push results to stack. |
|
Compile a script and push results to stack. |
|
Compile and run a expression. |
|
Return a global object if it exists. |
|
Return the global object. |
|
Push a new array to the stack |
|
Push a boolean to the stack |
|
Push a double to the stack |
|
Push an integer to the stack |
|
Push a new object to the stack |
|
Push a string to the stack |
|
Compile and run a script. |
|
Set a global object. |
Created with MrDocs