numbl 0.4.21 → 0.4.22
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 +12 -6
- package/dist-browser/browser/index.d.ts +1 -1
- package/dist-browser/browser/mip.d.ts +7 -0
- package/dist-browser/browser/protocol.d.ts +1 -1
- package/dist-browser/browser.js +1 -1
- package/dist-browser/db/operations.d.ts +0 -1
- package/dist-browser/gpuHelper.d.ts +29 -0
- package/dist-browser/hooks/projectFilesState.d.ts +37 -0
- package/dist-browser/numbl-core/execSession.d.ts +39 -0
- package/dist-browser/numbl-core/executeCode.d.ts +10 -1
- package/dist-browser/numbl-core/executors/classification.d.ts +2 -10
- package/dist-browser/numbl-core/executors/jit/backend.d.ts +65 -0
- package/dist-browser/numbl-core/executors/jit/cBackend.d.ts +22 -0
- package/dist-browser/numbl-core/executors/jit/callExecutor.d.ts +13 -44
- package/dist-browser/numbl-core/executors/jit/hostHelpers.d.ts +24 -0
- package/dist-browser/numbl-core/executors/jit/jsBackend.d.ts +15 -0
- package/dist-browser/numbl-core/executors/jit/loopExecutor.d.ts +13 -40
- package/dist-browser/numbl-core/executors/jit/session.d.ts +1 -1
- package/dist-browser/numbl-core/executors/jit/topLevelExecutor.d.ts +13 -33
- package/dist-browser/numbl-core/executors/jit/valueAdapterC.d.ts +32 -48
- package/dist-browser/numbl-core/executors/lowering.d.ts +38 -96
- package/dist-browser/numbl-core/executors/plugins.d.ts +14 -28
- package/dist-browser/numbl-core/executors/registry.d.ts +32 -133
- package/dist-browser/numbl-core/executors/types.d.ts +30 -92
- package/dist-browser/numbl-core/functionResolve.d.ts +3 -13
- package/dist-browser/numbl-core/helpers/check-helpers.d.ts +0 -5
- package/dist-browser/numbl-core/helpers/glob.d.ts +14 -0
- package/dist-browser/numbl-core/helpers/linsolve.d.ts +3 -13
- package/dist-browser/numbl-core/helpers/reduction-helpers.d.ts +2 -4
- package/dist-browser/numbl-core/helpers/shape-utils.d.ts +10 -0
- package/dist-browser/numbl-core/interpreter/builtins/index.d.ts +3 -1
- package/dist-browser/numbl-core/interpreter/builtins/time-system.d.ts +0 -1
- package/dist-browser/numbl-core/interpreter/builtins/types.d.ts +7 -7
- package/dist-browser/numbl-core/interpreter/interpreter.d.ts +6 -6
- package/dist-browser/numbl-core/interpreter/interpreterFunctions.d.ts +9 -1
- package/dist-browser/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
- package/dist-browser/numbl-core/jit/builtins/defs/_shared.d.ts +1 -5
- package/dist-browser/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +1 -2
- package/dist-browser/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +3 -3
- package/dist-browser/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +1 -1
- package/dist-browser/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +1 -1
- package/dist-browser/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +5 -2
- package/dist-browser/numbl-core/jit/builtins/defs/math/realsqrt.d.ts +6 -0
- package/dist-browser/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +0 -5
- package/dist-browser/numbl-core/jit/builtins/defs/shape/_construct.d.ts +0 -4
- package/dist-browser/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +2 -8
- package/dist-browser/numbl-core/jit/builtins/defs/system/deal.d.ts +4 -5
- package/dist-browser/numbl-core/jit/builtins/defs/system/feval.d.ts +7 -29
- package/dist-browser/numbl-core/jit/builtins/registry.d.ts +15 -30
- package/dist-browser/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
- package/dist-browser/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +4 -0
- package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +45 -15
- package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +5 -5
- package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +6 -0
- package/dist-browser/numbl-core/jit/codegen/emit.d.ts +9 -30
- package/dist-browser/numbl-core/jit/codegen/emitJs.d.ts +9 -27
- package/dist-browser/numbl-core/jit/codegen/emitStmt.d.ts +8 -31
- package/dist-browser/numbl-core/jit/codegen/emitTensorFused.d.ts +10 -9
- package/dist-browser/numbl-core/jit/codegen/inlinePass.d.ts +39 -48
- package/dist-browser/numbl-core/jit/codegen/prettyIR.d.ts +1 -6
- package/dist-browser/numbl-core/jit/codegen/runtime.d.ts +7 -28
- package/dist-browser/numbl-core/jit/compileSpec.d.ts +3 -6
- package/dist-browser/numbl-core/jit/compileSpecC.d.ts +5 -0
- package/dist-browser/numbl-core/jit/lowering/assignedFlags.d.ts +24 -0
- package/dist-browser/numbl-core/jit/lowering/definiteAssign.d.ts +3 -1
- package/dist-browser/numbl-core/jit/lowering/errors.d.ts +3 -15
- package/dist-browser/numbl-core/jit/lowering/ir.d.ts +0 -2
- package/dist-browser/numbl-core/jit/lowering/lower.d.ts +4 -12
- package/dist-browser/numbl-core/jit/lowering/types.d.ts +2 -7
- package/dist-browser/numbl-core/jit/numbl/index.d.ts +5 -14
- package/dist-browser/numbl-core/jit/parser/index.d.ts +4 -9
- package/dist-browser/numbl-core/jit/workspace/workspace.d.ts +32 -136
- package/dist-browser/numbl-core/jitDeclineDiagnostics.d.ts +1 -1
- package/dist-browser/numbl-core/jsUserFunctions.d.ts +10 -12
- package/dist-browser/numbl-core/lowering/classInfo.d.ts +4 -1
- package/dist-browser/numbl-core/lowering/loweringContext.d.ts +15 -23
- package/dist-browser/numbl-core/native/lapack-bridge.d.ts +111 -130
- package/dist-browser/numbl-core/native/ts-lapack-bridge.d.ts +4 -5
- package/dist-browser/numbl-core/native/ts-lapack-complex.d.ts +23 -0
- package/dist-browser/numbl-core/native/ts-lapack-qr-lu.d.ts +37 -0
- package/dist-browser/numbl-core/native/wasm-lapack-bridge.d.ts +4 -5
- package/dist-browser/numbl-core/ops/dispatch.d.ts +4 -5
- package/dist-browser/numbl-core/parser/types.d.ts +1 -21
- package/{dist-lib/numbl-core/runtime → dist-browser/numbl-core/plotting}/axisCommand.d.ts +2 -2
- package/dist-browser/{graphics → numbl-core/plotting}/axisLimits.d.ts +14 -2
- package/dist-browser/numbl-core/plotting/builtins.d.ts +8 -0
- package/dist-browser/numbl-core/plotting/colormaps.d.ts +10 -0
- package/dist-browser/numbl-core/{runtime/plotBuiltinDispatch.d.ts → plotting/dispatch.d.ts} +14 -25
- package/dist-browser/numbl-core/plotting/imagescExtent.d.ts +19 -0
- package/dist-browser/numbl-core/{runtime/runtimePlot.d.ts → plotting/instructions.d.ts} +5 -17
- package/dist-browser/numbl-core/plotting/parseArgsChart.d.ts +94 -0
- package/dist-browser/numbl-core/plotting/parseArgsCommon.d.ts +64 -0
- package/dist-browser/numbl-core/plotting/parseArgsLine.d.ts +103 -0
- package/dist-browser/numbl-core/plotting/parseArgsPatch.d.ts +38 -0
- package/dist-browser/numbl-core/plotting/parseArgsQuiver.d.ts +32 -0
- package/dist-browser/numbl-core/plotting/parseArgsSurface.d.ts +75 -0
- package/dist-browser/numbl-core/plotting/streamline.d.ts +16 -0
- package/{dist-graphics/graphics → dist-browser/numbl-core/plotting}/types.d.ts +9 -7
- package/dist-browser/numbl-core/runtime/cow.d.ts +0 -8
- package/dist-browser/numbl-core/runtime/refcount.d.ts +0 -3
- package/dist-browser/numbl-core/runtime/registerSpecial.d.ts +15 -0
- package/dist-browser/numbl-core/runtime/runtime.d.ts +11 -35
- package/dist-browser/numbl-core/runtime/runtimeDispatch.d.ts +6 -0
- package/dist-browser/numbl-core/runtime/specialBuiltins.d.ts +3 -9
- package/dist-browser/numbl-core/runtime/uihtmlSession.d.ts +5 -13
- package/dist-browser/numbl-core/runtime/utils.d.ts +4 -1
- package/dist-browser/numbl-core/version.d.ts +1 -1
- package/dist-browser/numbl-core/workspace/workspace.d.ts +64 -0
- package/dist-browser/vfs/syncVfsChanges.d.ts +2 -2
- package/dist-cli/cli.js +74244 -80566
- package/dist-graphics/graphics/FigureView.d.ts +1 -1
- package/dist-graphics/graphics/SurfView.d.ts +3 -2
- package/dist-graphics/graphics/drawPlot.d.ts +1 -1
- package/dist-graphics/graphics/exportFigureHdf5.d.ts +1 -1
- package/dist-graphics/graphics/figureHashTransport.d.ts +1 -1
- package/dist-graphics/graphics/figureUpload.d.ts +1 -1
- package/dist-graphics/graphics/importFigureHdf5.d.ts +1 -1
- package/dist-graphics/graphics/openInFigureViewer.d.ts +1 -1
- package/dist-graphics/graphics/plotHelpers.d.ts +1 -1
- package/dist-graphics/graphics/plotLegend.d.ts +1 -1
- package/dist-graphics/graphics/plotMarkers.d.ts +1 -1
- package/dist-graphics/graphics/restoreNaNs.d.ts +1 -1
- package/dist-graphics/graphics/uihtmlRelay.d.ts +16 -0
- package/dist-graphics/graphics-lib.d.ts +3 -3
- package/dist-graphics/index.js +294 -328
- package/{dist-lib/graphics → dist-graphics/numbl-core/plotting}/axisLimits.d.ts +14 -2
- package/dist-graphics/numbl-core/plotting/colormaps.d.ts +10 -0
- package/dist-graphics/numbl-core/plotting/imagescExtent.d.ts +19 -0
- package/{dist-browser/graphics → dist-graphics/numbl-core/plotting}/types.d.ts +9 -7
- package/dist-lib/browser/mip.d.ts +17 -0
- package/dist-lib/cli-scan.d.ts +8 -1
- package/dist-lib/lib.d.ts +1 -1
- package/dist-lib/lib.js +29201 -35301
- package/dist-lib/node.js +22 -14
- package/dist-lib/numbl-core/execSession.d.ts +39 -0
- package/dist-lib/numbl-core/executeCode.d.ts +10 -1
- package/dist-lib/numbl-core/executors/classification.d.ts +2 -10
- package/dist-lib/numbl-core/executors/jit/backend.d.ts +65 -0
- package/dist-lib/numbl-core/executors/jit/cBackend.d.ts +22 -0
- package/dist-lib/numbl-core/executors/jit/callExecutor.d.ts +13 -44
- package/dist-lib/numbl-core/executors/jit/hostHelpers.d.ts +24 -0
- package/dist-lib/numbl-core/executors/jit/jsBackend.d.ts +15 -0
- package/dist-lib/numbl-core/executors/jit/loopExecutor.d.ts +13 -40
- package/dist-lib/numbl-core/executors/jit/session.d.ts +1 -1
- package/dist-lib/numbl-core/executors/jit/topLevelExecutor.d.ts +13 -33
- package/dist-lib/numbl-core/executors/jit/valueAdapterC.d.ts +32 -48
- package/dist-lib/numbl-core/executors/lowering.d.ts +38 -96
- package/dist-lib/numbl-core/executors/plugins.d.ts +14 -28
- package/dist-lib/numbl-core/executors/registry.d.ts +32 -133
- package/dist-lib/numbl-core/executors/types.d.ts +30 -92
- package/dist-lib/numbl-core/functionResolve.d.ts +3 -13
- package/dist-lib/numbl-core/helpers/check-helpers.d.ts +0 -5
- package/dist-lib/numbl-core/helpers/glob.d.ts +14 -0
- package/dist-lib/numbl-core/helpers/linsolve.d.ts +3 -13
- package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +2 -4
- package/dist-lib/numbl-core/helpers/shape-utils.d.ts +10 -0
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +3 -1
- package/dist-lib/numbl-core/interpreter/builtins/time-system.d.ts +0 -1
- package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +7 -7
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +6 -6
- package/dist-lib/numbl-core/interpreter/interpreterFunctions.d.ts +9 -1
- package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
- package/dist-lib/numbl-core/jit/builtins/defs/_shared.d.ts +1 -5
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +1 -2
- package/dist-lib/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +3 -3
- package/dist-lib/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +1 -1
- package/dist-lib/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +1 -1
- package/dist-lib/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +5 -2
- package/dist-lib/numbl-core/jit/builtins/defs/math/realsqrt.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +0 -5
- package/dist-lib/numbl-core/jit/builtins/defs/shape/_construct.d.ts +0 -4
- package/dist-lib/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +2 -8
- package/dist-lib/numbl-core/jit/builtins/defs/system/deal.d.ts +4 -5
- package/dist-lib/numbl-core/jit/builtins/defs/system/feval.d.ts +7 -29
- package/dist-lib/numbl-core/jit/builtins/registry.d.ts +15 -30
- 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 +4 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +45 -15
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +5 -5
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +6 -0
- package/dist-lib/numbl-core/jit/codegen/emit.d.ts +9 -30
- package/dist-lib/numbl-core/jit/codegen/emitJs.d.ts +9 -27
- package/dist-lib/numbl-core/jit/codegen/emitStmt.d.ts +8 -31
- package/dist-lib/numbl-core/jit/codegen/emitTensorFused.d.ts +10 -9
- package/dist-lib/numbl-core/jit/codegen/inlinePass.d.ts +39 -48
- package/dist-lib/numbl-core/jit/codegen/prettyIR.d.ts +1 -6
- package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +7 -28
- package/dist-lib/numbl-core/jit/compileSpec.d.ts +3 -6
- package/dist-lib/numbl-core/jit/compileSpecC.d.ts +5 -0
- package/dist-lib/numbl-core/jit/lowering/assignedFlags.d.ts +24 -0
- package/dist-lib/numbl-core/jit/lowering/definiteAssign.d.ts +3 -1
- package/dist-lib/numbl-core/jit/lowering/errors.d.ts +3 -15
- package/dist-lib/numbl-core/jit/lowering/ir.d.ts +0 -2
- package/dist-lib/numbl-core/jit/lowering/lower.d.ts +4 -12
- package/dist-lib/numbl-core/jit/lowering/types.d.ts +2 -7
- package/dist-lib/numbl-core/jit/numbl/index.d.ts +5 -14
- package/dist-lib/numbl-core/jit/parser/index.d.ts +4 -9
- package/dist-lib/numbl-core/jit/workspace/workspace.d.ts +32 -136
- package/dist-lib/numbl-core/jitDeclineDiagnostics.d.ts +1 -1
- package/dist-lib/numbl-core/jsUserFunctions.d.ts +10 -12
- package/dist-lib/numbl-core/lowering/classInfo.d.ts +4 -1
- package/dist-lib/numbl-core/lowering/loweringContext.d.ts +15 -23
- package/dist-lib/numbl-core/native/lapack-bridge.d.ts +111 -130
- package/dist-lib/numbl-core/native/ts-lapack-bridge.d.ts +4 -5
- package/dist-lib/numbl-core/native/ts-lapack-complex.d.ts +23 -0
- package/dist-lib/numbl-core/native/ts-lapack-qr-lu.d.ts +37 -0
- package/dist-lib/numbl-core/native/wasm-lapack-bridge.d.ts +4 -5
- package/dist-lib/numbl-core/ops/dispatch.d.ts +4 -5
- package/dist-lib/numbl-core/parser/types.d.ts +1 -21
- package/{dist-browser/numbl-core/runtime → dist-lib/numbl-core/plotting}/axisCommand.d.ts +2 -2
- package/{dist-graphics/graphics → dist-lib/numbl-core/plotting}/axisLimits.d.ts +14 -2
- package/dist-lib/numbl-core/plotting/builtins.d.ts +8 -0
- package/dist-lib/numbl-core/plotting/colormaps.d.ts +10 -0
- package/dist-lib/numbl-core/{runtime/plotBuiltinDispatch.d.ts → plotting/dispatch.d.ts} +14 -25
- package/dist-lib/numbl-core/plotting/imagescExtent.d.ts +19 -0
- package/dist-lib/numbl-core/{runtime/runtimePlot.d.ts → plotting/instructions.d.ts} +5 -17
- package/dist-lib/numbl-core/plotting/parseArgsChart.d.ts +94 -0
- package/dist-lib/numbl-core/plotting/parseArgsCommon.d.ts +64 -0
- package/dist-lib/numbl-core/plotting/parseArgsLine.d.ts +103 -0
- package/dist-lib/numbl-core/plotting/parseArgsPatch.d.ts +38 -0
- package/dist-lib/numbl-core/plotting/parseArgsQuiver.d.ts +32 -0
- package/dist-lib/numbl-core/plotting/parseArgsSurface.d.ts +75 -0
- package/dist-lib/numbl-core/plotting/streamline.d.ts +16 -0
- package/dist-lib/{graphics → numbl-core/plotting}/types.d.ts +9 -7
- package/dist-lib/numbl-core/runtime/cow.d.ts +0 -8
- package/dist-lib/numbl-core/runtime/refcount.d.ts +0 -3
- package/dist-lib/numbl-core/runtime/registerSpecial.d.ts +15 -0
- package/dist-lib/numbl-core/runtime/runtime.d.ts +11 -35
- package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +6 -0
- package/dist-lib/numbl-core/runtime/specialBuiltins.d.ts +3 -9
- package/dist-lib/numbl-core/runtime/uihtmlSession.d.ts +5 -13
- package/dist-lib/numbl-core/runtime/utils.d.ts +4 -1
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-lib/numbl-core/workspace/workspace.d.ts +64 -0
- package/dist-lib/vfs/unzipToFiles.d.ts +7 -0
- package/dist-plot-viewer/assets/index-C0fIevlp.js +4504 -0
- package/dist-plot-viewer/index.html +1 -1
- package/dist-site-viewer/assets/index-BDaviCH6.js +4832 -0
- package/dist-site-viewer/assets/numbl-worker-D6m4K2PP.js +5691 -0
- package/dist-site-viewer/index.html +2 -2
- package/native/numbl_addon.cpp +2 -12
- package/native/numbl_addon_common.h +0 -5
- package/package.json +6 -5
- package/dist-browser/hooks/useProjectFiles.d.ts +0 -45
- package/dist-browser/numbl-core/executors/context.d.ts +0 -76
- package/dist-browser/numbl-core/executors/index.d.ts +0 -14
- package/dist-browser/numbl-core/executors/jit/cJitCallExecutor.d.ts +0 -35
- package/dist-browser/numbl-core/executors/jit/cJitLoopExecutor.d.ts +0 -31
- package/dist-browser/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +0 -29
- package/dist-browser/numbl-core/helpers/dummy.d.ts +0 -5
- package/dist-browser/numbl-core/jit/runtime/context.d.ts +0 -23
- package/dist-browser/numbl-core/jit/runtime/inferType.d.ts +0 -10
- package/dist-browser/numbl-core/jit/runtime/value.d.ts +0 -101
- package/dist-browser/numbl-core/jit/workspace/driverPrologue.d.ts +0 -59
- package/dist-browser/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +0 -62
- package/dist-browser/numbl-core/native/bridge-resolve.d.ts +0 -14
- package/dist-browser/numbl-core/runtime/plotUtils.d.ts +0 -336
- package/dist-browser/numbl-core/runtime/specialBuiltinNames.d.ts +0 -2
- package/dist-graphics/graphics/surfColormap.d.ts +0 -2
- package/dist-lib/numbl-core/executors/context.d.ts +0 -76
- package/dist-lib/numbl-core/executors/index.d.ts +0 -14
- package/dist-lib/numbl-core/executors/jit/cJitCallExecutor.d.ts +0 -35
- package/dist-lib/numbl-core/executors/jit/cJitLoopExecutor.d.ts +0 -31
- package/dist-lib/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +0 -29
- package/dist-lib/numbl-core/helpers/dummy.d.ts +0 -5
- package/dist-lib/numbl-core/jit/runtime/context.d.ts +0 -23
- package/dist-lib/numbl-core/jit/runtime/inferType.d.ts +0 -10
- package/dist-lib/numbl-core/jit/runtime/value.d.ts +0 -101
- package/dist-lib/numbl-core/jit/workspace/driverPrologue.d.ts +0 -59
- package/dist-lib/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +0 -62
- package/dist-lib/numbl-core/native/bridge-resolve.d.ts +0 -14
- package/dist-lib/numbl-core/runtime/plotUtils.d.ts +0 -336
- package/dist-lib/numbl-core/runtime/specialBuiltinNames.d.ts +0 -2
- package/dist-plot-viewer/assets/index-YeXWXIxH.js +0 -4504
- package/dist-site-viewer/assets/index-DrtkDG_M.js +0 -4832
- package/dist-site-viewer/assets/numbl-worker-Dz_Z8B9u.js +0 -5327
- package/native/elemwise.cpp +0 -360
- package/native/unary_elemwise.cpp +0 -67
- /package/dist-browser/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
- /package/dist-graphics/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
- /package/dist-lib/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
|
@@ -1,120 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared lowering pipeline.
|
|
3
3
|
*
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
4
|
+
* The registry lowers each unit once, before any executor is asked to
|
|
5
|
+
* propose, and passes the resulting `LoweredStmt` to every executor
|
|
6
|
+
* registered for that shape:
|
|
10
7
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
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).
|
|
8
|
+
* - `top-level` — a script body (`tryLowerTopLevel`), analysed as a
|
|
9
|
+
* synthetic FunctionDef.
|
|
10
|
+
* - `loop` — a For/While stmt (`tryLowerLoop`).
|
|
11
|
+
* - `call` — a user-function call (`tryLowerCall`).
|
|
25
12
|
*
|
|
26
|
-
*
|
|
27
|
-
* cacheKey
|
|
13
|
+
* Lowering here is *classification only*: it analyses inputs/outputs,
|
|
14
|
+
* infers types, and synthesizes a cacheKey. Codegen-feasibility decisions
|
|
15
|
+
* live in each executor's `propose`, which keeps this layer free of
|
|
16
|
+
* dependencies on the JIT compiler (`src/numbl-core/jit`).
|
|
28
17
|
*/
|
|
29
18
|
import type { Stmt } from "../parser/types.js";
|
|
30
19
|
import type { FunctionDef } from "../interpreter/types.js";
|
|
31
20
|
import type { Interpreter } from "../interpreter/interpreter.js";
|
|
21
|
+
import type { JitType } from "../jitTypes.js";
|
|
32
22
|
import { type TopLevelClassification, type CallClassification, type LoopClassification } from "./classification.js";
|
|
33
|
-
/** What `propose()` receives — a discriminated union of the
|
|
34
|
-
*
|
|
35
|
-
|
|
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. */
|
|
23
|
+
/** What `propose()` receives — a discriminated union of the shapes the
|
|
24
|
+
* registry knows how to lower. */
|
|
25
|
+
export type LoweredStmt = TopLevelLoweredStmt | LoopLoweredStmt | CallLoweredStmt;
|
|
39
26
|
export interface TopLevelLoweredStmt {
|
|
40
27
|
readonly kind: "top-level";
|
|
41
28
|
readonly classification: TopLevelClassification;
|
|
42
29
|
}
|
|
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
30
|
export interface LoopLoweredStmt {
|
|
46
31
|
readonly kind: "loop";
|
|
47
32
|
readonly classification: LoopClassification;
|
|
48
33
|
}
|
|
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
34
|
export interface CallLoweredStmt {
|
|
53
35
|
readonly kind: "call";
|
|
54
36
|
readonly classification: CallClassification;
|
|
55
|
-
/** Runtime arg values.
|
|
56
|
-
*
|
|
57
|
-
* stmt-shape executors, the call executor can't re-fetch them
|
|
58
|
-
* from env. */
|
|
37
|
+
/** Runtime arg values. Unlike the env-reading shapes, a call executor
|
|
38
|
+
* cannot re-fetch its inputs from the env. */
|
|
59
39
|
readonly args: readonly unknown[];
|
|
60
40
|
}
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
41
|
+
/** Per-owner type-widening state: the most recent input type signature
|
|
42
|
+
* seen for (owner, slot), where owner is the head Stmt (top-level, loop)
|
|
43
|
+
* or the FunctionDef (call). Classification widens against it so a unit
|
|
44
|
+
* invoked with shifting input types converges to a single specialization
|
|
45
|
+
* rather than thrashing the compile cache. The slot lets one owner host
|
|
46
|
+
* several trackers (one per nargout for calls). WeakMap-scoped so entries
|
|
47
|
+
* are reclaimed when the AST is dropped. */
|
|
48
|
+
export declare class WideningState {
|
|
49
|
+
private readonly last;
|
|
50
|
+
get(owner: object, slot: string): JitType[] | undefined;
|
|
51
|
+
set(owner: object, slot: string, types: readonly JitType[]): void;
|
|
69
52
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
|
|
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 {};
|
|
53
|
+
/** Lower a For/While stmt at `siblings[i]`. Classification needs the
|
|
54
|
+
* post-loop tail of the sibling list (to filter outputs) and the env
|
|
55
|
+
* (for input types). Null when classification declines. */
|
|
56
|
+
export declare function tryLowerLoop(interp: Interpreter, siblings: readonly Stmt[], i: number, widening: WideningState): LoopLoweredStmt | null;
|
|
57
|
+
/** Lower a script body as a whole-scope unit. Null when classification
|
|
58
|
+
* declines. */
|
|
59
|
+
export declare function tryLowerTopLevel(interp: Interpreter, siblings: readonly Stmt[], widening: WideningState): TopLevelLoweredStmt | null;
|
|
60
|
+
/** Lower a user-function call. Null when classification declines (`~`
|
|
61
|
+
* params, type-unknown args, varargin arity mismatch). */
|
|
62
|
+
export declare function tryLowerCall(fn: FunctionDef, args: unknown[], nargout: number, widening: WideningState): CallLoweredStmt | null;
|
|
@@ -1,39 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mode-driven executor registration.
|
|
3
3
|
*
|
|
4
|
-
* `registerExecutorsForOpt(registry, opt)` is the single switch from
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* fallback (see `Registry.dispatch`); it doesn't need to be a
|
|
10
|
-
* registered executor.
|
|
4
|
+
* `registerExecutorsForOpt(registry, opt)` is the single switch from an
|
|
5
|
+
* `--opt` value to a set of registered executors. Each JIT backend
|
|
6
|
+
* contributes one executor per shape (top-level, loop, call); the
|
|
7
|
+
* registry tries them in registration order. The AST interpreter is the
|
|
8
|
+
* registry's last-resort fallback and isn't registered.
|
|
11
9
|
*/
|
|
12
10
|
import type { Registry } from "./registry.js";
|
|
13
|
-
import type {
|
|
14
|
-
/**
|
|
15
|
-
export
|
|
16
|
-
topLevel: Executor;
|
|
17
|
-
loop: Executor;
|
|
18
|
-
call: Executor;
|
|
19
|
-
}
|
|
20
|
-
/** Register the C-JIT executors. Called once at Node bootstrap. */
|
|
21
|
-
export declare function registerCJitExecutors(execs: CJitExecutors): void;
|
|
11
|
+
import type { JitBackend } from "./jit/backend.js";
|
|
12
|
+
/** Register the C backend. Called once at Node bootstrap. */
|
|
13
|
+
export declare function registerCJitBackend(backend: JitBackend): void;
|
|
22
14
|
/** Optimization mode label.
|
|
23
15
|
*
|
|
24
16
|
* - `"0"` — pure AST interpreter, no executors registered.
|
|
25
|
-
* - `"1"` — JS-JIT
|
|
26
|
-
*
|
|
27
|
-
* (
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* so the C path wins where it applies (scalar / tensor numeric
|
|
32
|
-
* types with a wired `nativeBridge`) and the JS path picks up
|
|
33
|
-
* the slack (struct / class / handle / no-cc-available).
|
|
34
|
-
* Requires `cc` on the PATH and `koffi` installed; without
|
|
35
|
-
* either, the C executors decline and `"2"` collapses to the
|
|
36
|
-
* same behaviour as `"1"`. */
|
|
17
|
+
* - `"1"` — JS-JIT for all three shapes.
|
|
18
|
+
* - `"2"` — C-JIT first, JS-JIT as fallback, per shape. C-JIT takes
|
|
19
|
+
* what it can marshal (scalar / tensor numeric types with a wired
|
|
20
|
+
* `nativeBridge`); JS-JIT picks up the rest (struct / class / handle).
|
|
21
|
+
* Without `cc` + `koffi` the C executors decline and `"2"` behaves
|
|
22
|
+
* like `"1"`. */
|
|
37
23
|
export type OptLevel = "0" | "1" | "2";
|
|
38
24
|
export declare const OPT_LEVELS: readonly OptLevel[];
|
|
39
25
|
export declare function isOptLevel(s: string): s is OptLevel;
|
|
@@ -1,115 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Executor registry and dispatch.
|
|
3
3
|
*
|
|
4
|
-
* Three entry points,
|
|
5
|
-
* - `
|
|
6
|
-
*
|
|
4
|
+
* Three entry points, one per lowered shape:
|
|
5
|
+
* - `tryRunWholeScope(siblings, interp)` — whole-script attempt, called
|
|
6
|
+
* once before the per-stmt loop runs.
|
|
7
|
+
* - `dispatch(siblings, i, interp)` — per-stmt dispatch; loops are
|
|
8
|
+
* offered to the loop executors, everything else is interpreted.
|
|
7
9
|
* - `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
10
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* a registered executor.
|
|
11
|
+
* Executors are tried in registration order (at `--opt 2`: C-JIT, then
|
|
12
|
+
* JS-JIT). The first that proposes and runs without bailing wins. The AST
|
|
13
|
+
* interpreter is the last-resort fallback and isn't a registered executor.
|
|
16
14
|
*/
|
|
17
15
|
import type { Stmt } from "../parser/types.js";
|
|
18
16
|
import type { ControlSignal, FunctionDef } from "../interpreter/types.js";
|
|
19
|
-
import type {
|
|
20
|
-
import {
|
|
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;
|
|
17
|
+
import type { Interpreter } from "../interpreter/interpreter.js";
|
|
18
|
+
import type { Executor, RunResult, ShapeKind } from "./types.js";
|
|
45
19
|
export declare class Registry {
|
|
46
|
-
/** Per-stmt executors (loop, call, fuse). */
|
|
47
20
|
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
21
|
private cache;
|
|
60
|
-
private
|
|
61
|
-
/**
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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;
|
|
22
|
+
private widening;
|
|
23
|
+
/** Register an executor for its shape. Order matters: earlier
|
|
24
|
+
* executors are tried first. */
|
|
25
|
+
register<K extends ShapeKind>(executor: Executor<K>): void;
|
|
26
|
+
/** Whether any call executor is registered. */
|
|
27
|
+
get hasCallExecutors(): boolean;
|
|
88
28
|
/** Drop all cached compiled artifacts. Called from
|
|
89
29
|
* `Interpreter.clearAllCaches()` after addpath/rmpath etc. */
|
|
90
30
|
clearCache(): void;
|
|
91
|
-
/**
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
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;
|
|
31
|
+
/** Try to handle the entire script body as a unit. Returns false when
|
|
32
|
+
* no executor took it; the caller then runs the per-stmt loop. */
|
|
33
|
+
tryRunWholeScope(siblings: readonly Stmt[], interp: Interpreter): boolean;
|
|
34
|
+
/** Dispatch the stmt at `siblings[i]`. Returns its control signal. */
|
|
35
|
+
dispatch(siblings: readonly Stmt[], i: number, interp: Interpreter): ControlSignal | null;
|
|
36
|
+
/** Dispatch a user-function call. Returns `{ result }` when an executor
|
|
37
|
+
* handled it, or `null` so the caller runs the interpreter's call path. */
|
|
38
|
+
dispatchCall(fn: FunctionDef, args: unknown[], nargout: number, interp: Interpreter): RunResult;
|
|
113
39
|
/** Run one stmt on the AST interpreter.
|
|
114
40
|
*
|
|
115
41
|
* When that stmt is a loop, the interpreter is about to walk its body,
|
|
@@ -118,39 +44,12 @@ export declare class Registry {
|
|
|
118
44
|
* that for the duration of the body so nested loops and calls can bid for
|
|
119
45
|
* themselves instead of running interpreted all the way down. */
|
|
120
46
|
private interpretFallback;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
private
|
|
129
|
-
/**
|
|
130
|
-
* Dispatch a user-function call. Iterates the same `executors`
|
|
131
|
-
* array as stmt dispatch — call-shape executors filter on
|
|
132
|
-
* `lowered.kind === "call"`. Returns `{ result }` when one of them
|
|
133
|
-
* handles the call, or `null` so the caller (callUserFunction)
|
|
134
|
-
* falls through to the AST interpreter.
|
|
135
|
-
*
|
|
136
|
-
* Reuses a pre-allocated DispatchContext (`callCtx`) to avoid the
|
|
137
|
-
* per-call Map+Set allocation that previously motivated bypassing
|
|
138
|
-
* ctx for call dispatch entirely.
|
|
139
|
-
*/
|
|
140
|
-
dispatchCall(fn: FunctionDef, args: unknown[], nargout: number, interp: import("../interpreter/interpreter.js").Interpreter): CallDispatchResult;
|
|
141
|
-
private runCallCandidate;
|
|
142
|
-
private getCallCtx;
|
|
143
|
-
/**
|
|
144
|
-
* Whole-scope dispatch: try to handle the entire stmt list as a
|
|
145
|
-
* single unit (e.g. JS-JIT top-level). Called by the Interpreter
|
|
146
|
-
* once before the per-stmt loop runs. Returns:
|
|
147
|
-
* - `{ signal }` when a whole-scope executor handled the body.
|
|
148
|
-
* The caller should skip the per-stmt loop entirely.
|
|
149
|
-
* - `null` when no whole-scope executor matched (or all bailed).
|
|
150
|
-
* The caller falls through to per-stmt dispatch.
|
|
151
|
-
*/
|
|
152
|
-
tryRunWholeScope(siblings: readonly Stmt[], interp: import("../interpreter/interpreter.js").Interpreter): WholeScopeResult;
|
|
153
|
-
private finishWholeScope;
|
|
47
|
+
/** Try `executors` in order; return the first success, or null when
|
|
48
|
+
* all declined or bailed. `owner` scopes the compile cache (head Stmt
|
|
49
|
+
* or FunctionDef). */
|
|
50
|
+
private runFirst;
|
|
51
|
+
/** Cache lookup + compile-on-miss + run. A bail (including a compile
|
|
52
|
+
* that declined, which the executor reports as a bail from `run`) is
|
|
53
|
+
* cached so the same (executor, owner, key) is not retried. */
|
|
54
|
+
private execute;
|
|
154
55
|
}
|
|
155
|
-
/** Build a fresh dispatch context. */
|
|
156
|
-
export declare function makeRootContext(interp: import("../interpreter/interpreter.js").Interpreter, registry: Registry): DispatchContext;
|
|
@@ -3,101 +3,39 @@
|
|
|
3
3
|
*
|
|
4
4
|
* See docs/developer_reference/executors.md for the design overview.
|
|
5
5
|
*
|
|
6
|
-
* The interpreter delegates
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Executor interface — they're discriminated via the lowered statement
|
|
12
|
-
* passed to propose().
|
|
6
|
+
* The interpreter delegates whole-script bodies, loops, and user-function
|
|
7
|
+
* calls to a registry of Executors. Each executor handles one lowered shape
|
|
8
|
+
* (`top-level`, `loop`, or `call`). The registry tries the executors
|
|
9
|
+
* registered for a shape in order; the first that proposes and runs
|
|
10
|
+
* without bailing wins, and the AST interpreter handles the rest.
|
|
13
11
|
*/
|
|
14
|
-
import type {
|
|
12
|
+
import type { Interpreter } from "../interpreter/interpreter.js";
|
|
15
13
|
import type { LoweredStmt } from "./lowering.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* input sizes. */
|
|
26
|
-
runNs: number;
|
|
27
|
-
}
|
|
28
|
-
/** Reason a `run` invocation could not complete. The dispatcher
|
|
29
|
-
* invalidates the cache entry and tries the next-best candidate. */
|
|
30
|
-
export interface BailReason {
|
|
31
|
-
message: string;
|
|
32
|
-
cause?: unknown;
|
|
33
|
-
}
|
|
34
|
-
export type RunResult =
|
|
35
|
-
/** Stmt-shape success — handled the head stmt. Registered executors
|
|
36
|
-
* don't produce control signals (break/continue/return); only the
|
|
37
|
-
* hardcoded interpreter fallback in `Registry.dispatch` does.
|
|
38
|
-
* The dispatcher always advances by exactly one stmt on success. */
|
|
39
|
-
{
|
|
40
|
-
ok: true;
|
|
41
|
-
}
|
|
42
|
-
/** Call-shape success — used by executors that handle a
|
|
43
|
-
* CallLoweredStmt. The dispatcher's call entry point
|
|
44
|
-
* (`dispatchCall`) returns this `result` to the caller. */
|
|
45
|
-
| {
|
|
14
|
+
export type ShapeKind = LoweredStmt["kind"];
|
|
15
|
+
export type LoweredOf<K extends ShapeKind> = Extract<LoweredStmt, {
|
|
16
|
+
kind: K;
|
|
17
|
+
}>;
|
|
18
|
+
/** Outcome of `run`. `{ result }` on success (the call's return value
|
|
19
|
+
* for the `call` shape; `undefined` otherwise). `null` is a bail: the
|
|
20
|
+
* registry discards any captured output, caches the bail, and tries
|
|
21
|
+
* the next executor (or the interpreter). */
|
|
22
|
+
export type RunResult = {
|
|
46
23
|
result: unknown;
|
|
47
|
-
} |
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* the executor as if cache had never been touched. Use for
|
|
51
|
-
* shim/wrapper executors whose internal classify logic must
|
|
52
|
-
* re-run on every call (e.g., because the wrapped layer caches
|
|
53
|
-
* on its own keying scheme). Default false. */
|
|
54
|
-
transient?: boolean;
|
|
55
|
-
};
|
|
56
|
-
/** An executor's bid to handle the current dispatch. The dispatcher
|
|
57
|
-
* picks the lowest-cost proposal; the executor's own `data` flows
|
|
58
|
-
* through to compile() and run() unchanged. */
|
|
59
|
-
export interface Proposal<D> {
|
|
60
|
-
/** Opaque per-executor data; passed to compile() and run(). */
|
|
61
|
-
data: D;
|
|
62
|
-
cost: CostEstimate;
|
|
63
|
-
/** Whether this specific proposal's compiled artifact may fail an
|
|
64
|
-
* invariant mid-execution (and thus need re-running by a fallback).
|
|
65
|
-
* The dispatcher filters bail-risk proposals out of contexts marked
|
|
66
|
-
* `requireNoBail`. Per-proposal because a single executor may
|
|
67
|
-
* produce both bail-risky and bail-safe proposals depending on the
|
|
68
|
-
* inputs it sees. */
|
|
69
|
-
bailRisk: boolean;
|
|
70
|
-
}
|
|
71
|
-
export interface Executor<D = unknown, C = unknown> {
|
|
72
|
-
/** Stable identifier for logging, cache keys, and test selection. */
|
|
24
|
+
} | null;
|
|
25
|
+
export interface Executor<K extends ShapeKind = ShapeKind, D = unknown, C = unknown> {
|
|
26
|
+
/** Stable identifier for diagnostics and the compile cache. */
|
|
73
27
|
readonly name: string;
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
* AST directly.
|
|
83
|
-
*
|
|
84
|
-
* Codegen-feasibility decisions (display mode, IO+bail-risk, etc.)
|
|
85
|
-
* belong here — the lowering pipeline produces an IR; the
|
|
86
|
-
* executor decides whether to commit. For lookahead across
|
|
87
|
-
* multiple stmts, use `ctx.peekSibling(offset)` or `ctx.siblings`.
|
|
88
|
-
*
|
|
89
|
-
* Returns null to decline. */
|
|
90
|
-
propose(lowered: LoweredStmt, ctx: DispatchContext): Proposal<D> | null;
|
|
91
|
-
/** Stable cache key projected from the proposal data. Drops
|
|
92
|
-
* volatile bits (e.g., exact scalar values; tensor shape if
|
|
93
|
-
* codegen is shape-agnostic) so unrelated runs of the same code
|
|
94
|
-
* reuse compiled artifacts. */
|
|
28
|
+
/** The lowered shape this executor handles. */
|
|
29
|
+
readonly kind: K;
|
|
30
|
+
/** Decide whether to take this unit. Runs on every dispatch, so it
|
|
31
|
+
* must be cheap. Returns per-executor data passed to `compile` and
|
|
32
|
+
* `run`, or null to decline. */
|
|
33
|
+
propose(lowered: LoweredOf<K>, interp: Interpreter): D | null;
|
|
34
|
+
/** Stable cache key projected from the proposal data. Drops volatile
|
|
35
|
+
* bits (e.g. exact scalar values) so repeated runs reuse artifacts. */
|
|
95
36
|
cacheKey(data: D): string;
|
|
96
|
-
/** Compile to a runnable artifact. Called only on cache miss
|
|
97
|
-
*
|
|
98
|
-
compile(data: D,
|
|
99
|
-
|
|
100
|
-
* or a Bail signalling the cache entry should be invalidated and
|
|
101
|
-
* the next-best candidate tried. */
|
|
102
|
-
run(compiled: C, data: D, ctx: DispatchContext): RunResult;
|
|
37
|
+
/** Compile to a runnable artifact. Called only on cache miss; cached
|
|
38
|
+
* under (executor, owner, cacheKey). */
|
|
39
|
+
compile(data: D, interp: Interpreter): C;
|
|
40
|
+
run(compiled: C, data: D, interp: Interpreter): RunResult;
|
|
103
41
|
}
|
|
@@ -11,12 +11,10 @@ export type ResolvedTarget = {
|
|
|
11
11
|
kind: "classMethod";
|
|
12
12
|
className: string;
|
|
13
13
|
methodName: string;
|
|
14
|
-
compileArgTypes: ItemType[];
|
|
15
14
|
stripInstance: boolean;
|
|
16
15
|
} | {
|
|
17
16
|
kind: "localFunction";
|
|
18
17
|
name: string;
|
|
19
|
-
argTypes: ItemType[];
|
|
20
18
|
source: {
|
|
21
19
|
from: "main";
|
|
22
20
|
} | {
|
|
@@ -33,31 +31,23 @@ export type ResolvedTarget = {
|
|
|
33
31
|
} | {
|
|
34
32
|
kind: "privateFunction";
|
|
35
33
|
name: string;
|
|
36
|
-
argTypes: ItemType[];
|
|
37
34
|
callerFile: string;
|
|
38
35
|
} | {
|
|
39
36
|
kind: "workspaceFunction";
|
|
40
37
|
name: string;
|
|
41
|
-
argTypes: ItemType[];
|
|
42
38
|
} | {
|
|
43
39
|
kind: "jsUserFunction";
|
|
44
40
|
name: string;
|
|
45
|
-
argTypes: ItemType[];
|
|
46
|
-
} | {
|
|
47
|
-
/** mtoc2-only user function (.mtoc2.js). Numbl's interpreter
|
|
48
|
-
* rejects calls to this kind; mtoc2's loader picks up the source
|
|
49
|
-
* from the workspace registry and evaluates it. */
|
|
50
|
-
kind: "mtoc2UserFunction";
|
|
51
|
-
name: string;
|
|
52
|
-
argTypes: ItemType[];
|
|
53
41
|
} | {
|
|
54
42
|
kind: "workspaceClassConstructor";
|
|
55
43
|
className: string;
|
|
56
|
-
argTypes: ItemType[];
|
|
57
44
|
} | {
|
|
58
45
|
kind: "builtin";
|
|
59
46
|
name: string;
|
|
60
47
|
};
|
|
48
|
+
/** The argument type that resolution needs: only an object's class affects
|
|
49
|
+
* which function a name resolves to. */
|
|
50
|
+
export declare function resolutionArgType(v: unknown): ItemType;
|
|
61
51
|
/**
|
|
62
52
|
* Definitively resolve a function name to a single target using the FunctionIndex.
|
|
63
53
|
* Returns null only if the function is truly not found.
|
|
@@ -37,11 +37,6 @@ export declare function maybeComplexTensor(re: Float64Array | Float64Array, shap
|
|
|
37
37
|
* Optionally includes an imaginary diagonal.
|
|
38
38
|
*/
|
|
39
39
|
export declare function buildDiagMatrix(realVals: Float64Array | Float64Array, imagVals: Float64Array | Float64Array | undefined, size: number | [number, number]): ReturnType<typeof RTV.tensor>;
|
|
40
|
-
/**
|
|
41
|
-
* In-place Gauss-Jordan elimination with partial pivoting on a column-major
|
|
42
|
-
* augmented matrix [A | B] of size `rows × totalCols`.
|
|
43
|
-
*/
|
|
44
|
-
export declare function gaussJordanEliminate(aug: Float64Array, rows: number, totalCols: number): void;
|
|
45
40
|
/**
|
|
46
41
|
* Call a registered builtin from within another builtin's apply().
|
|
47
42
|
* Convenience wrapper that includes the caller name in error messages.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile a wildcard pattern to an anchored RegExp.
|
|
3
|
+
*
|
|
4
|
+
* Default (single name): `*` matches any run of characters and `?` any one
|
|
5
|
+
* character, as in `dir('*.m')`, `delete('*.txt')` or `who('a*')`.
|
|
6
|
+
*
|
|
7
|
+
* `paths: true` matches slash-separated paths: `*` and `?` stay within one
|
|
8
|
+
* segment, `**` matches anything, and `**` followed by `/` matches zero or
|
|
9
|
+
* more directory levels (so a double-star prefix before `x.m` also matches a
|
|
10
|
+
* top-level `x.m`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function globToRegExp(pattern: string, opts?: {
|
|
13
|
+
paths?: boolean;
|
|
14
|
+
}): RegExp;
|