QuickBEAM.VM.Interpreter (QuickBEAM v0.10.9)

Copy Markdown View Source

Executes decoded QuickJS bytecode via multi-clause function dispatch.

The interpreter pre-decodes bytecode into instruction tuples for O(1) indexed access, then runs a tail-recursive dispatch loop with one defp run/5 clause per opcode family.

JS value representation

  • number: Elixir integer or float
  • string: Elixir binary
  • boolean: true / false
  • null: nil
  • undefined: :undefined
  • object: {:obj, reference()}
  • function: %QuickBEAM.VM.Function{} | {:closure, map(), %QuickBEAM.VM.Function{}}

  • symbol: {:symbol, desc} | {:symbol, desc, ref}

  • bigint: {:bigint, integer()}

Summary

Functions

Evaluates bytecode in the interpreter.

Invoke a VM function or closure from external code.

Invokes a callback function from built-in code (e.g. Array.prototype.map).

Invokes a closure through the interpreter fallback path.

Invokes a VM function through the interpreter fallback path.

Invokes a JS function with a specific this receiver.

Resolves an awaited value for async interpreter execution.

Runs a bytecode frame — entry point for external callers.

Functions

eval(fun)

@spec eval(QuickBEAM.VM.Function.t()) :: {:ok, term()} | {:error, term()}

Evaluates bytecode in the interpreter.

eval(fun, args, opts)

@spec eval(QuickBEAM.VM.Function.t(), [term()], map()) ::
  {:ok, term()} | {:error, term()}

eval(fun, args, opts, atoms)

@spec eval(QuickBEAM.VM.Function.t(), [term()], map(), tuple()) ::
  {:ok, term()} | {:error, term()}

invoke(fun, args, gas)

Invoke a VM function or closure from external code.

invoke_callback(fun, args)

Invokes a callback function from built-in code (e.g. Array.prototype.map).

invoke_closure_fallback(closure, args, gas, ctx)

Invokes a closure through the interpreter fallback path.

invoke_constructor(fun, args, gas, this_obj, new_target)

invoke_function_fallback(fun, args, gas, ctx)

Invokes a VM function through the interpreter fallback path.

invoke_with_receiver(fun, args, gas, this_obj)

Invokes a JS function with a specific this receiver.

resolve_awaited(obj)

Resolves an awaited value for async interpreter execution.

run_frame(frame, stack, gas, ctx)

Runs a bytecode frame — entry point for external callers.

run_frame(pc, frame, stack, gas, ctx)