numbl 0.3.0 → 0.4.0
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 +17 -33
- package/dist-cli/cli.js +61511 -46223
- package/dist-lib/graphics/types.d.ts +22 -0
- package/dist-lib/lib.js +37582 -22275
- package/dist-lib/numbl-core/executeCode.d.ts +11 -16
- package/dist-lib/numbl-core/executors/cache.d.ts +26 -0
- package/dist-lib/numbl-core/executors/classification.d.ts +134 -0
- package/dist-lib/numbl-core/executors/context.d.ts +76 -0
- package/dist-lib/numbl-core/executors/handleInline.d.ts +42 -0
- package/dist-lib/numbl-core/executors/index.d.ts +14 -0
- 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 +120 -0
- package/dist-lib/numbl-core/executors/plugins.d.ts +32 -0
- package/dist-lib/numbl-core/executors/registry.d.ts +148 -0
- package/dist-lib/numbl-core/executors/types.d.ts +103 -0
- package/dist-lib/numbl-core/functionResolve.d.ts +7 -0
- package/dist-lib/numbl-core/helpers/check-helpers.d.ts +4 -5
- package/dist-lib/numbl-core/helpers/linsolve.d.ts +2 -3
- package/dist-lib/numbl-core/helpers/prng.d.ts +1 -2
- package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +4 -1
- package/dist-lib/numbl-core/interpreter/builtins/datetime.d.ts +2 -1
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +1 -1
- package/dist-lib/numbl-core/interpreter/builtins/misc.d.ts +4 -1
- package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +4 -109
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +51 -49
- package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +6 -0
- package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
- package/dist-lib/numbl-core/interpreter/types.d.ts +27 -12
- 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 +13 -5
- 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 +94 -0
- package/dist-lib/numbl-core/jsUserFunctions.d.ts +10 -2
- package/dist-lib/numbl-core/lowering/loweringContext.d.ts +24 -0
- package/dist-lib/numbl-core/native/lapack-bridge.d.ts +3 -3
- package/dist-lib/numbl-core/parser/ClassParser.d.ts +3 -0
- package/dist-lib/numbl-core/parser/types.d.ts +20 -0
- package/dist-lib/numbl-core/runtime/alloc.d.ts +12 -23
- package/dist-lib/numbl-core/runtime/constructors.d.ts +6 -6
- package/dist-lib/numbl-core/runtime/cow.d.ts +33 -0
- package/dist-lib/numbl-core/runtime/index.d.ts +4 -3
- package/dist-lib/numbl-core/runtime/indexing.d.ts +17 -2
- package/dist-lib/numbl-core/runtime/plotBuiltinDispatch.d.ts +86 -0
- package/dist-lib/numbl-core/runtime/plotUtils.d.ts +17 -2
- package/dist-lib/numbl-core/runtime/refcount.d.ts +85 -0
- package/dist-lib/numbl-core/runtime/runtime.d.ts +43 -67
- package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +2 -2
- package/dist-lib/numbl-core/runtime/runtimeIndexing.d.ts +2 -2
- package/dist-lib/numbl-core/runtime/runtimeMemberAccess.d.ts +1 -1
- package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +1 -0
- package/dist-lib/numbl-core/runtime/struct-access.d.ts +2 -1
- package/dist-lib/numbl-core/runtime/types.d.ts +117 -62
- package/dist-lib/numbl-core/runtime/utils.d.ts +2 -8
- 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-COAM8o1E.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-CgBUy7v7.js +4748 -0
- package/dist-site-viewer/assets/index-D5YY8PKx.css +1 -0
- package/dist-site-viewer/assets/numbl-worker-VkVtodCX.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/lapack_linsolve.cpp +1 -1
- package/native/numbl_addon_common.h +2 -2
- package/native/ops/comparison.c +1 -1
- package/native/ops/real_unary_elemwise.c +3 -1
- package/package.json +16 -13
- package/dist-lib/numbl-core/jit/c/abi.d.ts +0 -90
- package/dist-lib/numbl-core/jit/c/assemble.d.ts +0 -56
- package/dist-lib/numbl-core/jit/c/classify.d.ts +0 -70
- package/dist-lib/numbl-core/jit/c/compile.d.ts +0 -37
- package/dist-lib/numbl-core/jit/c/context.d.ts +0 -152
- package/dist-lib/numbl-core/jit/c/emit/assign.d.ts +0 -20
- package/dist-lib/numbl-core/jit/c/emit/complexScalar.d.ts +0 -18
- package/dist-lib/numbl-core/jit/c/emit/fused.d.ts +0 -42
- package/dist-lib/numbl-core/jit/c/emit/helpers.d.ts +0 -40
- package/dist-lib/numbl-core/jit/c/emit/index.d.ts +0 -14
- package/dist-lib/numbl-core/jit/c/emit/scalar.d.ts +0 -23
- package/dist-lib/numbl-core/jit/c/emit/stmt.d.ts +0 -25
- package/dist-lib/numbl-core/jit/c/emit/tensor.d.ts +0 -127
- package/dist-lib/numbl-core/jit/c/emit/userCall.d.ts +0 -58
- package/dist-lib/numbl-core/jit/c/epilogue.d.ts +0 -26
- package/dist-lib/numbl-core/jit/c/feasibility.d.ts +0 -44
- package/dist-lib/numbl-core/jit/c/prelude.d.ts +0 -37
- package/dist-lib/numbl-core/jit/c/visit.d.ts +0 -63
- package/dist-lib/numbl-core/jit/e1/complexKernelEmit.d.ts +0 -46
- package/dist-lib/numbl-core/jit/e1/hash.d.ts +0 -10
- package/dist-lib/numbl-core/jit/e1/install.d.ts +0 -13
- package/dist-lib/numbl-core/jit/e1/kernelEmit.d.ts +0 -54
- package/dist-lib/numbl-core/jit/e1/multiReductionKernel.d.ts +0 -66
- package/dist-lib/numbl-core/jit/e1/openmpFlag.d.ts +0 -13
- package/dist-lib/numbl-core/jit/e1/scalarFnKernel.d.ts +0 -44
- package/dist-lib/numbl-core/jit/e2/assignKernel.d.ts +0 -34
- package/dist-lib/numbl-core/jit/e2/astToJitExpr.d.ts +0 -25
- package/dist-lib/numbl-core/jit/e2/cache.d.ts +0 -80
- package/dist-lib/numbl-core/jit/e2/chainKernelEmit.d.ts +0 -55
- package/dist-lib/numbl-core/jit/e2/classify.d.ts +0 -119
- package/dist-lib/numbl-core/jit/e2/compileFn.d.ts +0 -16
- package/dist-lib/numbl-core/jit/e2/complexChainKernelEmit.d.ts +0 -79
- package/dist-lib/numbl-core/jit/e2/emitShared.d.ts +0 -71
- package/dist-lib/numbl-core/jit/e2/install.d.ts +0 -11
- package/dist-lib/numbl-core/jit/e2/liveness.d.ts +0 -29
- package/dist-lib/numbl-core/jit/e2/loopKernel.d.ts +0 -49
- package/dist-lib/numbl-core/jit/e2/loopKernelEmit.d.ts +0 -75
- package/dist-lib/numbl-core/jit/e2/multiReductionDriver.d.ts +0 -24
- package/dist-lib/numbl-core/jit/e2/reductionKernelEmit.d.ts +0 -72
- package/dist-lib/numbl-core/jit/e2/scalarFnDriver.d.ts +0 -29
- package/dist-lib/numbl-core/jit/fusedChainHelpers.d.ts +0 -65
- package/dist-lib/numbl-core/jit/fusedScalarEmit.d.ts +0 -69
- package/dist-lib/numbl-core/jit/fusion.d.ts +0 -71
- package/dist-lib/numbl-core/jit/fusionOps.d.ts +0 -25
- package/dist-lib/numbl-core/jit/heavyOps.d.ts +0 -15
- package/dist-lib/numbl-core/jit/jitBailSafety.d.ts +0 -41
- package/dist-lib/numbl-core/jit/jitLoop.d.ts +0 -25
- package/dist-lib/numbl-core/jit/jitLoopAnalysis.d.ts +0 -37
- package/dist-lib/numbl-core/jit/jitLower.d.ts +0 -122
- package/dist-lib/numbl-core/jit/jitLowerExpr.d.ts +0 -27
- package/dist-lib/numbl-core/jit/jitLowerStmt.d.ts +0 -9
- package/dist-lib/numbl-core/jit/jitLowerTypes.d.ts +0 -29
- package/dist-lib/numbl-core/jit/jitTopLevel.d.ts +0 -22
- package/dist-lib/numbl-core/jit/jitTypes.d.ts +0 -394
- package/dist-lib/numbl-core/jit/js/jitCodegen.d.ts +0 -7
- package/dist-lib/numbl-core/jit/js/jitCodegenHoist.d.ts +0 -70
- package/dist-lib/numbl-core/jit/js/jitHelpers.d.ts +0 -34
- package/dist-lib/numbl-core/jit/js/jitHelpersComplex.d.ts +0 -21
- package/dist-lib/numbl-core/jit/js/jitHelpersIndex.d.ts +0 -33
- package/dist-lib/numbl-core/jit/js/jitHelpersTensor.d.ts +0 -34
- package/dist-lib/numbl-core/jit/js/jsFusedCodegen.d.ts +0 -17
- package/dist-lib/numbl-core/jit/js/jsMultiReduction.d.ts +0 -70
- package/dist-lib/numbl-core/jit/scalarEmit.d.ts +0 -58
- package/dist-plot-viewer/assets/index-GiUNnMQg.js +0 -4426
- package/native/jit_runtime/jit_runtime.c +0 -261
- package/native/jit_runtime/jit_runtime.h +0 -204
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jit-top-level — compiles a script body via mtoc2's `compileSpec`
|
|
3
|
+
* with the body wrapped as a synthetic user function whose params are
|
|
4
|
+
* the variables the body reads (env inputs) and whose outputs are the
|
|
5
|
+
* variables it assigns (env outputs).
|
|
6
|
+
*
|
|
7
|
+
* The interpreter calls `Registry.tryRunWholeScope` once at script
|
|
8
|
+
* start; we register this via `registerWholeScope`. On compile
|
|
9
|
+
* success the entire script runs in mtoc2-emitted JS; on
|
|
10
|
+
* `UnsupportedConstruct` / `TypeError` we decline and the dispatcher
|
|
11
|
+
* falls through to per-stmt dispatch (where jit-call still handles
|
|
12
|
+
* individual user-function calls).
|
|
13
|
+
*
|
|
14
|
+
* Top-level loops *inside* the script execute as part of the
|
|
15
|
+
* compiled artifact, so `loopDepth` only gates dispatch-level calls,
|
|
16
|
+
* not this whole-scope attempt.
|
|
17
|
+
*/
|
|
18
|
+
import type { Executor } from "../types.js";
|
|
19
|
+
import { type JitType } from "../../jitTypes.js";
|
|
20
|
+
import type { Stmt } from "../../parser/index.js";
|
|
21
|
+
import { type Type as CompilerType } from "../../jit/index.js";
|
|
22
|
+
interface JitTopLevelData {
|
|
23
|
+
readonly stmts: readonly Stmt[];
|
|
24
|
+
readonly inputs: readonly string[];
|
|
25
|
+
readonly outputs: readonly string[];
|
|
26
|
+
readonly inputTypes: readonly JitType[];
|
|
27
|
+
readonly compilerInputTypes: readonly CompilerType[];
|
|
28
|
+
readonly currentFile: string;
|
|
29
|
+
readonly cacheKey: string;
|
|
30
|
+
}
|
|
31
|
+
interface CompiledArtifact {
|
|
32
|
+
readonly specFn: (...args: unknown[]) => unknown;
|
|
33
|
+
readonly nargout: number;
|
|
34
|
+
}
|
|
35
|
+
export declare const jitTopLevelExecutor: Executor<JitTopLevelData, CompiledArtifact | null>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter: numbl `JitType` → mtoc2 `Type`.
|
|
3
|
+
*
|
|
4
|
+
* Called by the mtoc2 JIT executor at `propose()` time. Numbl observes
|
|
5
|
+
* each argument's `JitType` from the live runtime value (via
|
|
6
|
+
* `inferJitType`); the adapter translates it into the matching mtoc2
|
|
7
|
+
* Type so `compileSpec` can specialize on the same shape information.
|
|
8
|
+
*
|
|
9
|
+
* Two design rules:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Always strip exact.** Runtime-observed scalars must NOT shard
|
|
12
|
+
* mtoc2's spec cache by value. We never propagate `exact` through
|
|
13
|
+
* the adapter — `compileSpec` calls `withoutExact` again
|
|
14
|
+
* defensively, but doing it here makes the spec key wider one step
|
|
15
|
+
* earlier.
|
|
16
|
+
* 2. **Reject unsupported kinds via `null`.** The executor's
|
|
17
|
+
* `propose()` treats `null` from this adapter as "decline this
|
|
18
|
+
* JIT proposal" — the dispatcher falls through to the next
|
|
19
|
+
* executor (eventually the interpreter). First-cut coverage is
|
|
20
|
+
* scalars + dense real/complex tensors + strings + chars. Structs,
|
|
21
|
+
* cells, class instances, struct arrays, sparse, dictionaries, and
|
|
22
|
+
* function handles return `null`; they can be added later.
|
|
23
|
+
*/
|
|
24
|
+
import type { JitType } from "../../jitTypes.js";
|
|
25
|
+
import { type Type } from "../../jit/index.js";
|
|
26
|
+
/** Translate a numbl `JitType` to the matching mtoc2 `Type`.
|
|
27
|
+
* Returns `null` for kinds the mtoc2 JIT path doesn't accept (yet). */
|
|
28
|
+
export declare function jitTypeToCompilerType(jt: JitType): Type | null;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared lowering pipeline.
|
|
3
|
+
*
|
|
4
|
+
* The dispatcher calls `tryLower` once per stmt-dispatch and
|
|
5
|
+
* `tryLowerCall` per function-call dispatch, before any executor is
|
|
6
|
+
* asked to propose. The result — a `LoweredStmt` — is passed to every
|
|
7
|
+
* executor's `propose()` as the first argument. `tryLower` returns
|
|
8
|
+
* `null` for stmts with no specialized lowering shape; the dispatcher
|
|
9
|
+
* falls through to its hardcoded `interp.execStmt` path in that case.
|
|
10
|
+
*
|
|
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`).
|
|
17
|
+
*
|
|
18
|
+
* Shapes today:
|
|
19
|
+
* - `top-level` — script body (top-level scope). Whole script
|
|
20
|
+
* analysed as a synthetic FunctionDef.
|
|
21
|
+
* - `call` — user-function call. Produced by `tryLowerCall`
|
|
22
|
+
* from `dispatchCall`.
|
|
23
|
+
* - `synth` — a `Synth` AST stmt produced by a registered AST
|
|
24
|
+
* transformer (no further analysis here).
|
|
25
|
+
*
|
|
26
|
+
* Lowerings are cached by (head Stmt or FunctionDef, classification
|
|
27
|
+
* cacheKey).
|
|
28
|
+
*/
|
|
29
|
+
import type { Stmt } from "../parser/types.js";
|
|
30
|
+
import type { FunctionDef } from "../interpreter/types.js";
|
|
31
|
+
import type { Interpreter } from "../interpreter/interpreter.js";
|
|
32
|
+
import { type TopLevelClassification, type CallClassification, type LoopClassification } from "./classification.js";
|
|
33
|
+
/** What `propose()` receives — a discriminated union of the
|
|
34
|
+
* specialized shapes the dispatcher knows how to lower. Stmts with
|
|
35
|
+
* no specialized shape don't reach `propose()` at all; the dispatcher
|
|
36
|
+
* falls through to its hardcoded interpreter path. */
|
|
37
|
+
export type LoweredStmt = TopLevelLoweredStmt | LoopLoweredStmt | CallLoweredStmt | SynthLoweredStmt;
|
|
38
|
+
/** Top-level shape: script body analysed for whole-scope codegen. */
|
|
39
|
+
export interface TopLevelLoweredStmt {
|
|
40
|
+
readonly kind: "top-level";
|
|
41
|
+
readonly classification: TopLevelClassification;
|
|
42
|
+
}
|
|
43
|
+
/** Loop shape: a single For/While stmt analysed for loop codegen.
|
|
44
|
+
* Produced by `tryLower` when the head stmt is a For/While. */
|
|
45
|
+
export interface LoopLoweredStmt {
|
|
46
|
+
readonly kind: "loop";
|
|
47
|
+
readonly classification: LoopClassification;
|
|
48
|
+
}
|
|
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. */
|
|
52
|
+
export interface CallLoweredStmt {
|
|
53
|
+
readonly kind: "call";
|
|
54
|
+
readonly classification: CallClassification;
|
|
55
|
+
/** Runtime arg values. Carried alongside the classification
|
|
56
|
+
* because the executor needs them at runCall time; unlike
|
|
57
|
+
* stmt-shape executors, the call executor can't re-fetch them
|
|
58
|
+
* from env. */
|
|
59
|
+
readonly args: readonly unknown[];
|
|
60
|
+
}
|
|
61
|
+
/** Synth shape: a `Synth` AST stmt produced by a registered AST
|
|
62
|
+
* transformer. The matching executor reads `data` (analysis the
|
|
63
|
+
* transformer pre-computed) and the `tag` discriminates among
|
|
64
|
+
* multiple registered transformers. */
|
|
65
|
+
export interface SynthLoweredStmt {
|
|
66
|
+
readonly kind: "synth";
|
|
67
|
+
readonly tag: string;
|
|
68
|
+
readonly data: unknown;
|
|
69
|
+
}
|
|
70
|
+
declare const BAILED: unique symbol;
|
|
71
|
+
type Bailed = typeof BAILED;
|
|
72
|
+
/** Per-owner lowering cache. Owner is either the head Stmt
|
|
73
|
+
* (stmt-shape lowerings) or the FunctionDef (call-shape lowerings).
|
|
74
|
+
* WeakMap-scoped so entries are reclaimed when the AST is dropped.
|
|
75
|
+
*
|
|
76
|
+
* Also tracks per-owner type-widening state: the most recent input
|
|
77
|
+
* type signature seen for a given (owner, slot). Classify phases
|
|
78
|
+
* consult this so a callee invoked with shifting input types
|
|
79
|
+
* converges to a single specialization rather than thrashing the
|
|
80
|
+
* cache. The slot string lets one owner host multiple widening
|
|
81
|
+
* trackers (e.g. one per nargout for call-shape). */
|
|
82
|
+
export declare class LoweringCache {
|
|
83
|
+
private readonly slots;
|
|
84
|
+
private readonly widening;
|
|
85
|
+
get(owner: object, cacheKey: string): LoweredStmt | Bailed | undefined;
|
|
86
|
+
set(owner: object, cacheKey: string, value: LoweredStmt): void;
|
|
87
|
+
markBailed(owner: object, cacheKey: string): void;
|
|
88
|
+
isBailed(value: unknown): value is Bailed;
|
|
89
|
+
/** Most recent input-type signature recorded for (owner, slot), or
|
|
90
|
+
* undefined when nothing has been recorded yet. */
|
|
91
|
+
getLastInputTypes(owner: object, slot: string): import("../jitTypes.js").JitType[] | undefined;
|
|
92
|
+
/** Record the latest unified input-type signature for (owner, slot). */
|
|
93
|
+
setLastInputTypes(owner: object, slot: string, types: readonly import("../jitTypes.js").JitType[]): void;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
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.
|
|
100
|
+
*
|
|
101
|
+
* Whole-scope shapes (`top-level`) are NOT produced here — they're
|
|
102
|
+
* lowered separately via `tryLowerTopLevel` and dispatched through
|
|
103
|
+
* `Registry.tryRunWholeScope` before the per-stmt loop runs.
|
|
104
|
+
*/
|
|
105
|
+
export declare function tryLower(siblings: readonly Stmt[], i: number, interp: Interpreter, cache: LoweringCache): LoweredStmt | null;
|
|
106
|
+
/**
|
|
107
|
+
* Lower a script body as a whole-scope unit. Called by the registry
|
|
108
|
+
* before the per-stmt dispatch loop runs; returns a TopLevelLoweredStmt
|
|
109
|
+
* for whole-scope executors to consider, or null when the classification
|
|
110
|
+
* declines.
|
|
111
|
+
*/
|
|
112
|
+
export declare function tryLowerTopLevel(interp: Interpreter, siblings: readonly Stmt[], cache: LoweringCache): TopLevelLoweredStmt | null;
|
|
113
|
+
/**
|
|
114
|
+
* Try to lower a user-function call. Always returns a
|
|
115
|
+
* `CallLoweredStmt` when classification succeeds; null when the
|
|
116
|
+
* classify declines (`~` params, type-unknown args, varargin
|
|
117
|
+
* arity mismatch).
|
|
118
|
+
*/
|
|
119
|
+
export declare function tryLowerCall(fn: FunctionDef, args: unknown[], nargout: number, cache: LoweringCache): CallLoweredStmt | null;
|
|
120
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mode-driven executor registration.
|
|
3
|
+
*
|
|
4
|
+
* `registerExecutorsForOpt(registry, opt)` is the single switch from
|
|
5
|
+
* an `--opt` value to a set of registered executors. Adding a new
|
|
6
|
+
* mode means extending the switch here — no other call-site changes.
|
|
7
|
+
*
|
|
8
|
+
* The AST interpreter is the dispatcher's hardcoded last-resort
|
|
9
|
+
* fallback (see `Registry.dispatch`); it doesn't need to be a
|
|
10
|
+
* registered executor.
|
|
11
|
+
*/
|
|
12
|
+
import type { Registry } from "./registry.js";
|
|
13
|
+
/** Optimization mode label.
|
|
14
|
+
*
|
|
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";
|
|
29
|
+
export declare const OPT_LEVELS: readonly OptLevel[];
|
|
30
|
+
export declare function isOptLevel(s: string): s is OptLevel;
|
|
31
|
+
/** Register the executors for a given optimization mode. */
|
|
32
|
+
export declare function registerExecutorsForOpt(registry: Registry, opt: OptLevel): void;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executor registry and dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Three entry points, three concerns:
|
|
5
|
+
* - `dispatch(siblings, i, ctx)` — per-stmt dispatch. Each executor
|
|
6
|
+
* handles exactly one stmt (no consumed-N).
|
|
7
|
+
* - `dispatchCall(fn, args, nargout, interp)` — user-function call.
|
|
8
|
+
* - `tryRunWholeScope(siblings, interp)` — whole-script attempt,
|
|
9
|
+
* called once before the per-stmt loop runs. Top-level executors
|
|
10
|
+
* register here separately from per-stmt ones.
|
|
11
|
+
*
|
|
12
|
+
* Plugins register executors at startup; the dispatcher selects among
|
|
13
|
+
* them at runtime based on cost estimates. The AST interpreter is the
|
|
14
|
+
* always-matching last-resort fallback for per-stmt dispatch and isn't
|
|
15
|
+
* a registered executor.
|
|
16
|
+
*/
|
|
17
|
+
import type { Stmt } from "../parser/types.js";
|
|
18
|
+
import type { ControlSignal, FunctionDef } from "../interpreter/types.js";
|
|
19
|
+
import type { Executor } from "./types.js";
|
|
20
|
+
import { DispatchContext } from "./context.js";
|
|
21
|
+
/** AST stmt-list transformer. Receives a stmt list and returns a
|
|
22
|
+
* list of the same semantics, possibly with `Synth` stmts inserted
|
|
23
|
+
* where the transformer can collapse a contiguous run of stmts into
|
|
24
|
+
* a unit handled by a specialized executor. The transform is
|
|
25
|
+
* shallow — recursive descent into For/While/If bodies happens
|
|
26
|
+
* lazily on the next call to `transformStmts`, cached separately. */
|
|
27
|
+
export type StmtTransformer = (stmts: readonly Stmt[]) => Stmt[];
|
|
28
|
+
export interface DispatchResult {
|
|
29
|
+
/** Control signal from interpreter execution (break/continue/return),
|
|
30
|
+
* if any. */
|
|
31
|
+
signal: ControlSignal | null;
|
|
32
|
+
}
|
|
33
|
+
/** Result from `dispatchCall`. `null` means no executor handled the
|
|
34
|
+
* call — the caller should fall through to its own
|
|
35
|
+
* interpreter-execution path. */
|
|
36
|
+
export type CallDispatchResult = {
|
|
37
|
+
result: unknown;
|
|
38
|
+
} | null;
|
|
39
|
+
/** Result from `tryRunWholeScope`. `null` means no whole-scope
|
|
40
|
+
* executor matched (or all bailed) — the caller should fall through
|
|
41
|
+
* to the per-stmt dispatch loop. */
|
|
42
|
+
export type WholeScopeResult = {
|
|
43
|
+
signal: ControlSignal | null;
|
|
44
|
+
} | null;
|
|
45
|
+
export declare class Registry {
|
|
46
|
+
/** Per-stmt executors (loop, call, fuse). */
|
|
47
|
+
private readonly executors;
|
|
48
|
+
/** Whole-scope executors (top-level). Iterated only by
|
|
49
|
+
* `tryRunWholeScope`, separate from per-stmt dispatch. */
|
|
50
|
+
private readonly wholeScopeExecutors;
|
|
51
|
+
/** AST stmt-list transformers. Run lazily on each stmt list before
|
|
52
|
+
* the per-stmt loop walks it; result cached per input list. */
|
|
53
|
+
private readonly transformers;
|
|
54
|
+
/** Memoize transformed lists by input list identity. WeakMap so
|
|
55
|
+
* entries vanish when the AST is dropped. The transformed list
|
|
56
|
+
* is also stored mapped to itself so a second call with the
|
|
57
|
+
* result hits the cache (idempotency). */
|
|
58
|
+
private transformCache;
|
|
59
|
+
private cache;
|
|
60
|
+
private loweringCache;
|
|
61
|
+
/** Pre-allocated context reused for `dispatchCall`. Avoids the
|
|
62
|
+
* per-call Map+Set allocation cost that previously motivated
|
|
63
|
+
* bypassing ctx entirely on call-heavy workloads. Safe to reuse
|
|
64
|
+
* because dispatchCall isn't reentrant within itself: each call's
|
|
65
|
+
* propose/compile/run touches the context synchronously, and any
|
|
66
|
+
* nested call dispatch goes through `Interpreter.callUserFunction`
|
|
67
|
+
* which re-enters dispatchCall and re-resets the context. */
|
|
68
|
+
private callCtx;
|
|
69
|
+
register(executor: Executor): void;
|
|
70
|
+
/** Register an executor that handles a whole stmt list as a unit
|
|
71
|
+
* (e.g. JS-JIT top-level). Iterated only by `tryRunWholeScope`
|
|
72
|
+
* and never seen by per-stmt dispatch. */
|
|
73
|
+
registerWholeScope(executor: Executor): void;
|
|
74
|
+
/** Register an AST stmt-list transformer. Transformers run on every
|
|
75
|
+
* stmt list the interpreter is about to walk (script body, function
|
|
76
|
+
* body, loop body, if branch, ...) before the per-stmt loop kicks
|
|
77
|
+
* in. They typically wrap contiguous runs of stmts in `Synth`
|
|
78
|
+
* nodes that a matching executor will recognize. Adding new
|
|
79
|
+
* transformers is additive — they compose in registration order. */
|
|
80
|
+
registerStmtTransformer(fn: StmtTransformer): void;
|
|
81
|
+
/** Transform a stmt list, applying all registered transformers in
|
|
82
|
+
* registration order. Cached per input-list identity (WeakMap).
|
|
83
|
+
* When no transformers are registered, returns the input unchanged
|
|
84
|
+
* without populating the cache (saves a Map lookup per dispatch). */
|
|
85
|
+
transformStmts(stmts: readonly Stmt[]): Stmt[];
|
|
86
|
+
/** Number of registered per-stmt executors. Mainly for tests. */
|
|
87
|
+
get size(): number;
|
|
88
|
+
/** Drop all cached compiled artifacts. Called from
|
|
89
|
+
* `Interpreter.clearAllCaches()` after addpath/rmpath etc. */
|
|
90
|
+
clearCache(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Dispatch one statement at `siblings[i]`. Each executor handles
|
|
93
|
+
* exactly one stmt — the dispatcher always advances by one on
|
|
94
|
+
* success.
|
|
95
|
+
*
|
|
96
|
+
* Hot path. Two optimizations matter for the chunkie-helmholtz-
|
|
97
|
+
* scale workloads:
|
|
98
|
+
*
|
|
99
|
+
* 1. The AST interpreter is the always-applicable last-resort
|
|
100
|
+
* fallback. It is *not* a registered executor — the dispatcher
|
|
101
|
+
* hardcodes a direct call to `ctx.interp.execStmt(stmt)` when
|
|
102
|
+
* no specialized executor matches or all of them bail. This
|
|
103
|
+
* avoids per-dispatch match/Candidate/cache/result allocations
|
|
104
|
+
* for the most common path (where only the interpreter would
|
|
105
|
+
* fit anyway).
|
|
106
|
+
*
|
|
107
|
+
* 2. The reentrancy guard (`pushActive`/`popActive` /
|
|
108
|
+
* `isActive`) is short-circuited when the active set is
|
|
109
|
+
* empty — no sub-dispatch in flight means the bookkeeping is
|
|
110
|
+
* pure overhead.
|
|
111
|
+
*/
|
|
112
|
+
dispatch(siblings: readonly Stmt[], i: number, ctx: DispatchContext): DispatchResult;
|
|
113
|
+
private runStmtCandidate;
|
|
114
|
+
/** Cache lookup + compile-on-miss + run + bail handling. Returns
|
|
115
|
+
* the executor's success RunResult, or null when the candidate
|
|
116
|
+
* bailed (cache may have been marked BAILED). When `guardKey` is
|
|
117
|
+
* non-null, the reentrancy guard pushes/pops around `run()` —
|
|
118
|
+
* passed by the stmt path; the call path passes null because
|
|
119
|
+
* `dispatchCall` isn't reentrant within itself. */
|
|
120
|
+
private executeCandidate;
|
|
121
|
+
/**
|
|
122
|
+
* Dispatch a user-function call. Iterates the same `executors`
|
|
123
|
+
* array as stmt dispatch — call-shape executors filter on
|
|
124
|
+
* `lowered.kind === "call"`. Returns `{ result }` when one of them
|
|
125
|
+
* handles the call, or `null` so the caller (callUserFunction)
|
|
126
|
+
* falls through to the AST interpreter.
|
|
127
|
+
*
|
|
128
|
+
* Reuses a pre-allocated DispatchContext (`callCtx`) to avoid the
|
|
129
|
+
* per-call Map+Set allocation that previously motivated bypassing
|
|
130
|
+
* ctx for call dispatch entirely.
|
|
131
|
+
*/
|
|
132
|
+
dispatchCall(fn: FunctionDef, args: unknown[], nargout: number, interp: import("../interpreter/interpreter.js").Interpreter): CallDispatchResult;
|
|
133
|
+
private runCallCandidate;
|
|
134
|
+
private getCallCtx;
|
|
135
|
+
/**
|
|
136
|
+
* Whole-scope dispatch: try to handle the entire stmt list as a
|
|
137
|
+
* single unit (e.g. JS-JIT top-level). Called by the Interpreter
|
|
138
|
+
* once before the per-stmt loop runs. Returns:
|
|
139
|
+
* - `{ signal }` when a whole-scope executor handled the body.
|
|
140
|
+
* The caller should skip the per-stmt loop entirely.
|
|
141
|
+
* - `null` when no whole-scope executor matched (or all bailed).
|
|
142
|
+
* The caller falls through to per-stmt dispatch.
|
|
143
|
+
*/
|
|
144
|
+
tryRunWholeScope(siblings: readonly Stmt[], interp: import("../interpreter/interpreter.js").Interpreter): WholeScopeResult;
|
|
145
|
+
private finishWholeScope;
|
|
146
|
+
}
|
|
147
|
+
/** Build a fresh dispatch context. */
|
|
148
|
+
export declare function makeRootContext(interp: import("../interpreter/interpreter.js").Interpreter, registry: Registry): DispatchContext;
|