Expand description
Runtime and context state: limits, GC, opaque pointers, context values, memory reporting
and JS_PrintValue.
§Which of these are real and which are “accepted and recorded”
A limit that the engine does not enforce must not pretend to. JS_SetMemoryLimit and
JS_SetMaxStackSize map onto Runtime::set_memory_limit/set_stack_size, which the
allocator and the call-depth check already consult — so those are real.
JS_SetGCThreshold maps onto the heap’s threshold, also real.
JS_SetInterruptHandler is real but only checked where the engine already yields
(docs/m15-plan.md §5: not between every opcode), and that limit is stated in the README.
JS_SetCanBlock, JS_SetStripInfo and JS_SetRuntimeInfo are recorded and have no
observable effect, which is stated at each one.
§Why the memory report is not a fabrication
JS_ComputeMemoryUsage fills a JSMemoryUsage whose fields a C program prints. Filling
them with plausible-looking zeros would be worse than filling the two that are actually
known: a host that logs malloc_size and sees 0 knows the number is unavailable, whereas
one that sees an invented 4096 believes it. So the live-box count and its bytes are real,
and the fields this engine cannot account for are zero with a comment naming which.
Functions§
- JS_
Compute ⚠Memory Usage JS_ComputeMemoryUsage: fillswith what this runtime occupies.- JS_
Dump ⚠Memory Usage JS_DumpMemoryUsage: print the report tofp.- JS_
DupContext ⚠ JS_DupContext: raise the context’s reference count and answer the same pointer.- JS_
GetContext ⚠Opaque JS_GetContextOpaque.- JS_
GetContext ⚠Value JS_GetContextValue: the value at slotidx, orundefined.- JS_
GetRuntime ⚠Opaque JS_GetRuntimeOpaque: the host’s pointer.- JS_
GetStrip ⚠Info JS_GetStripInfo: the value last given toJS_SetStripInfo.- JS_
HasException ⚠ JS_HasException: whether a call left an exception behind.- JS_
NewContext ⚠Raw JS_NewContextRaw: a context with no intrinsics installed.- JS_
NewRuntime2 ⚠ JS_NewRuntime2: a runtime with the host’s allocator.- JS_
Print ⚠Value JS_PrintValue: rendervalthroughwrite_func.- JS_
Print ⚠ValueRT JS_PrintValueRT: the same, found through a runtime rather than a context.- JS_
Print ⚠Value SetDefault Options JS_PrintValueSetDefaultOptions: the options a freshJSPrintValueOptionsshould hold.- JS_
RunGC ⚠ JS_RunGC: collect now.- JS_
SetCan ⚠Block JS_SetCanBlock: whether a blocking operation (a synchronousAtomics.wait) is allowed.- JS_
SetContext ⚠Opaque JS_SetContextOpaque.- JS_
SetContext ⚠Value JS_SetContextValue: store a value at one of the context’s private slots.- JS_
SetGC ⚠Threshold JS_SetGCThreshold: collect once the heap holdsthresholdbytes.- JS_
SetInterrupt ⚠Handler JS_SetInterruptHandler: callcbperiodically while a script runs.- JS_
SetMax ⚠Stack Size JS_SetMaxStackSize: cap the call depth,0to disable the check.- JS_
SetMemory ⚠Limit JS_SetMemoryLimit: refuse an allocation that would take the heap pastlimitbytes.- JS_
SetRuntime ⚠Info JS_SetRuntimeInfo: a label for diagnostics.- JS_
SetRuntime ⚠Opaque JS_SetRuntimeOpaque.- JS_
SetStrip ⚠Info JS_SetStripInfo: record how much debug info to keep.- JS_
Throw ⚠Internal Error JS_ThrowInternalError. SeeJS_ThrowSyntaxError.- JS_
Throw ⚠OutOf Memory JS_ThrowOutOfMemory: raise the engine’s out-of-memory error.- JS_
Throw ⚠Reference Error JS_ThrowReferenceError. SeeJS_ThrowSyntaxError.- JS_
Throw ⚠Syntax Error JS_ThrowSyntaxError,JS_ThrowTypeError,JS_ThrowReferenceError,JS_ThrowInternalError: the fourJS_Throw*spellings not already exported.- JS_
Throw ⚠Type Error JS_ThrowTypeError. SeeJS_ThrowSyntaxError.- JS_
Update ⚠Stack Top JS_UpdateStackTop: tell the engine where this thread’s stack starts.