QuickBEAM.VM.Heap (QuickBEAM v0.10.9)

Copy Markdown View Source

Mutable heap storage for JS runtime values.

All heap access goes through this module — callers never touch the process dictionary directly. Current implementation uses the process dictionary for single-process performance; the backing store can be swapped to ETS for concurrent access.

Storage keys

  • integer_id — JS object/array properties (raw integer keys)
  • {:qb_cell, ref} — closure variable cells
  • {:qb_class_proto, ctor} — class prototype objects
  • {:qb_parent_ctor, ctor} — parent constructor references
  • {:qb_var, name} — global variable bindings

Summary

Functions

Runs heap garbage collection using the active VM roots plus extra roots.

Returns the allocation threshold that triggers the first heap GC pass.

Returns an object's prototype, falling back to the cached Array prototype for array values.

Reads a closure/capture cell value.

Returns the active interpreter context stored in the process dictionary.

Returns heap object data, reconstructing shaped objects as maps.

Returns an existing constructor prototype or lazily creates one for function constructors.

Creates a JavaScript Error-like object with message, name, prototype, and stack metadata.

Returns a heap object as a list when it stores array-like data.

Stores builtin-name metadata.

Stores the eval restore stack for the current process.

Caches the atom table for a VM function.

Stores cached global bindings and invalidates derived base globals.

Stores host-provided handler globals and invalidates derived base globals.

Stores the parent constructor associated with a class constructor.

Registers a compiled module and its exports in the process-local registry.

Clear all heap state. Used in test setup.

Converts JavaScript array-like VM values to Elixir lists.

Wraps maps, lists, arrays, and scalar data in a JavaScript object reference.

Wraps a list as a JavaScript iterator object with a next method.

Fast-wraps a value tuple with a compile-time key tuple, using a cached shape when possible.

Fast allocation with a pre-resolved shape. Skips eligibility check and key sorting.

Functions

all_module_exports()

See QuickBEAM.VM.Heap.Registry.all_module_exports/0.

array_get(ref, idx)

See QuickBEAM.VM.Heap.Store.array_get/2.

array_push(ref, values)

See QuickBEAM.VM.Heap.Store.array_push/2.

array_set(ref, idx, value)

See QuickBEAM.VM.Heap.Store.array_set/3.

array_size(ref)

See QuickBEAM.VM.Heap.Store.array_size/1.

delete_array_prop(ref, key)

See QuickBEAM.VM.Heap.Store.delete_array_prop/2.

delete_parent_ctor(ctor)

See QuickBEAM.VM.Heap.Store.delete_parent_ctor/1.

delete_promise_waiters(ref)

See QuickBEAM.VM.Heap.Async.delete_promise_waiters/1.

delete_var(name)

See QuickBEAM.VM.Heap.Store.delete_var/1.

dequeue_microtask()

See QuickBEAM.VM.Heap.Async.dequeue_microtask/0.

enqueue_microtask(task)

See QuickBEAM.VM.Heap.Async.enqueue_microtask/1.

extensible?(ref)

See QuickBEAM.VM.Heap.Store.extensible?/1.

freeze(ref)

See QuickBEAM.VM.Heap.Store.freeze/1.

frozen?(ref)

See QuickBEAM.VM.Heap.Store.frozen?/1.

gc(extra_roots \\ [])

Runs heap garbage collection using the active VM roots plus extra roots.

gc_initial_threshold()

Returns the allocation threshold that triggers the first heap GC pass.

gc_needed?()

See QuickBEAM.VM.Heap.GC.gc_needed?/0.

get_array_prop(ref, key)

See QuickBEAM.VM.Heap.Store.get_array_prop/2.

get_array_props(ref)

See QuickBEAM.VM.Heap.Store.get_array_props/1.

get_array_proto()

See QuickBEAM.VM.Heap.Caches.get_array_proto/0.

get_array_proto(ref)

Returns an object's prototype, falling back to the cached Array prototype for array values.

get_atoms()

See QuickBEAM.VM.Heap.Context.get_atoms/0.

get_base_globals()

See QuickBEAM.VM.Heap.Context.get_base_globals/0.

get_builtin_names()

See QuickBEAM.VM.Heap.Caches.get_builtin_names/0.

get_capture_keys(function_or_key)

See QuickBEAM.VM.Heap.Caches.get_capture_keys/1.

get_cell(ref)

Reads a closure/capture cell value.

get_class_proto(ctor)

See QuickBEAM.VM.Heap.Store.get_class_proto/1.

get_compiled(key)

See QuickBEAM.VM.Heap.Caches.get_compiled/1.

get_ctor_statics(ctor)

See QuickBEAM.VM.Heap.Store.get_ctor_statics/1.

get_ctx()

Returns the active interpreter context stored in the process dictionary.

get_eval_restore_stack()

See QuickBEAM.VM.Heap.Caches.get_eval_restore_stack/0.

get_fn_atoms(function_or_key)

See QuickBEAM.VM.Heap.Caches.get_fn_atoms/1.

get_fn_atoms(function_or_key, default)

See QuickBEAM.VM.Heap.Caches.get_fn_atoms/2.

get_func_proto()

See QuickBEAM.VM.Heap.Caches.get_func_proto/0.

get_global_cache()

See QuickBEAM.VM.Heap.Context.get_global_cache/0.

get_handler_globals()

See QuickBEAM.VM.Heap.Context.get_handler_globals/0.

get_invoke_depth()

See QuickBEAM.VM.Heap.Caches.get_invoke_depth/0.

get_module(name)

See QuickBEAM.VM.Heap.Registry.get_module/1.

get_obj(ref)

Returns heap object data, reconstructing shaped objects as maps.

get_obj(ref, default)

See QuickBEAM.VM.Heap.Store.get_obj/2.

