WAM Roadmap

This document is a plan for evolving the Flowlog engine (flowlog.c) towards a fuller WAM/bytecode-style execution model without giving up Flowlog’s parallel OR/AND execution model.

Status note:

Goals

Constraints

Execution model (target shape)

The intended end-state is a bytecode VM with:

Built-ins remain “native” C functions, invoked via a fast dispatch from a call_builtin instruction.

OR-parallelism on WAM

Two viable approaches:

  1. Alternative-splitting at clause entry (coarse OR-par):
  2. Stack-copying choicepoint splitting (fine OR-par):

Flowlog’s flowlog_parallel_profile=fast (unordered) maps naturally to the second model (commit as soon as found). Ordered mode needs extra coordination to preserve classic answer order.

AND-parallelism on WAM

Flowlog’s conservative AND-par analysis can be preserved on WAM states:

Status: implemented in the WAM-lite engine as a conservative “safe prefix” scheduler:

Incremental milestones

Milestone 1: compiled clause skeleton

Status: implemented in the wamvm engine for clause bodies (CALL/PROCEED), with a conservative support check that falls back to wam when unsupported goals are used.

Milestone 2: expand WAM-lite for common pure code

Milestone 3: backtracking + multi-clause predicates

Status: implemented in wamvm via an explicit choicepoint stack (predicate-clause continuation, ;/2, repeat/0, catch/3, retract/1, and the select1/3 generator used by benchmarks). This is not yet a classic WAM try/retry/trust instruction stream.

Milestone 4: ISO integration and correctness

Milestone 5: OR-par on VM states

Testing strategy