Hasty Briefsbeta

Bilingual

Rust-like compiler pipeline to resolve Matlab language semantics

2 days ago
  • #MATLAB runtime
  • #semantic resolution
  • #compiler pipeline
  • RunMat is a Rust runtime and compiler designed to execute MATLAB-family code, preserving original semantics for real-world engineering programs.
  • MATLAB's compact syntax requires semantic resolution because the same surface syntax can mean multiple things depending on context (e.g., function calls vs. variable indexing).
  • RunMat uses a staged compiler pipeline: source → AST → semantic HIR → MIR → MIR analysis → VM layout + bytecode → runtime/providers to resolve language decisions explicitly.
  • Semantic HIR records MATLAB program meaning, including functions, classes, bindings, calls with output counts, and indexing contexts, separate from VM storage.
  • MIR provides lower-level control flow, places, and effects, enabling analysis for initialization, spawn safety, and fusion eligibility.
  • Analysis stores facts (e.g., assignment states, type hints) that feed execution, tooling, and acceleration without each component reinventing program models.
  • VM layout maps semantic bindings to frame slots, keeping language semantics independent of execution storage, similar to workspace variables in MATLAB.
  • Bytecode is compiled from MIR with semantic decisions already made, allowing the VM to focus on execution with minimal reinterpretation.
  • RunMat 0.5 introduces project manifests (runmat.toml) for source roots, dependencies, and entrypoints, enabling stable composition and multi-file project support.
  • Builtins are treated as runtime metadata with descriptors for signatures, behavior, and errors, aligning runtime, tooling, and documentation.
  • Classes (classdef) are fully supported, including properties, methods, and custom indexing (e.g., subsref), with semantic resolution for object construction and mutation.
  • Acceleration separates semantic eligibility from concrete residency, allowing providers to decide GPU execution based on runtime state while preserving MATLAB behavior.
  • A JIT path exists via Turbine and Cranelift but is incomplete; the interpreter remains primary, with future plans to expand JIT coverage using bytecode and semantic facts.