numbl 0.3.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +6 -5
- package/dist-cli/cli.js +63077 -42047
- package/dist-lib/graphics/types.d.ts +40 -1
- package/dist-lib/lib.d.ts +0 -1
- package/dist-lib/lib.js +78446 -57671
- package/dist-lib/numbl-core/executeCode.d.ts +10 -12
- package/dist-lib/numbl-core/executors/classification.d.ts +134 -0
- package/dist-lib/numbl-core/executors/handleInline.d.ts +42 -0
- package/dist-lib/numbl-core/executors/index.d.ts +0 -3
- package/dist-lib/numbl-core/executors/jit/cJitCallExecutor.d.ts +35 -0
- package/dist-lib/numbl-core/executors/jit/cJitLoopExecutor.d.ts +31 -0
- package/dist-lib/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +29 -0
- package/dist-lib/numbl-core/executors/jit/callExecutor.d.ts +45 -0
- package/dist-lib/numbl-core/executors/jit/compileC.d.ts +51 -0
- package/dist-lib/numbl-core/executors/jit/compileC.node.d.ts +25 -0
- package/dist-lib/numbl-core/executors/jit/hostHelpers.d.ts +27 -0
- package/dist-lib/numbl-core/executors/jit/loopExecutor.d.ts +41 -0
- package/dist-lib/numbl-core/executors/jit/session.d.ts +17 -0
- package/dist-lib/numbl-core/executors/jit/topLevelExecutor.d.ts +36 -0
- package/dist-lib/numbl-core/executors/jit/typeAdapter.d.ts +28 -0
- package/dist-lib/numbl-core/executors/jit/typeAdapterC.d.ts +73 -0
- package/dist-lib/numbl-core/executors/jit/valueAdapter.d.ts +48 -0
- package/dist-lib/numbl-core/executors/jit/valueAdapterC.d.ts +108 -0
- package/dist-lib/numbl-core/executors/lowering.d.ts +31 -77
- package/dist-lib/numbl-core/executors/plugins.d.ts +14 -21
- package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +4 -1
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +1 -1
- package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +0 -18
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +37 -21
- package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +6 -0
- package/dist-lib/numbl-core/interpreter/interpreterFunctions.d.ts +13 -1
- package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +1 -1
- package/dist-lib/numbl-core/jit/builtins/defs/_shared.d.ts +43 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +123 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/minus.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mpower.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mrdivide.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mtimes.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/plus.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/power.d.ts +30 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/rdivide.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/times.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/uminus.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/_compare.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/eq.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/ge.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/gt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/le.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/lt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/ne.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/diag/assert.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/_format_args.d.ts +17 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/disp.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/error.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/fprintf.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/sprintf.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/warning.d.ts +15 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/_shortcircuit.d.ts +30 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +30 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/and.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/andand.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/boolconst.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/classBuiltin.d.ts +21 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +15 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isa.d.ts +13 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/iscell.d.ts +8 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isempty.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isequal.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isfield.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isinf.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isnan.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isnumeric.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isreal.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isscalar.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isstruct.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/logical.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/not.d.ts +15 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/or.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/oror.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +21 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/typequery.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/xor.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/_complex_fold.d.ts +34 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +51 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/abs.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/angle.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/asinh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/atan.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/atan2.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/besselh.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/ceil.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/conj.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/constants.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/cos.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/cosh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/dot.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/double.d.ts +28 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/exp.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/fix.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/floor.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/hypot.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/imag.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/linspace.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/log.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/log10.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/log2.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/logspace.d.ts +8 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/mod.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/norm.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/real.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/rem.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/round.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sign.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sin.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sinh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sqrt.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/tan.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/tanh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/uniquetol.d.ts +22 -0
- package/dist-lib/numbl-core/jit/builtins/defs/plot/dispatch.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/_cumulative.d.ts +49 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +126 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/_variance.d.ts +17 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/all.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/any.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummax.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummin.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumprod.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumsum.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/diff.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/length.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/max.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/mean.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/min.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/numel.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/prod.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/std.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/sum.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/var.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/_construct.d.ts +67 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +34 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/cat.d.ts +33 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/diag.d.ts +29 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/eye.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/flip.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/meshgrid.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/ones.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/repmat.d.ts +37 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/reshape.d.ts +39 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/size.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/sort.d.ts +19 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/transpose.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/tril.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/triu.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/zeros.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/deal.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/feval.d.ts +36 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/pathBuiltins.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/tic.d.ts +8 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/toc.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/index.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/registry.d.ts +138 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/cell/cell.d.ts +24 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/loop_count.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/range_value.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/scalar_index.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/tensor_make_range.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/assert_fmt.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_complex.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_double.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_struct.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor_complex.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/error_fmt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/format_complex.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/format_double.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/format_engine.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/fprintf.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/sprintf.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/warning_fmt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/plot/plot_dispatch.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/snippets.gen.d.ts +86 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +103 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/deep_clone.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/isequal.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/tictoc.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_copy_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cat.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cumulative.d.ts +32 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diag.d.ts +33 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diff.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_dot.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_complex.d.ts +90 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real.d.ts +75 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +95 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_eye.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_nd.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_square.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_flip.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_linspace.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logical_real.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logspace.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_meshgrid.d.ts +29 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_complex.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_real.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_norm.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_square.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_predicate.d.ts +42 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_complex.d.ts +53 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +42 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_repmat.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_size.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_sort_real.d.ts +36 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_triangular.d.ts +22 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_complex_math.d.ts +128 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +95 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_uniquetol.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_var.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_square.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/text/strcmp.d.ts +2 -0
- package/dist-lib/numbl-core/jit/codegen/cFormat.d.ts +36 -0
- package/dist-lib/numbl-core/jit/codegen/cHelpers.d.ts +48 -0
- package/dist-lib/numbl-core/jit/codegen/emit.d.ts +55 -0
- package/dist-lib/numbl-core/jit/codegen/emitCellTypedef.d.ts +23 -0
- package/dist-lib/numbl-core/jit/codegen/emitExpr.d.ts +33 -0
- package/dist-lib/numbl-core/jit/codegen/emitIndex.d.ts +56 -0
- package/dist-lib/numbl-core/jit/codegen/emitJs.d.ts +64 -0
- package/dist-lib/numbl-core/jit/codegen/emitNamedTypedef.d.ts +58 -0
- package/dist-lib/numbl-core/jit/codegen/emitStmt.d.ts +76 -0
- package/dist-lib/numbl-core/jit/codegen/emitTensorConcat.d.ts +23 -0
- package/dist-lib/numbl-core/jit/codegen/emitTensorConcatJs.d.ts +16 -0
- package/dist-lib/numbl-core/jit/codegen/emitTensorFused.d.ts +77 -0
- package/dist-lib/numbl-core/jit/codegen/inlinePass.d.ts +66 -0
- package/dist-lib/numbl-core/jit/codegen/liveness.d.ts +58 -0
- package/dist-lib/numbl-core/jit/codegen/prettyIR.d.ts +24 -0
- package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +150 -0
- package/dist-lib/numbl-core/jit/compileSpec.d.ts +84 -0
- package/dist-lib/numbl-core/jit/compileSpecC.d.ts +93 -0
- package/dist-lib/numbl-core/jit/index.d.ts +15 -0
- package/dist-lib/numbl-core/jit/lowering/classDefs.d.ts +109 -0
- package/dist-lib/numbl-core/jit/lowering/errors.d.ts +35 -0
- package/dist-lib/numbl-core/jit/lowering/indexFold.d.ts +31 -0
- package/dist-lib/numbl-core/jit/lowering/indexResolve.d.ts +100 -0
- package/dist-lib/numbl-core/jit/lowering/ir.d.ts +584 -0
- package/dist-lib/numbl-core/jit/lowering/lower.d.ts +271 -0
- package/dist-lib/numbl-core/jit/lowering/lowerCellIndex.d.ts +41 -0
- package/dist-lib/numbl-core/jit/lowering/lowerCellLit.d.ts +19 -0
- package/dist-lib/numbl-core/jit/lowering/lowerClassConstructor.d.ts +55 -0
- package/dist-lib/numbl-core/jit/lowering/lowerFuncCall.d.ts +34 -0
- package/dist-lib/numbl-core/jit/lowering/lowerHandle.d.ts +57 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexLoad.d.ts +16 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexSlice.d.ts +29 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexSliceStore.d.ts +19 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexStore.d.ts +14 -0
- package/dist-lib/numbl-core/jit/lowering/lowerMethodCall.d.ts +45 -0
- package/dist-lib/numbl-core/jit/lowering/lowerMultiAssign.d.ts +36 -0
- package/dist-lib/numbl-core/jit/lowering/lowerTensorLit.d.ts +25 -0
- package/dist-lib/numbl-core/jit/lowering/rangeCount.d.ts +19 -0
- package/dist-lib/numbl-core/jit/lowering/specialize.d.ts +93 -0
- package/dist-lib/numbl-core/jit/lowering/types.d.ts +503 -0
- package/dist-lib/numbl-core/jit/lowering/walk.d.ts +17 -0
- package/dist-lib/numbl-core/jit/numbl/index.d.ts +30 -0
- package/dist-lib/numbl-core/jit/parser/astUtils.d.ts +43 -0
- package/dist-lib/numbl-core/jit/parser/index.d.ts +12 -0
- package/dist-lib/numbl-core/jit/parser/sourceLoc.d.ts +12 -0
- package/dist-lib/numbl-core/jit/runtime/context.d.ts +23 -0
- package/dist-lib/numbl-core/jit/runtime/inferType.d.ts +10 -0
- package/dist-lib/numbl-core/jit/runtime/value.d.ts +101 -0
- package/dist-lib/numbl-core/jit/workspace/driverPrologue.d.ts +59 -0
- package/dist-lib/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +62 -0
- package/dist-lib/numbl-core/jit/workspace/workspace.d.ts +243 -0
- package/dist-lib/numbl-core/jitTypes.d.ts +7 -321
- package/dist-lib/numbl-core/jsUserFunctions.d.ts +2 -2
- package/dist-lib/numbl-core/parser/ClassParser.d.ts +3 -0
- package/dist-lib/numbl-core/runtime/index.d.ts +1 -1
- package/dist-lib/numbl-core/runtime/indexing.d.ts +11 -1
- package/dist-lib/numbl-core/runtime/plotUtils.d.ts +28 -2
- package/dist-lib/numbl-core/runtime/runtime.d.ts +16 -1
- package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +5 -0
- package/dist-lib/numbl-core/runtime/types.d.ts +19 -3
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-lib/numbl-core/workspace/types.d.ts +8 -0
- package/dist-plot-viewer/assets/index-DfxsWeyf.js +4426 -0
- package/dist-plot-viewer/index.html +1 -1
- package/dist-site-viewer/404.html +33 -0
- package/dist-site-viewer/assets/index-C5c2lKAx.js +4748 -0
- package/dist-site-viewer/assets/index-D5YY8PKx.css +1 -0
- package/dist-site-viewer/assets/numbl-worker-CkoM4MUa.js +11836 -0
- package/dist-site-viewer/coi-serviceworker.js +70 -0
- package/dist-site-viewer/favicon.svg +23 -0
- package/dist-site-viewer/index.html +16 -0
- package/dist-site-viewer/logo.svg +26 -0
- package/dist-site-viewer/numbl-embed.js +111 -0
- package/dist-site-viewer/vite.svg +1 -0
- package/native/ops/real_unary_elemwise.c +3 -1
- package/package.json +15 -9
- package/dist-lib/numbl-core/executors/cJit/builtins.d.ts +0 -30
- package/dist-lib/numbl-core/executors/cJit/chainCodegen.d.ts +0 -59
- package/dist-lib/numbl-core/executors/cJit/chainExecutor.d.ts +0 -27
- package/dist-lib/numbl-core/executors/cJit/chainPass.d.ts +0 -42
- package/dist-lib/numbl-core/executors/cJit/codegen.d.ts +0 -44
- package/dist-lib/numbl-core/executors/cJit/compile.d.ts +0 -45
- package/dist-lib/numbl-core/executors/cJit/elemwiseCodegen.d.ts +0 -23
- package/dist-lib/numbl-core/executors/cJit/elemwiseStructural.d.ts +0 -33
- package/dist-lib/numbl-core/executors/cJit/fuseAnalyze.d.ts +0 -39
- package/dist-lib/numbl-core/executors/cJit/fuseCodegen.d.ts +0 -16
- package/dist-lib/numbl-core/executors/cJit/fuseExecutor.d.ts +0 -28
- package/dist-lib/numbl-core/executors/cJit/loopExecutor.d.ts +0 -32
- package/dist-lib/numbl-core/executors/cJit/register.d.ts +0 -10
- package/dist-lib/numbl-core/executors/cJit/whitelist.d.ts +0 -15
- package/dist-lib/numbl-core/executors/jsJit/callExecutor.d.ts +0 -25
- package/dist-lib/numbl-core/executors/jsJit/codegen/jitCodegen.d.ts +0 -7
- package/dist-lib/numbl-core/executors/jsJit/codegen/jitCodegenHoist.d.ts +0 -70
- package/dist-lib/numbl-core/executors/jsJit/codegen/jsMultiReduction.d.ts +0 -67
- package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpers.d.ts +0 -34
- package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersComplex.d.ts +0 -21
- package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersIndex.d.ts +0 -33
- package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersTensor.d.ts +0 -34
- package/dist-lib/numbl-core/executors/jsJit/jitCall.d.ts +0 -59
- package/dist-lib/numbl-core/executors/jsJit/jitLoop.d.ts +0 -53
- package/dist-lib/numbl-core/executors/jsJit/jitTopLevel.d.ts +0 -44
- package/dist-lib/numbl-core/executors/jsJit/loopExecutor.d.ts +0 -15
- package/dist-lib/numbl-core/executors/jsJit/lower/blockAnalysis.d.ts +0 -37
- package/dist-lib/numbl-core/executors/jsJit/lower/jitBailSafety.d.ts +0 -41
- package/dist-lib/numbl-core/executors/jsJit/lower/jitLower.d.ts +0 -136
- package/dist-lib/numbl-core/executors/jsJit/lower/jitLowerExpr.d.ts +0 -36
- package/dist-lib/numbl-core/executors/jsJit/lower/jitLowerStmt.d.ts +0 -9
- package/dist-lib/numbl-core/executors/jsJit/lower/jitLowerTypes.d.ts +0 -29
- package/dist-lib/numbl-core/executors/jsJit/lower/scalarEmit.d.ts +0 -58
- package/dist-lib/numbl-core/executors/jsJit/shared.d.ts +0 -120
- package/dist-lib/numbl-core/executors/jsJit/topLevelExecutor.d.ts +0 -17
- package/dist-plot-viewer/assets/index-COAM8o1E.js +0 -4426
- /package/dist-lib/numbl-core/{executors/jsJit/helpers → runtime}/alloc.d.ts +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type adapter for the mtoc2 C-JIT path.
|
|
3
|
+
*
|
|
4
|
+
* - `compilerTypeToCDecl(ty)` returns the C type string that goes in the
|
|
5
|
+
* koffi prototype for a value of that type, or `null` when the
|
|
6
|
+
* type isn't supported across the FFI today.
|
|
7
|
+
* - `registerTensorStruct(koffi)` registers `mtoc2_tensor_t`
|
|
8
|
+
* with koffi (idempotent across calls — koffi's `struct` returns
|
|
9
|
+
* the existing definition on re-registration of the same name).
|
|
10
|
+
* - `buildCDeclaration(signature)` assembles the full koffi prototype
|
|
11
|
+
* string from a `SpecCSignature`.
|
|
12
|
+
*
|
|
13
|
+
* Supported today:
|
|
14
|
+
* - Scalar real numeric → `double`
|
|
15
|
+
* - Scalar complex → `mtoc2_cscalar_t` (a `{double re; double im;}`
|
|
16
|
+
* koffi struct). The emitted C signature uses `double _Complex` by
|
|
17
|
+
* value, but on the SysV-x86-64 / AAPCS64 ABIs a 2-double struct
|
|
18
|
+
* and `double _Complex` share the same by-value calling convention
|
|
19
|
+
* (two SSE / SIMD registers, returned in xmm0:xmm1), so koffi
|
|
20
|
+
* marshals the struct against the real `_Complex` function — koffi's
|
|
21
|
+
* own prototype parser doesn't accept the `double _Complex` token.
|
|
22
|
+
* - Scalar logical → `double` (shares the `double` ABI)
|
|
23
|
+
* - Tensor (real or complex) → `mtoc2_tensor_t` (koffi struct)
|
|
24
|
+
* - Void return → `void`
|
|
25
|
+
*
|
|
26
|
+
* Everything else (Struct / Class / Handle / String / Char / Cell)
|
|
27
|
+
* returns null so the C-JIT executor declines and JS-JIT picks up.
|
|
28
|
+
*/
|
|
29
|
+
import type { SpecCSignature, Type } from "../../jit/index.js";
|
|
30
|
+
/** koffi's runtime-shaped api object. Loose typing because koffi
|
|
31
|
+
* doesn't ship TS types for its declaration-string API. */
|
|
32
|
+
interface Koffi {
|
|
33
|
+
struct(name: string, fields: Record<string, unknown>): any;
|
|
34
|
+
array(elemType: string, count: number, encoding?: string): any;
|
|
35
|
+
resolve(name: string): any | undefined;
|
|
36
|
+
}
|
|
37
|
+
/** Register the `mtoc2_tensor_t` struct with koffi. Idempotent — safe
|
|
38
|
+
* to call from each compile() invocation; the second call short-
|
|
39
|
+
* circuits.
|
|
40
|
+
*
|
|
41
|
+
* Layout MUST match `mtoc2/src/builtins/runtime/tensor/tensor.h`:
|
|
42
|
+
* ```
|
|
43
|
+
* typedef struct {
|
|
44
|
+
* double *real;
|
|
45
|
+
* double *imag;
|
|
46
|
+
* int ndim;
|
|
47
|
+
* long dims[JIT_MAX_NDIM]; // JIT_MAX_NDIM == 8
|
|
48
|
+
* } mtoc2_tensor_t;
|
|
49
|
+
* ```
|
|
50
|
+
* Field order and padding match the C struct's natural alignment;
|
|
51
|
+
* koffi handles the platform-specific alignment automatically when
|
|
52
|
+
* asked for the same field types.
|
|
53
|
+
*/
|
|
54
|
+
export declare const JIT_MAX_NDIM = 8;
|
|
55
|
+
export declare function registerTensorStruct(koffi: Koffi): void;
|
|
56
|
+
/** Register the `mtoc2_cscalar_t` struct — `{double re; double im;}` —
|
|
57
|
+
* used as the koffi stand-in for `double _Complex` scalar params and
|
|
58
|
+
* returns (ABI-compatible by-value; see header). Idempotent. */
|
|
59
|
+
export declare function registerCScalarStruct(koffi: Koffi): void;
|
|
60
|
+
/** Map an mtoc2 `Type` to the C-type token used in the koffi
|
|
61
|
+
* declaration string. Returns `null` for unsupported shapes. */
|
|
62
|
+
export declare function compilerTypeToCDecl(ty: Type): string | null;
|
|
63
|
+
/** Assemble the koffi prototype string for a `SpecCSignature`.
|
|
64
|
+
*
|
|
65
|
+
* Convention (mirrors mtoc2's `fnRetType` + `fnParamList`):
|
|
66
|
+
* - 0 outputs ⇒ `void <cName>(<params>)`
|
|
67
|
+
* - 1 output ⇒ `<retType> <cName>(<params>)`
|
|
68
|
+
* - ≥2 outputs ⇒ `void <cName>(<params>, <outTy> *_mtoc2_o<i>...)`
|
|
69
|
+
*
|
|
70
|
+
* Returns `null` if any param or output type fails the C-FFI
|
|
71
|
+
* feasibility check — the executor must decline. */
|
|
72
|
+
export declare function buildCDeclaration(signature: SpecCSignature): string | null;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter: numbl `RuntimeValue` ↔ mtoc2 emit-JS value shape.
|
|
3
|
+
*
|
|
4
|
+
* Numbl wraps tensors / chars / complex / structs in Refcounted
|
|
5
|
+
* classes (`RuntimeTensor`, `RuntimeChar`, `RuntimeComplexNumber`)
|
|
6
|
+
* keyed by a `kind:` discriminator. mtoc2's emitted JS uses plain
|
|
7
|
+
* objects keyed by `mtoc2Tag:` (no class wrapper, no refcount).
|
|
8
|
+
*
|
|
9
|
+
* **Pass-by-value at the boundary.** MATLAB function calls are
|
|
10
|
+
* pass-by-value; a JIT'd function that mutates its argument must
|
|
11
|
+
* not leak the mutation to the caller. mtoc2's whole-program
|
|
12
|
+
* codegen handles this by wrapping every call-site argument in
|
|
13
|
+
* `mtoc2_deep_clone(...)` — but the JIT executor is a *new* call
|
|
14
|
+
* site that mtoc2 doesn't know about, so we have to clone the
|
|
15
|
+
* tensor data buffer ourselves on the way in. On the way out, we
|
|
16
|
+
* take ownership of the returned buffer directly (mtoc2's spec
|
|
17
|
+
* always returns a freshly-owned tensor).
|
|
18
|
+
*
|
|
19
|
+
* The executor only invokes these adapters on values whose JitType
|
|
20
|
+
* was accepted by `jitTypeToCompilerType`. Unsupported value kinds
|
|
21
|
+
* arriving here are a programmer error — the type adapter should
|
|
22
|
+
* have caused `propose()` to decline earlier.
|
|
23
|
+
*/
|
|
24
|
+
import { type RuntimeValue } from "../../runtime/types.js";
|
|
25
|
+
import type { JitType } from "../../jitTypes.js";
|
|
26
|
+
/** numbl RuntimeValue → mtoc2 emit-JS value shape. Owned-typed
|
|
27
|
+
* values (tensors) get their data buffer cloned so mtoc2's spec
|
|
28
|
+
* body can mutate freely without leaking the change back through
|
|
29
|
+
* numbl's caller-side env.
|
|
30
|
+
*
|
|
31
|
+
* `targetType` is the JitType the spec was COMPILED for at this
|
|
32
|
+
* parameter. Type-widening can reuse a complex specialization for a
|
|
33
|
+
* later real/boolean scalar call (both keys collapse to
|
|
34
|
+
* `complex_or_number`); the complex-typed body reads `.re`/`.im`, so a
|
|
35
|
+
* bare JS number arriving there yields `undefined` → NaN. Box such a
|
|
36
|
+
* scalar into `{re, im:0}` to mirror the C adapter (valueAdapterC),
|
|
37
|
+
* which already boxes a real as a complex with `im=0`. */
|
|
38
|
+
export declare function numblToJit(v: RuntimeValue, targetType?: JitType): unknown;
|
|
39
|
+
/** mtoc2 emit-JS return value → numbl RuntimeValue. */
|
|
40
|
+
export declare function jitToNumbl(v: unknown): RuntimeValue;
|
|
41
|
+
/** True if `e` is the grow-bail sentinel thrown by the emitted JS
|
|
42
|
+
* store helpers (`mtoc2_idx_*_grow_js` in `scalar_index.js`) — an
|
|
43
|
+
* indexed store whose index exceeds the runtime extent, which would
|
|
44
|
+
* grow the array (unsupported in the JIT). The JS executors recognize
|
|
45
|
+
* it to surface a one-time warning; they bail on it (and on any other
|
|
46
|
+
* runtime error) so the interpreter re-runs the scope with full
|
|
47
|
+
* MATLAB grow semantics. */
|
|
48
|
+
export declare function isGrowBail(e: unknown): boolean;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value adapter for the mtoc2 C-JIT path.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `valueAdapter.ts` (JS path) but converts numbl
|
|
5
|
+
* `RuntimeValue` to / from the C ABI mtoc2 expects across the koffi
|
|
6
|
+
* FFI boundary.
|
|
7
|
+
*
|
|
8
|
+
* **Copy budget** (see CLAUDE memo `feedback-no-silent-bails.md`
|
|
9
|
+
* and the user's "no extra copies" guideline):
|
|
10
|
+
* - Scalars: zero copies; passed by value in koffi's args array.
|
|
11
|
+
* - Tensors: one copy in, one copy out. mtoc2's call convention
|
|
12
|
+
* requires the callee own its tensor params (it frees them at
|
|
13
|
+
* scope exit), so the input data must be copied into a
|
|
14
|
+
* `koffi.alloc`'d malloc-backed buffer that mtoc2 can free.
|
|
15
|
+
* Reused / shared buffer would either (a) get freed under
|
|
16
|
+
* numbl's still-live Float64Array, or (b) require extending
|
|
17
|
+
* mtoc2 with borrowed-param semantics — deferred.
|
|
18
|
+
*
|
|
19
|
+
* - Output tensors arrive as `mtoc2_tensor_t` with mtoc2_alloc'd
|
|
20
|
+
* `real`/`imag` pointers. Caller (this adapter) copies the data
|
|
21
|
+
* into a fresh `Float64Array`, then calls `free()` on the
|
|
22
|
+
* pointers (`koffi`-bound `free` from libc) to release mtoc2's
|
|
23
|
+
* buffers.
|
|
24
|
+
*/
|
|
25
|
+
import { RuntimeTensor, type RuntimeValue } from "../../runtime/types.js";
|
|
26
|
+
import type { Type, NumericType } from "../../jit/index.js";
|
|
27
|
+
import type { KoffiLib } from "./compileC.js";
|
|
28
|
+
/** Loose koffi typing — same shape as in typeAdapterC.ts. */
|
|
29
|
+
type KoffiAny = any;
|
|
30
|
+
interface Koffi {
|
|
31
|
+
alloc(type: string, count: number): any;
|
|
32
|
+
decode(ptr: unknown, type: string, count: number): any;
|
|
33
|
+
encode(buf: any, type: string, value: any): void;
|
|
34
|
+
address(buf: any): any;
|
|
35
|
+
}
|
|
36
|
+
/** A function that frees the `mtoc2_alloc`'d buffer at the given
|
|
37
|
+
* pointer. Resolved via koffi against libc's `free`. The .so we
|
|
38
|
+
* dlopen pulls in libc anyway, so binding through the same lib is
|
|
39
|
+
* zero-cost. */
|
|
40
|
+
type FreeFn = (ptr: unknown) => void;
|
|
41
|
+
interface MarshalCtx {
|
|
42
|
+
readonly koffi: Koffi;
|
|
43
|
+
readonly free: FreeFn;
|
|
44
|
+
}
|
|
45
|
+
/** Bind numbl's output sink into an emitted C `.so` so program output
|
|
46
|
+
* (disp / fprintf / …) routes through `write` instead of libc stdout
|
|
47
|
+
* — see `runtime/io/host_output.h`. Returns a `dispose()` the caller
|
|
48
|
+
* MUST invoke after the C call returns (success or throw) to unbind
|
|
49
|
+
* and free the koffi callback.
|
|
50
|
+
*
|
|
51
|
+
* When the spec emitted no output, `mtoc2_set_host_write` is absent
|
|
52
|
+
* from the `.so`; binding then no-ops (the C code never writes). */
|
|
53
|
+
export declare function bindHostWrite(koffi: KoffiAny, lib: KoffiLib, write: (s: string) => void): {
|
|
54
|
+
dispose(): void;
|
|
55
|
+
};
|
|
56
|
+
/** Bind the emitted `.so`'s grow-bail flag accessors. A runtime
|
|
57
|
+
* indexed-store grow (`v(k) = x`, k past the runtime extent) sets a
|
|
58
|
+
* flag in the `.so` and `longjmp`s back to the host-entry function's
|
|
59
|
+
* guard (see `grow_bail.h`), which returns normally. The host calls
|
|
60
|
+
* `reset()` before each invocation and `bailed()` after; when
|
|
61
|
+
* `bailed()` is true it discards the outputs and bails to the
|
|
62
|
+
* interpreter (which has full MATLAB grow semantics).
|
|
63
|
+
*
|
|
64
|
+
* When the spec emitted no scalar indexed store, `mtoc2_grow_bail_*`
|
|
65
|
+
* are absent from the `.so`; binding then no-ops (`bailed()` is always
|
|
66
|
+
* false — the code can't grow). */
|
|
67
|
+
export declare function bindGrowBail(lib: KoffiLib): {
|
|
68
|
+
reset(): void;
|
|
69
|
+
bailed(): boolean;
|
|
70
|
+
};
|
|
71
|
+
/** Build a marshaling context from a koffi lib handle. The host
|
|
72
|
+
* passes the lib it got from `compileAndLoadC`; we resolve `free`
|
|
73
|
+
* against that same lib (libc symbols are reachable through any
|
|
74
|
+
* dlopen'd .so). */
|
|
75
|
+
export declare function makeCMarshalCtx(koffi: Koffi, lib: KoffiLib): MarshalCtx;
|
|
76
|
+
/** Marshaled-input bookkeeping returned by `marshalInputs`. The
|
|
77
|
+
* caller is responsible for invoking `release()` once the C call
|
|
78
|
+
* has returned (success or throw). `release` does nothing for
|
|
79
|
+
* scalar inputs (no allocation); for tensor inputs it's also a
|
|
80
|
+
* no-op: mtoc2's spec body frees the buffers at its scope exit.
|
|
81
|
+
* Kept as an explicit handle so a future change to lifetime
|
|
82
|
+
* semantics has a single place to update. */
|
|
83
|
+
export interface MarshaledInputs {
|
|
84
|
+
/** The values to splat into the koffi call, in order. */
|
|
85
|
+
readonly args: unknown[];
|
|
86
|
+
release(): void;
|
|
87
|
+
}
|
|
88
|
+
/** Convert a numbl `RuntimeValue` to the matching koffi-callable
|
|
89
|
+
* arg for a parameter of mtoc2 `Type`. */
|
|
90
|
+
export declare function marshalInputs(ctx: MarshalCtx, paramTypes: ReadonlyArray<Type>, values: ReadonlyArray<RuntimeValue | undefined>): MarshaledInputs | null;
|
|
91
|
+
/** Convert a returned C tensor struct (decoded by koffi into a JS
|
|
92
|
+
* object with `{real, imag, ndim, dims}`) to a numbl RuntimeTensor.
|
|
93
|
+
* Reads `n = product(dims[0..ndim])` doubles from each lane, then
|
|
94
|
+
* frees mtoc2's buffers.
|
|
95
|
+
*
|
|
96
|
+
* For `Numeric` outputs that aren't multi-element (scalars), the
|
|
97
|
+
* caller passes the bare value through `unmarshalScalarOutput`
|
|
98
|
+
* instead — koffi unboxes them automatically.
|
|
99
|
+
*/
|
|
100
|
+
export declare function unmarshalTensorOutput(ctx: MarshalCtx, ret: KoffiAny, ty: NumericType): RuntimeTensor;
|
|
101
|
+
/** Convert a bare scalar return value to a numbl RuntimeValue.
|
|
102
|
+
*
|
|
103
|
+
* Real / logical scalars ride the `double` ABI, so koffi hands us a
|
|
104
|
+
* JS number (logical coerces to `Boolean`). Complex scalars ride the
|
|
105
|
+
* `mtoc2_cscalar_t` struct, so koffi hands us a `{re, im}` object,
|
|
106
|
+
* which becomes a `RuntimeComplexNumber`. */
|
|
107
|
+
export declare function unmarshalScalarOutput(v: unknown, ty: NumericType): RuntimeValue;
|
|
108
|
+
export {};
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared lowering pipeline.
|
|
3
3
|
*
|
|
4
|
-
* The dispatcher calls `tryLower` once per stmt-dispatch
|
|
5
|
-
* `tryLowerCall` per function-call dispatch
|
|
4
|
+
* The dispatcher calls `tryLower` once per stmt-dispatch and
|
|
5
|
+
* `tryLowerCall` per function-call dispatch, before any executor is
|
|
6
6
|
* asked to propose. The result — a `LoweredStmt` — is passed to every
|
|
7
7
|
* executor's `propose()` as the first argument. `tryLower` returns
|
|
8
8
|
* `null` for stmts with no specialized lowering shape; the dispatcher
|
|
9
|
-
* falls through to its hardcoded `interp.execStmt` path in that case
|
|
10
|
-
* (no executor needs to filter on "raw stmt").
|
|
9
|
+
* falls through to its hardcoded `interp.execStmt` path in that case.
|
|
11
10
|
*
|
|
12
|
-
* Lowering
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* Lowering here is *classification only*: it analyses inputs/outputs,
|
|
12
|
+
* infers types, and synthesizes a cacheKey. It does NOT make
|
|
13
|
+
* codegen-feasibility decisions — those live in the codegen executor's
|
|
14
|
+
* `propose`. This keeps the dispatcher free of dependencies on the
|
|
15
|
+
* JIT backend's internals (the in-tree compiler under
|
|
16
|
+
* `src/numbl-core/jit`).
|
|
16
17
|
*
|
|
17
18
|
* Shapes today:
|
|
18
|
-
* - `top-level` — script body (top-level scope
|
|
19
|
-
*
|
|
20
|
-
* - `
|
|
21
|
-
* FunctionDef that wraps just that stmt.
|
|
22
|
-
* - `call` — user-function call. Lowered via `tryLowerCall`
|
|
19
|
+
* - `top-level` — script body (top-level scope). Whole script
|
|
20
|
+
* analysed as a synthetic FunctionDef.
|
|
21
|
+
* - `call` — user-function call. Produced by `tryLowerCall`
|
|
23
22
|
* from `dispatchCall`.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* (`shared.ts`); they're modeled as separate kinds because they have
|
|
27
|
-
* distinct trigger conditions (script-root vs. control-flow stmt) and
|
|
28
|
-
* runtime semantics (claim entire stmt list vs. consume one stmt).
|
|
23
|
+
* - `synth` — a `Synth` AST stmt produced by a registered AST
|
|
24
|
+
* transformer (no further analysis here).
|
|
29
25
|
*
|
|
30
26
|
* Lowerings are cached by (head Stmt or FunctionDef, classification
|
|
31
27
|
* cacheKey).
|
|
@@ -33,78 +29,35 @@
|
|
|
33
29
|
import type { Stmt } from "../parser/types.js";
|
|
34
30
|
import type { FunctionDef } from "../interpreter/types.js";
|
|
35
31
|
import type { Interpreter } from "../interpreter/interpreter.js";
|
|
36
|
-
import type
|
|
37
|
-
import { type TopLevelClassification, type TopLevelLowered } from "./jsJit/jitTopLevel.js";
|
|
38
|
-
import { type LoopClassification, type LoopLowered } from "./jsJit/jitLoop.js";
|
|
39
|
-
import { type CallClassification, type CallLowered } from "./jsJit/jitCall.js";
|
|
40
|
-
import { type FuseClassification } from "./cJit/fuseAnalyze.js";
|
|
32
|
+
import { type TopLevelClassification, type CallClassification, type LoopClassification } from "./classification.js";
|
|
41
33
|
/** What `propose()` receives — a discriminated union of the
|
|
42
34
|
* specialized shapes the dispatcher knows how to lower. Stmts with
|
|
43
35
|
* no specialized shape don't reach `propose()` at all; the dispatcher
|
|
44
36
|
* falls through to its hardcoded interpreter path. */
|
|
45
|
-
export type LoweredStmt = TopLevelLoweredStmt | LoopLoweredStmt | CallLoweredStmt |
|
|
46
|
-
/** Top-level shape: script body
|
|
37
|
+
export type LoweredStmt = TopLevelLoweredStmt | LoopLoweredStmt | CallLoweredStmt | SynthLoweredStmt;
|
|
38
|
+
/** Top-level shape: script body analysed for whole-scope codegen. */
|
|
47
39
|
export interface TopLevelLoweredStmt {
|
|
48
40
|
readonly kind: "top-level";
|
|
49
41
|
readonly classification: TopLevelClassification;
|
|
50
|
-
readonly lowered: TopLevelLowered;
|
|
51
|
-
readonly flags: TopLevelFlags;
|
|
52
|
-
}
|
|
53
|
-
/** Pre-computed feasibility flags for top-level codegen executors. */
|
|
54
|
-
export interface TopLevelFlags {
|
|
55
|
-
/** Body contains a `return` statement. JIT cannot model
|
|
56
|
-
* early-return from the synthetic top-level fn. */
|
|
57
|
-
readonly hasReturn: boolean;
|
|
58
|
-
/** Source body contains an unsuppressed assign / multiassign /
|
|
59
|
-
* non-void-call ExprStmt. In display-mode the JIT must bail —
|
|
60
|
-
* it has no emit for auto-display. */
|
|
61
|
-
readonly hasUnsuppressedAssign: boolean;
|
|
62
|
-
/** Lowered IR contains an I/O builtin (disp, fprintf, ...). */
|
|
63
|
-
readonly hasIO: boolean;
|
|
64
|
-
/** Lowered IR contains a possibly-bailing operation. Combined
|
|
65
|
-
* with hasIO, signals a body that mustn't be retried after a
|
|
66
|
-
* partial run (already-emitted output would duplicate). */
|
|
67
|
-
readonly hasBailRisk: boolean;
|
|
68
42
|
}
|
|
69
|
-
/** Loop shape: a For/While stmt
|
|
43
|
+
/** Loop shape: a single For/While stmt analysed for loop codegen.
|
|
44
|
+
* Produced by `tryLower` when the head stmt is a For/While. */
|
|
70
45
|
export interface LoopLoweredStmt {
|
|
71
46
|
readonly kind: "loop";
|
|
72
47
|
readonly classification: LoopClassification;
|
|
73
|
-
readonly lowered: LoopLowered;
|
|
74
|
-
readonly flags: LoopFlags;
|
|
75
|
-
}
|
|
76
|
-
/** Pre-computed feasibility flags for loop codegen executors. */
|
|
77
|
-
export interface LoopFlags {
|
|
78
|
-
readonly hasReturn: boolean;
|
|
79
|
-
readonly hasIO: boolean;
|
|
80
|
-
readonly hasBailRisk: boolean;
|
|
81
48
|
}
|
|
82
|
-
/** Call shape: a user-function call
|
|
83
|
-
* by `tryLowerCall`, not `tryLower` — function calls fire
|
|
84
|
-
* expression evaluation, not from the stmt loop. */
|
|
49
|
+
/** Call shape: a user-function call analysed for call codegen.
|
|
50
|
+
* Produced by `tryLowerCall`, not `tryLower` — function calls fire
|
|
51
|
+
* from expression evaluation, not from the stmt loop. */
|
|
85
52
|
export interface CallLoweredStmt {
|
|
86
53
|
readonly kind: "call";
|
|
87
54
|
readonly classification: CallClassification;
|
|
88
|
-
readonly lowered: CallLowered;
|
|
89
|
-
readonly flags: CallFlags;
|
|
90
55
|
/** Runtime arg values. Carried alongside the classification
|
|
91
56
|
* because the executor needs them at runCall time; unlike
|
|
92
57
|
* stmt-shape executors, the call executor can't re-fetch them
|
|
93
58
|
* from env. */
|
|
94
59
|
readonly args: readonly unknown[];
|
|
95
60
|
}
|
|
96
|
-
/** Pre-computed feasibility flags for call codegen executors. */
|
|
97
|
-
export interface CallFlags {
|
|
98
|
-
readonly hasIO: boolean;
|
|
99
|
-
readonly hasBailRisk: boolean;
|
|
100
|
-
}
|
|
101
|
-
/** Fuse shape: a single AST `Assign` whose RHS is a fusable
|
|
102
|
-
* element-wise expression tree. Produced by `analyzeFuse` over the
|
|
103
|
-
* raw AST stmt. */
|
|
104
|
-
export interface FuseLoweredStmt {
|
|
105
|
-
readonly kind: "fuse";
|
|
106
|
-
readonly classification: FuseClassification;
|
|
107
|
-
}
|
|
108
61
|
/** Synth shape: a `Synth` AST stmt produced by a registered AST
|
|
109
62
|
* transformer. The matching executor reads `data` (analysis the
|
|
110
63
|
* transformer pre-computed) and the `tag` discriminates among
|
|
@@ -140,27 +93,28 @@ export declare class LoweringCache {
|
|
|
140
93
|
setLastInputTypes(owner: object, slot: string, types: readonly import("../jitTypes.js").JitType[]): void;
|
|
141
94
|
}
|
|
142
95
|
/**
|
|
143
|
-
* Try to lower the stmt at `siblings[i]
|
|
144
|
-
*
|
|
145
|
-
* shape
|
|
146
|
-
*
|
|
96
|
+
* Try to lower the stmt at `siblings[i]`. Returns a `LoweredStmt` for
|
|
97
|
+
* stmts that match a specialized shape, or `null` for stmts with no
|
|
98
|
+
* shape — the dispatcher falls through to its hardcoded interpreter
|
|
99
|
+
* path in that case.
|
|
147
100
|
*
|
|
148
101
|
* Whole-scope shapes (`top-level`) are NOT produced here — they're
|
|
149
102
|
* lowered separately via `tryLowerTopLevel` and dispatched through
|
|
150
103
|
* `Registry.tryRunWholeScope` before the per-stmt loop runs.
|
|
151
104
|
*/
|
|
152
|
-
export declare function tryLower(siblings: readonly Stmt[], i: number,
|
|
105
|
+
export declare function tryLower(siblings: readonly Stmt[], i: number, interp: Interpreter, cache: LoweringCache): LoweredStmt | null;
|
|
153
106
|
/**
|
|
154
107
|
* Lower a script body as a whole-scope unit. Called by the registry
|
|
155
108
|
* before the per-stmt dispatch loop runs; returns a TopLevelLoweredStmt
|
|
156
|
-
* for whole-scope executors to consider, or null when the
|
|
109
|
+
* for whole-scope executors to consider, or null when the classification
|
|
157
110
|
* declines.
|
|
158
111
|
*/
|
|
159
112
|
export declare function tryLowerTopLevel(interp: Interpreter, siblings: readonly Stmt[], cache: LoweringCache): TopLevelLoweredStmt | null;
|
|
160
113
|
/**
|
|
161
114
|
* Try to lower a user-function call. Always returns a
|
|
162
115
|
* `CallLoweredStmt` when classification succeeds; null when the
|
|
163
|
-
*
|
|
116
|
+
* classify declines (`~` params, type-unknown args, varargin
|
|
117
|
+
* arity mismatch).
|
|
164
118
|
*/
|
|
165
|
-
export declare function tryLowerCall(fn: FunctionDef, args: unknown[], nargout: number,
|
|
119
|
+
export declare function tryLowerCall(fn: FunctionDef, args: unknown[], nargout: number, cache: LoweringCache): CallLoweredStmt | null;
|
|
166
120
|
export {};
|
|
@@ -8,32 +8,25 @@
|
|
|
8
8
|
* The AST interpreter is the dispatcher's hardcoded last-resort
|
|
9
9
|
* fallback (see `Registry.dispatch`); it doesn't need to be a
|
|
10
10
|
* registered executor.
|
|
11
|
-
*
|
|
12
|
-
* The C-JIT (e3) executors are registered via an injected callback
|
|
13
|
-
* (`setCJitRegistrar`). A Node-only entry point (`cli.ts`) imports
|
|
14
|
-
* `executors/cJit/register.ts`, which calls `setCJitRegistrar` at
|
|
15
|
-
* load time. The browser worker never imports that module, so the
|
|
16
|
-
* cJit subtree (which pulls in `node:fs`/`node:os`/`node:child_process`
|
|
17
|
-
* via `compile.ts`) stays out of the web bundle.
|
|
18
11
|
*/
|
|
19
12
|
import type { Registry } from "./registry.js";
|
|
20
13
|
/** Optimization mode label.
|
|
21
14
|
*
|
|
22
|
-
* - `"0"`
|
|
23
|
-
* - `"1"`
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
15
|
+
* - `"0"` — pure AST interpreter, no executors registered.
|
|
16
|
+
* - `"1"` — JS-JIT: all three shapes (top-level, loop,
|
|
17
|
+
* call) emit JS via `compileSpec`. JIT declines
|
|
18
|
+
* (`UnsupportedConstruct` / `JitTypeError`) fall back to the
|
|
19
|
+
* interpreter cleanly.
|
|
20
|
+
* - `"2"` — C-JIT-first with JS-JIT fallback. Both backends
|
|
21
|
+
* register their executors; the dispatcher picks based on cost,
|
|
22
|
+
* so the C path wins where it applies (scalar / tensor numeric
|
|
23
|
+
* types with a wired `nativeBridge`) and the JS path picks up
|
|
24
|
+
* the slack (struct / class / handle / no-cc-available).
|
|
25
|
+
* Requires `cc` on the PATH and `koffi` installed; without
|
|
26
|
+
* either, the C executors decline and `"2"` collapses to the
|
|
27
|
+
* same behaviour as `"1"`. */
|
|
28
|
+
export type OptLevel = "0" | "1" | "2";
|
|
30
29
|
export declare const OPT_LEVELS: readonly OptLevel[];
|
|
31
30
|
export declare function isOptLevel(s: string): s is OptLevel;
|
|
32
|
-
type CJitRegistrar = (registry: Registry) => void;
|
|
33
|
-
/** Wire up the C-JIT (e3) executors. Called from a Node-only entry
|
|
34
|
-
* point at startup so the browser bundle never reaches the cJit
|
|
35
|
-
* module graph. */
|
|
36
|
-
export declare function setCJitRegistrar(fn: CJitRegistrar): void;
|
|
37
31
|
/** Register the executors for a given optimization mode. */
|
|
38
32
|
export declare function registerExecutorsForOpt(registry: Registry, opt: OptLevel): void;
|
|
39
|
-
export {};
|
|
@@ -13,7 +13,10 @@ export declare function forEachSlice(shape: number[], dim: number, callback: (ou
|
|
|
13
13
|
resultShape: number[];
|
|
14
14
|
totalElems: number;
|
|
15
15
|
} | null;
|
|
16
|
-
/** Return 1-based dim to reduce along (first
|
|
16
|
+
/** Return 1-based dim to reduce along (first dim whose size != 1), or 0 for
|
|
17
|
+
* "reduce to scalar". A size-0 dimension counts as non-singleton (MATLAB
|
|
18
|
+
* reduces along it), so `sum(zeros(0,3))` is `[0 0 0]` not a scalar — the
|
|
19
|
+
* previous `d > 1` test wrongly treated a size-0 dim as singleton. */
|
|
17
20
|
export declare function firstReduceDim(shape: number[]): number;
|
|
18
21
|
/** Return a deep copy of a tensor (data + shape + optional imag). */
|
|
19
22
|
export declare function copyTensor(v: RuntimeTensor): RuntimeValue;
|
|
@@ -31,6 +31,6 @@ import "./special-math.js";
|
|
|
31
31
|
import "./misc.js";
|
|
32
32
|
import "./dictionary.js";
|
|
33
33
|
import "./help-text.js";
|
|
34
|
-
export { getIBuiltin, getIBuiltinHelp, getIBuiltinNargin, getAllIBuiltinNames,
|
|
34
|
+
export { getIBuiltin, getIBuiltinHelp, getIBuiltinNargin, getAllIBuiltinNames, registerBuiltinHelp, inferJitType, } from "./types.js";
|
|
35
35
|
export type { IBuiltin, IBuiltinResolution, BuiltinHelp } from "./types.js";
|
|
36
36
|
export { resetAppdataStore, convertJsonValue } from "./misc.js";
|
|
@@ -17,13 +17,9 @@ export interface IBuiltin {
|
|
|
17
17
|
help?: BuiltinHelp;
|
|
18
18
|
/** Given input JIT types + nargout, return output types and a specialized apply, or null. */
|
|
19
19
|
resolve: (argTypes: JitType[], nargout: number) => IBuiltinResolution | null;
|
|
20
|
-
/** Optional fast-path JS code emission for JIT. Return null to fall back to $h.ib_<name>. */
|
|
21
|
-
jitEmit?: (argCode: string[], argTypes: JitType[], getDest?: () => string) => string | null;
|
|
22
20
|
}
|
|
23
21
|
export declare function getIBuiltin(name: string): IBuiltin | undefined;
|
|
24
22
|
export declare function registerIBuiltin(b: IBuiltin): void;
|
|
25
|
-
/** Set a callback for dynamic IBuiltin registration (called by jitHelpers setup). */
|
|
26
|
-
export declare function setDynamicRegisterHook(hook: ((b: IBuiltin) => void) | null): void;
|
|
27
23
|
/** Register a dynamic IBuiltin (e.g. .js user functions), replacing any
|
|
28
24
|
* existing entry with the same name without error. */
|
|
29
25
|
export declare function registerDynamicIBuiltin(b: IBuiltin): void;
|
|
@@ -35,10 +31,6 @@ export declare function registerBuiltinHelp(name: string, help: BuiltinHelp): vo
|
|
|
35
31
|
* Tries resolve with 1, 2, 3 number-type args to find the accepted count. */
|
|
36
32
|
export declare function getIBuiltinNargin(name: string): number | undefined;
|
|
37
33
|
export declare function inferJitType(value: unknown): JitType;
|
|
38
|
-
/** Build the ib_* entries for the jitHelpers object.
|
|
39
|
-
* The returned object also has _profileEnter/_profileLeave hooks (no-ops by default)
|
|
40
|
-
* that the runtime replaces when profiling is enabled. */
|
|
41
|
-
export declare function buildIBuiltinHelpers(): Record<string, any>;
|
|
42
34
|
export declare function mkc(re: number, im: number): number | RuntimeComplexNumber;
|
|
43
35
|
export declare function makeTensor(data: Float64Array, imag: Float64Array | undefined, shape: number[]): RuntimeTensor;
|
|
44
36
|
/** Type rule requiring two scalar numbers */
|
|
@@ -66,7 +58,6 @@ export declare function defineBuiltin(opts: {
|
|
|
66
58
|
name: string;
|
|
67
59
|
help?: BuiltinHelp;
|
|
68
60
|
cases: BuiltinCase[];
|
|
69
|
-
jitEmit?: (argCode: string[], argTypes: JitType[], getDest?: () => string) => string | null;
|
|
70
61
|
}): void;
|
|
71
62
|
type NumberJitType = Extract<JitType, {
|
|
72
63
|
kind: "number";
|
|
@@ -104,13 +95,4 @@ export declare function unaryElemwiseCases(spec: UnaryElemwiseSpec, name: string
|
|
|
104
95
|
export declare function unaryRealResultCases(realFn: (x: number) => number, complexFn: (re: number, im: number) => number, name: string): BuiltinCase[];
|
|
105
96
|
/** Build cases for numeric predicates (isnan, isinf, isfinite) that return logical. */
|
|
106
97
|
export declare function predicateCases(scalarTest: (x: number) => boolean, complexTest: (re: number, im: number) => boolean, tensorTest: (x: number) => boolean, tensorComplexTest: (re: number, im: number) => boolean, name: string): BuiltinCase[];
|
|
107
|
-
/** Fast-path emitter for unary Math.* functions.
|
|
108
|
-
* Emits Math.fn(x) for scalar numbers, $h.tHelper(dest, x) for real
|
|
109
|
-
* tensors. `getDest` is a lazy callback returning the dest local: either
|
|
110
|
-
* a mangled LHS (top-level Assign) or a fresh scratch (inner tensor
|
|
111
|
-
* sub-expression). It's only invoked when the tensor fast path is
|
|
112
|
-
* actually taken, so scalar / rejected paths don't burn a scratch. */
|
|
113
|
-
export declare function unaryMathJitEmit(mathFn: string, tensorHelper: string, requireNonneg?: boolean): (argCode: string[], argTypes: JitType[], getDest?: () => string) => string | null;
|
|
114
|
-
/** Fast-path emitter for binary Math.* functions on two scalar numbers. */
|
|
115
|
-
export declare function binaryMathJitEmit(mathFn: string): (argCode: string[], argTypes: JitType[]) => string | null;
|
|
116
98
|
export {};
|
|
@@ -40,6 +40,23 @@ export declare class Interpreter {
|
|
|
40
40
|
dimIndex: number;
|
|
41
41
|
numIndices: number;
|
|
42
42
|
}>;
|
|
43
|
+
/** @internal Number of enclosing `for` / `while` loop bodies the
|
|
44
|
+
* interpreter is currently inside. Bumped on body entry, decremented
|
|
45
|
+
* on exit. Read by the executor registry's `propose()` to gate JIT
|
|
46
|
+
* attempts: when `loopDepth > 0`, the interpreter is iterating a
|
|
47
|
+
* hot loop and per-call JIT lookup overhead / spec-cache thrashing
|
|
48
|
+
* is a net loss. Once mtoc2 successfully JITs an outer call, the
|
|
49
|
+
* nested loops execute inside the compiled artifact and the
|
|
50
|
+
* interpreter never sees them, so this gate only fires on calls
|
|
51
|
+
* that genuinely happen at the interpreter level inside a loop. */
|
|
52
|
+
loopDepth: number;
|
|
53
|
+
/** @internal Number of enclosing conditional blocks (`if` / `switch` /
|
|
54
|
+
* `try`) whose bodies the interpreter is currently executing. Used by
|
|
55
|
+
* the loop classifier: when a loop is dispatched with `condBlockDepth >
|
|
56
|
+
* 0` (or `loopDepth > 0`), its sibling list is a nested block, so the
|
|
57
|
+
* post-loop liveness scan can't see reads after the enclosing block —
|
|
58
|
+
* the classifier must then keep every loop-assigned name live-out. */
|
|
59
|
+
condBlockDepth: number;
|
|
43
60
|
/** @internal */
|
|
44
61
|
functionDefCache: Map<string, FunctionDef>;
|
|
45
62
|
/** @internal Pre-built line break tables for offset→line lookup per file. */
|
|
@@ -50,29 +67,27 @@ export declare class Interpreter {
|
|
|
50
67
|
compileInProgress: Set<string>;
|
|
51
68
|
/**
|
|
52
69
|
* Optimization mode:
|
|
53
|
-
* "0"
|
|
54
|
-
* "1"
|
|
55
|
-
*
|
|
56
|
-
* "
|
|
57
|
-
* registered alongside; loops either match the C-JIT
|
|
58
|
-
* executor or fall back to the AST interpreter.
|
|
70
|
+
* "0" — pure AST interpreter, no JIT.
|
|
71
|
+
* "1" — JS-JIT (default): top-level + call shapes get
|
|
72
|
+
* type-specialized JS via the JIT's `compileSpec`.
|
|
73
|
+
* "2" — C-JIT: scalar/tensor kernels via `compileSpecC` + koffi.
|
|
59
74
|
*/
|
|
60
75
|
optimization: import("../executors/plugins.js").OptLevel;
|
|
61
|
-
/** Callback for JIT compilation logging
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
76
|
+
/** Callback for JIT compilation logging. `lang` distinguishes the
|
|
77
|
+
* emitted source: `"js"` for the JS-JIT backend, `"c"` for the
|
|
78
|
+
* C-JIT backend (both can fire in a single `--opt 2` run). */
|
|
79
|
+
onJitCompile?: (description: string, code: string, lang: "js" | "c") => void;
|
|
80
|
+
/** Called when a JIT-compiled unit bails back to the interpreter at
|
|
81
|
+
* RUNTIME (as opposed to declining at compile time). Today the sole
|
|
82
|
+
* trigger is an indexed-store array growth that's only detectable at
|
|
83
|
+
* runtime — the JIT can't model the grown shape, so it bails and the
|
|
84
|
+
* interpreter re-runs the whole scope with full MATLAB semantics.
|
|
85
|
+
* Surfaced as a warning (the CLI routes it to stderr); a compile-time
|
|
86
|
+
* decline stays silent (it's the normal "not JIT-able" path). */
|
|
87
|
+
onJitBail?: (message: string) => void;
|
|
88
|
+
/** Bridge for loading native shared libraries. Undefined in browser
|
|
89
|
+
* contexts. */
|
|
70
90
|
nativeBridge?: import("../workspace/types.js").NativeBridge;
|
|
71
|
-
/** Compile c-jit kernels with `-ffast-math`. On by default for
|
|
72
|
-
* libmvec-vectorized transcendentals (~30% speedup on element-wise
|
|
73
|
-
* tensor benchmarks); opt out via the CLI's `--no-fast-math` flag
|
|
74
|
-
* to keep reductions bitwise-deterministic. */
|
|
75
|
-
fastMath: boolean;
|
|
76
91
|
/** Telemetry: invoked after a registered executor's `run()` succeeds.
|
|
77
92
|
* Used to track which optimizers fire in a session. The kind is the
|
|
78
93
|
* LoweredStmt kind the executor handled ("top-level", "loop", "call",
|
|
@@ -98,6 +113,7 @@ export declare class Interpreter {
|
|
|
98
113
|
getVariableValues(): Record<string, RuntimeValue>;
|
|
99
114
|
execStmt: (stmt: Stmt) => ControlSignal | null;
|
|
100
115
|
execStmts: (stmts: Stmt[]) => ControlSignal | null;
|
|
116
|
+
execBlockStmts: (stmts: Stmt[]) => ControlSignal | null;
|
|
101
117
|
evalExpr: (expr: Expr) => unknown;
|
|
102
118
|
evalExprNargout: (expr: Expr, nargout: number) => unknown;
|
|
103
119
|
evalBinary: (expr: Extract<Expr, {
|
|
@@ -173,5 +189,5 @@ export declare class Interpreter {
|
|
|
173
189
|
};
|
|
174
190
|
isHandleClass: (classInfo: ClassInfo) => boolean;
|
|
175
191
|
evalInLocalScope: (codeArg: unknown, fileName?: string) => unknown;
|
|
176
|
-
processArgumentsBlocks: (fn: FunctionDef, args: unknown[]) =>
|
|
192
|
+
processArgumentsBlocks: (fn: FunctionDef, args: unknown[]) => void;
|
|
177
193
|
}
|
|
@@ -8,6 +8,12 @@ import { type ControlSignal } from "./types.js";
|
|
|
8
8
|
import type { Interpreter } from "./interpreter.js";
|
|
9
9
|
export declare function execStmt(this: Interpreter, stmt: Stmt): ControlSignal | null;
|
|
10
10
|
export declare function execStmts(this: Interpreter, stmts: Stmt[]): ControlSignal | null;
|
|
11
|
+
/** Execute a conditional-block body (`if` / `switch` / `try`), tracking
|
|
12
|
+
* `condBlockDepth` so a loop dispatched inside knows its sibling list is
|
|
13
|
+
* a nested block — the loop classifier then keeps every loop-assigned
|
|
14
|
+
* name live-out (the post-loop liveness scan can't see reads after the
|
|
15
|
+
* enclosing block). */
|
|
16
|
+
export declare function execBlockStmts(this: Interpreter, stmts: Stmt[]): ControlSignal | null;
|
|
11
17
|
export declare function evalExpr(this: Interpreter, expr: Expr): unknown;
|
|
12
18
|
export declare function evalExprNargout(this: Interpreter, expr: Expr, nargout: number): unknown;
|
|
13
19
|
export declare function evalArgs(this: Interpreter, argExprs: Expr[]): unknown[];
|
|
@@ -41,4 +41,16 @@ export declare function collectClassProperties(this: Interpreter, classInfo: Cla
|
|
|
41
41
|
};
|
|
42
42
|
export declare function isHandleClass(this: Interpreter, classInfo: ClassInfo): boolean;
|
|
43
43
|
export declare function evalInLocalScope(this: Interpreter, codeArg: unknown, fileName?: string): unknown;
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Apply `arguments`-block defaults and build name-value struct parameters,
|
|
46
|
+
* binding the results into the *current* function environment.
|
|
47
|
+
*
|
|
48
|
+
* Must be called with `this.env` already set to the function scope and the
|
|
49
|
+
* caller-supplied positional arguments already bound to their parameters.
|
|
50
|
+
* Default expressions are evaluated in that scope so they can reference
|
|
51
|
+
* earlier arguments (e.g. `mergeIdx = surfaceop.defaultIdx(dom)`), matching
|
|
52
|
+
* MATLAB. Entries are matched to parameters by name via `fn.params`, which
|
|
53
|
+
* also handles the constructor case where the output variable is prepended
|
|
54
|
+
* to `params` (shifting argument positions by one).
|
|
55
|
+
*/
|
|
56
|
+
export declare function processArgumentsBlocks(this: Interpreter, fn: FunctionDef, args: unknown[]): void;
|