ztcl::wasm jit
Reads or sets the use of the JIT tier.
ztcl::wasm jit ?BOOLEAN?
Description
On x86-64 Linux and macOS, the engine compiles a module to machine code at its first call, and the calls run in that code; elsewhere the interpreter of the engine runs. The JIT gives the same results, traps, compute units, and NaN bits as the interpreter. With BOOLEAN it turns the JIT on or off for the calls of the interpreter. It gives 1 when the JIT is on, so on a platform with no JIT it gives 0 also after ztcl::wasm jit 1.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| BOOLEAN | boolean | none | 1 to use the JIT, 0 to use the interpreter. |
Returns
1 or 0.
Examples
Each example of this page runs after
package require ztcl::wasm
# (func (export "add") (param i32 i32) (result i32))
set m [ztcl::wasm new [binary decode hex 0061736d0100000001070160027f7f017f030201000707010361646400000a09010700200020016a0b]]
set w [ztcl::wasm instantiate $m]
# (memory (export "memory") 1 2), the bytes "hi" at 16, the globals "g" (mut i32 5) and "k" (i64 7), and (func (export "div") (param i32 i32) (result i32)) of i32.div_s
set mem [ztcl::wasm new [binary decode hex 0061736d0100000001070160027f7f017f03020100050401010102060b027f0141050b7e0042070b071804066d656d6f7279020001670300016b03010364697600000a09010700200020016d0b0b09010041100b03686900]]
.
% ztcl::wasm jit 0
0
% string is boolean [ztcl::wasm jit]
1
Errors
% ztcl::wasm jit x
expected boolean value but got "x"
-errorcode NONE
% ztcl::wasm jit 1 2
wrong # args: should be "ztcl::wasm jit ?boolean?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1
- Compute cost
- One compute unit for each call and each loop pass of the wasm code.