Skip to content

engine: vector operations and ALLOCATE AVAILABLE are interpreter-only, not in VM #355

Closed

Description

@bpowers

Problem

The vector operations (VECTOR SELECT, VECTOR ELM MAP, VECTOR SORT ORDER) and ALLOCATE AVAILABLE are implemented only in the interpreter code path, not in the VM bytecode compiler/executor. This means:

  • The VM cannot execute models that use any of these builtins.
  • Three integration tests (simulates_vector_simple_mdl, simulates_allocate_mdl, simulates_allocate_xmile) rely on interpreter-only code paths.
  • As the VM becomes the primary execution engine, models using these builtins would either fail or silently fall back to the interpreter.

The interpreter implementations are in src/simlin-engine/src/interpreter.rs (VECTOR SELECT around line 500, VECTOR ELM MAP around line 512, VECTOR SORT ORDER around line 528, ALLOCATE AVAILABLE around line 550). There are no corresponding bytecode opcodes or VM dispatch handlers for these operations.

Why it matters

  • Correctness: If the VM becomes the default execution path, models using these functions will fail to compile or execute.
  • Maintainability: Having builtins that only work in one of two execution backends creates a hidden compatibility gap that can surprise users and developers.
  • Test coverage: The passing tests give a false sense of completeness since they only exercise the interpreter path.

Component(s) affected

  • src/simlin-engine/src/interpreter.rs (current implementations)
  • src/simlin-engine/src/compiler/ (would need bytecode emission)
  • src/simlin-engine/src/bytecode.rs (would need new opcodes)
  • src/simlin-engine/src/vm.rs (would need dispatch handlers)

Possible approaches

  1. Add bytecode opcodes for each vector operation and ALLOCATE AVAILABLE, with corresponding compiler emission and VM dispatch.
  2. Implement these as VM "extern calls" that invoke the interpreter logic from within the VM, avoiding full bytecode encoding of complex multi-array operations.
  3. If these are rare/niche builtins, document the interpreter-only limitation explicitly and gate the tests accordingly.

Context

Identified during review of the MDL full-compat work on branch mdl-full-compat.

Activity

  1. bpowers commented on Mar 8, 2026

    @bpowers
    OwnerAuthor

    Fixed in commit 614aa09 (PR #361) — VectorSelect, VectorElmMap, VectorSortOrder, and AllocateAvailable all implemented as VM opcodes with full test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions