RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.2, Nov 26, 2026 ·

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
    • Virtual Machine (VM)
    • Bytecode Compilation
    • Interpreter Dispatch & Execution Loop
    • Indexing Subsystem
    • Callable Resolution & Function Dispatch
    • JIT Compiler
    • JIT Pipeline
    • Memory Management
Docs>Runtime>Execution Engines

Indexing Subsystem

The VM indexing subsystem executes MATLAB-style indexing after the compiler has already classified the operation. It handles scalar access, multidimensional slicing, end expressions, cell arrays, structure arrays, logical arrays, strings, GPU tensors, and object subsref/subsasgn dispatch.

The key design point is that indexing intent is made explicit before runtime. MIR carries a MirIndexPlan, the VM compiler emits a matching bytecode instruction, and the interpreter builds concrete selector plans only from the runtime shape and values it actually needs.

Planning Model

Indexing begins in the compiler pipeline, where HIR and MIR identify whether an operation is a scalar index, a slice, a slice expression involving end, or cell indexing. The VM compiler lowers those plans to indexing instructions in Instr.

Loading diagram...

Plan Categories

CategoryRuntime MeaningRepresentative Instructions
ScalarDirect element access with numeric scalar selectors.Index, StoreIndex
SliceColon, vector, logical, or range-based access without dynamic end expressions.IndexSlice, StoreSlice
SliceExprSlice access whose selectors require runtime EndExpr evaluation.IndexSliceExpr, StoreSliceExpr
CellCell container or cell contents access.IndexCell, StoreCellIndex, cell-specific slice paths
Structure arrayTyped structure-element selection, growth, replacement, and whole-element deletion.Shared slice/index instructions routed through the runtime structure-array planner
MemberDot/member access and object protocols.IndexMember, object descriptors

The stack contract is part of the bytecode ABI. Read instructions pop their base value and selectors, then push the selected value. Write instructions also pop the right-hand side and then push the updated base value; a later store instruction commits that value back to the variable or local slot.

end Expressions

The compiler represents end and expressions derived from it as EndExpr. The interpreter resolves these expressions after it knows the selected base shape and dimension. EndExpr supports constants, local variables, arithmetic, rounding functions, and resolved calls used by end-expression semantics.

Loading diagram...

VM Execution Flow

At runtime, indexing::dispatch_indexing consumes the instruction and its stack operands, normalizes selectors, builds an IndexPlan when needed, and routes the operation to the correct value-specific implementation.

Loading diagram...

Read Operations

Read paths support tensors, complex tensors, GPU tensors, string arrays, cells, structure arrays, logical arrays, objects, and simple scalar fallback through runtime indexing. Logical arrays are temporarily mapped to numeric tensors for slice planning, then converted back to logical results where appropriate. Structure-array reads use the same IndexPlan as other arrays, including linear indexing and trailing-dimension collapse when fewer subscripts are supplied.

Function handles can also be invoked through paren indexing syntax when the selector form is call-like. Colon and end selectors are rejected for that path because they are indexing syntax, not function-call arguments.

Write Operations

Write paths use the same selector planning but route to assignment or deletion helpers. Tensor, complex tensor, GPU tensor, string array, cell, and structure-array writes each have specialized scatter behavior. Structure-array whole-element assignment requires matching ordered fields; member growth fills other fields with empty values. Deletion is explicit in the bytecode through StoreSliceDelete or StoreSliceExprDelete.

Cell Expansion

Brace indexing can produce comma-separated-list behavior. Shared call helpers such as expand_brace_values are used by call expansion instructions so that cell contents can be consumed by the enclosing output or argument context. The sequence is transient execution state, not a user-visible value that can be stored in another cell.

Structure Member Sequences

Dot access on a structure array reads the selected field values in visible column-major structure-element order. MIR records the consuming context explicitly: an ordinary expression requires one value, a bracketed output list selects a fixed prefix, a call argument expands all values, and a suppressed expression discards them after evaluation. A nonscalar sequence used where one value is required is an error rather than an implicit choice of the first element.

A bracketed structure-member destination has runtime cardinality. Its base, selectors, and dynamic field name are evaluated left to right and exactly once before the right-hand side. The prepared destination supplies the requested output count; after the right-hand side produces exactly that many values, the store distributes them in structure-element order and writes the updated root back through the prepared indexing/member chain.

The prepared destination and produced values have a deliberately short lifetime. Bytecode keeps the prepared destination on its execution stack and the typed sequence in a transient register; native execution retains both in a rooted prepared-assignment record. In each executor, validation requires the producer and matching member-sequence consumer to be adjacent and forbids the state from crossing an unrelated instruction, control-flow edge, or function boundary. Errors consume or clear the transient state before execution continues.

Object Indexing

When the base is an object or handle object, the VM does not treat indexing as a native tensor or cell operation. Instead, it builds an ObjectIndexDescriptor and dispatches through the relevant MATLAB object protocol:

  • subsref for reads.
  • subsasgn for writes.
  • Member indexing for dot access.

Missing overloads are normalized into stable errors before falling back to native paths.

Error Boundaries

The indexing layer intentionally separates compile-time plan validation from runtime value validation. Malformed MIR plans fail during bytecode compilation with MIR-specific identifiers such as RunMat:MirSliceIndexPlanInvalid. Runtime selector and shape failures are normalized in the interpreter as indexing errors such as invalid selector plans, unsupported selector syntax, shape mismatch, or unsupported base values.

Some MATLAB behaviors are intentionally explicit at these boundaries. Cell brace deletion is rejected through a dedicated unsupported-cell deletion error, and string slice deletion is currently unsupported. GPU slice reads prefer provider-side gather operations but may fall back through host materialization when a direct GPU plan cannot be used.

On this page
  • Planning Model
  • Plan Categories
  • end Expressions
  • VM Execution Flow
  • Read Operations
  • Write Operations
  • Cell Expansion
  • Structure Member Sequences
  • Object Indexing
  • Error Boundaries