get_obj_raw(ref)

See QuickBEAM.VM.Heap.Store.get_obj_raw/1.

get_object_prototype()

See QuickBEAM.VM.Heap.Context.get_object_prototype/0.

get_or_create_prototype(ctor)

Returns an existing constructor prototype or lazily creates one for function constructors.

get_parent_ctor(ctor)

See QuickBEAM.VM.Heap.Store.get_parent_ctor/1.

get_persistent_globals()

See QuickBEAM.VM.Heap.Context.get_persistent_globals/0.

get_promise_waiters(ref)

See QuickBEAM.VM.Heap.Async.get_promise_waiters/1.

get_prop_desc(ref, key)

See QuickBEAM.VM.Heap.Store.get_prop_desc/2.

get_regexp_result(ref)

See QuickBEAM.VM.Heap.Caches.get_regexp_result/1.

get_runtime_mode(runtime)

See QuickBEAM.VM.Heap.Context.get_runtime_mode/1.

get_string_codepoints(s)

See QuickBEAM.VM.Heap.Caches.get_string_codepoints/1.

get_symbol(key)

See QuickBEAM.VM.Heap.Registry.get_symbol/1.

make_error(message, name)

Creates a JavaScript Error-like object with message, name, prototype, and stack metadata.

mark_and_sweep(roots)

See QuickBEAM.VM.Heap.GC.mark_and_sweep/1.

microtasks_empty?()

See QuickBEAM.VM.Heap.Async.microtasks_empty?/0.

obj_to_list(ref)

Returns a heap object as a list when it stores array-like data.

prevent_extensions(ref)

See QuickBEAM.VM.Heap.Store.prevent_extensions/1.

put_array_prop(ref, key, val)

See QuickBEAM.VM.Heap.Store.put_array_prop/3.

put_array_proto(proto)

See QuickBEAM.VM.Heap.Caches.put_array_proto/1.

put_atoms(atoms)

See QuickBEAM.VM.Heap.Context.put_atoms/1.

put_base_globals(globals)

See QuickBEAM.VM.Heap.Context.put_base_globals/1.

put_builtin_names(names)

Stores builtin-name metadata.

put_capture_keys(function_or_key, tuple)

See QuickBEAM.VM.Heap.Caches.put_capture_keys/2.

put_cell(ref, value)

See QuickBEAM.VM.Heap.Store.put_cell/2.

put_class_proto(ctor, proto)

See QuickBEAM.VM.Heap.Store.put_class_proto/2.

put_compiled(key, compiled)

See QuickBEAM.VM.Heap.Caches.put_compiled/2.

put_ctor_static(ctor, key, value)

See QuickBEAM.VM.Heap.Store.put_ctor_static/3.

put_ctor_statics(ctor, statics)

See QuickBEAM.VM.Heap.Store.put_ctor_statics/2.

put_ctx(ctx)

See QuickBEAM.VM.Heap.Context.put_ctx/1.

put_eval_restore_stack(stack)

Stores the eval restore stack for the current process.

put_fn_atoms(function_or_key, atoms)

Caches the atom table for a VM function.

put_func_proto(proto)

See QuickBEAM.VM.Heap.Caches.put_func_proto/1.

put_global_cache(bindings)

Stores cached global bindings and invalidates derived base globals.

put_handler_globals(globals)

Stores host-provided handler globals and invalidates derived base globals.

put_invoke_depth(depth)

See QuickBEAM.VM.Heap.Caches.put_invoke_depth/1.

put_obj(ref, value)

See QuickBEAM.VM.Heap.Store.put_obj/2.

put_obj_key(ref, key, value)

See QuickBEAM.VM.Heap.Store.put_obj_key/3.

put_obj_key(ref, map, key, value)

See QuickBEAM.VM.Heap.Store.put_obj_key/4.

put_obj_raw(ref, value)

See QuickBEAM.VM.Heap.Store.put_obj_raw/2.

put_object_prototype(proto)

See QuickBEAM.VM.Heap.Context.put_object_prototype/1.

put_parent_ctor(ctor, parent)

Stores the parent constructor associated with a class constructor.

put_persistent_globals(globals)

See QuickBEAM.VM.Heap.Context.put_persistent_globals/1.

put_promise_waiters(ref, waiters)

See QuickBEAM.VM.Heap.Async.put_promise_waiters/2.

put_prop_desc(ref, key, desc)

See QuickBEAM.VM.Heap.Store.put_prop_desc/3.

put_regexp_result(ref, result)

See QuickBEAM.VM.Heap.Caches.put_regexp_result/2.

put_runtime_mode(runtime, mode)

See QuickBEAM.VM.Heap.Context.put_runtime_mode/2.

put_string_codepoints(s, chars)

See QuickBEAM.VM.Heap.Caches.put_string_codepoints/2.

put_symbol(key, sym)

See QuickBEAM.VM.Heap.Registry.put_symbol/2.

put_var(name, value)

See QuickBEAM.VM.Heap.Store.put_var/2.

register_module(name, exports)

Registers a compiled module and its exports in the process-local registry.

reset()

Clear all heap state. Used in test setup.

to_list(arr)

Converts JavaScript array-like VM values to Elixir lists.

update_obj(ref, default, fun)

See QuickBEAM.VM.Heap.Store.update_obj/3.

wrap(data)

Wraps maps, lists, arrays, and scalar data in a JavaScript object reference.

wrap_iterator(list)

Wraps a list as a JavaScript iterator object with a next method.

wrap_keyed(keys, vals)

Fast-wraps a value tuple with a compile-time key tuple, using a cached shape when possible.

wrap_shaped(shape_id, offsets, vals, proto)

Fast allocation with a pre-resolved shape. Skips eligibility check and key sorting.