Files
cell/scripts/modules/js.js
John Alanbrook e86138ec00
Some checks failed
Build and Deploy / build-linux (push) Successful in 1m20s
Build and Deploy / build-windows (CLANG64) (push) Failing after 10m58s
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
multirheading mailboxes fixed
2025-03-11 20:34:39 -05:00

106 lines
3.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var js = this
js[prosperon.DOC] = `
Provides functions for introspecting and configuring the QuickJS runtime engine.
Includes debug info, memory usage, GC controls, code evaluation, etc.
`
js.rt_info[prosperon.DOC] = "Return internal QuickJS runtime info, such as object counts."
js.dump_shapes[prosperon.DOC] = `
:return: A debug string describing the internal shape hierarchy used by QuickJS.
Use this for internal debugging of object shapes.
`
js.dump_atoms[prosperon.DOC] = `
:return: A debug string listing all currently registered atoms (internal property keys/symbols)
known by QuickJS. Helpful for diagnosing memory usage or potential key collisions.
`
js.dump_class[prosperon.DOC] = `
:return: A debug string describing the distribution of JS object classes in the QuickJS runtime.
Shows how many objects of each class exist, useful for advanced memory or performance profiling.
`
js.dump_type_overheads[prosperon.DOC] = `
:return: A debug string describing the overheads for various JS object types in QuickJS.
Displays memory usage breakdown for different internal object types.
`
js.dump_objects[prosperon.DOC] = `
:return: A debug string listing certain internal QuickJS objects and their references,
useful for debugging memory leaks or object lifetimes.
`
js.stack_info[prosperon.DOC] = `
:return: An object or string describing the runtime's current stack usage and capacity.
Internal debugging utility to examine call stack details.
`
js.cycle_hook[prosperon.DOC] = `
:param callback: A function to call each time QuickJS completes a "cycle" (internal VM loop),
or undefined to remove the callback.
:return: None
Register or remove a hook function that QuickJS calls once per execution cycle. If the callback
is set, it receives a single argument (an optional object/value describing the cycle). If callback
is undefined, the hook is removed.
`
js.calc_mem[prosperon.DOC] = `
:param value: A JavaScript value to analyze.
:return: Approximate memory usage (in bytes) of that single value.
Compute the approximate size of a single JS value in memory. This is a best-effort estimate.
`
js.mem[prosperon.DOC] = `
:return: An object containing a comprehensive snapshot of memory usage for the current QuickJS runtime,
including total allocated bytes, object counts, and more.
Retrieve an overview of the runtimes memory usage.
`
js.mem_limit[prosperon.DOC] = `
:param bytes: The maximum memory (in bytes) QuickJS is allowed to use.
:return: None
Set the upper memory limit for the QuickJS runtime. Exceeding this limit may cause operations to
fail or throw errors.
`
js.gc_threshold[prosperon.DOC] = `
:param bytes: The threshold (in bytes) at which the engine triggers automatic garbage collection.
:return: None
Set the threshold (in bytes) for QuickJS to perform an automatic GC pass when memory usage surpasses it.
`
js.max_stacksize[prosperon.DOC] = `
:param bytes: The maximum allowed stack size (in bytes) for QuickJS.
:return: None
Set the maximum stack size for QuickJS. If exceeded, the runtime may throw a stack overflow error.
`
js.memstate[prosperon.DOC] = `
:return: A simpler memory usage object (malloc sizes, etc.) for the QuickJS runtime.
Gives a quick overview of the memory usage, including malloc size and other allocations.
`
js.gc[prosperon.DOC] = `
:return: None
Force an immediate, full garbage collection pass, reclaiming unreachable memory.
`
js.eval[prosperon.DOC] = `
:param src: A string of JavaScript source code to evaluate.
:param filename: (Optional) A string for the filename or label, used in debugging or stack traces.
:return: The result of evaluating the given source code.
Execute a string of JavaScript code in the current QuickJS context.
`
return js