wasm_jit (wasm v0.16.0)
View SourceWhen a module gets compiled, and how a call reaches the result.
You get here from wasm, on the path an invocation takes. Everything here is a policy
decision on top of two mechanisms that already exist: wasm_core generates and
compiles, and wasm_code_slots decides which module name the result may be
loaded into and when that name may be reused.
Where things are
| you want | look at |
|---|---|
| what a call runs: compiled code or the interpreter | entry/3, and %%% api |
| adopting a module another instance already compiled | maybe_adopt/3, adopt/2 |
| the per-instance compiled entry, and its lease | cached_entry/3, compiled/3, hashed_entry/6, generational_entry/4 |
| asking for a compile when a call returns | after_call/2, ask/2 |
| which functions get compiled | wanted/2, unit/2, ran/1 |
| starting the work off the calling process | spawn_compile/2, start_compiler/0, compiler_loop/0 |
| one compile, from generation to publish | compile/4, generate/5, build/9, publish_all/5 |
| splitting a compile into shards | shard_count/2, shards/1, pmap/2 |
| heap and concurrency limits on a compile | compile_limits/0, max_heap_words/0, concurrency/2 |
| waiting until an instance has compiled code | await/2 |
| counting every outcome | record/3, counts/0, reset_counts/0 |
| diagnostics and the generated source | diagnostics/0, dump/1 |
| an instance letting go of its slot | release/1 |
| compiled code built ahead of time, and loading it before the first call | precompile/3, preload_unit/2, compiled_functions/1, executed/1, in %%% ahead of time |
The compile path runs under these banners, in this order: %%% asking for a compile (the ask, and starting a compiler), %%% the compiler process,
%%% generation, %%% admission and build (the compile budget, the code
cache, publishing), %%% splitting into units, %%% limits, %%% shards
and %%% running the units, and the artifact.
Off by default
Compiled code is opt-in, #{compile => true} in an instance's limits, the way
fuse => false already works. Turning it on by default is a separate decision
with its own gates: differential trap and side-effect tests, an enforced
compile-time and code-size limit, and a scheduler-responsiveness measurement
while a generated loop runs.
Every failure interprets
A module the generator refuses, a slot pool that is exhausted, another process
already compiling the same module, a finite fuel budget, a compile error, a
compiler over compile_max_heap_words: all of them mean run the interpreter,
and none of them is an error. That is what
makes the tier safe to enable at all, and it is also what makes a green test
run prove nothing on its own -- see counts/0 and the compile_force option,
which exist so that a conformance run can say generated code actually ran.
Fuel
Fuel is charged at every loop back edge, and threading a budget through a compiled loop gives back what compiling it bought. So an invocation with finite fuel is interpreted, checked once here rather than in the generated code.
Three options for a conformance run, and none for production
The defaults are what an embedder wants: compile in the background, compile only what ran, and interpret anything the generator could not handle. Each of those is exactly wrong for a test that means to check generated code, because each of them lets the test pass without any generated code having run.
| Option | Default | What it changes |
|---|---|---|
compile_sync | false | Compile on the calling process, so the next call is already compiled rather than probably compiled. |
compile_whole | false | Compile every eligible function, not only the ones that have run. |
compile_force | false | Raise on a compile error instead of interpreting, so a generator bug fails rather than hides. |
compile_whole in particular is a conformance option and not a tuning knob.
Compiling every function of QuickJS measured 107 s in the run that first
moved it, against 15.2 s for the 223-function hot set in four units,
and it spends most of fifteen megabytes of code space on functions the
workload never calls. Specification modules are a few functions each, which is
why it is affordable there and nowhere else.
wasm_spec_SUITE's compiled phase sets all three, and then asserts counts/0
moved, because even with all three a refusal still interprets.
Summary
Functions
The version of generated code this runtime makes and accepts, which a unit
file records: scripts/wasm-units.escript compares it to decide a unit is
current.
Called once at the end of an outermost invocation, to decide about compiling.
Wait for this instance's module to finish compiling, or give up.
The node's whole compile budget in heap words, or 0 for none.
Every bound the compiled tier applies to a request, so a caller can ask rather
than infer it from a refusal. wasm_core:limits/0 is the same idea for the
bounds a single unit has.
The function indexes the tier has compiled for the module behind Handle, a
handle from wasm:load/1, across every unit it is split into.
A compiler, waiting to be told what to compile. Started by wasm_jit_sup.
How much has been compiled, and how often generated code was entered.
Why the last compiles that did not happen did not happen.
The Core Erlang this instance's module would compile to, as text.
As dump/1, for one function index.
Make the call-path counters now, at application start, rather than on the first
compiled call. Two processes making them at once would each keep an array and
one of them would count into the one counts/0 does not read.
The entry to run this invocation through: generated code, or the one given.
The function indexes the calling process has run in Inst, for a guest whose
calls never return and so never reach the tier: ask in each process that runs
it and take the union, for wasm:precompile/2's functions.
The slot, 0 to 15, M's compiled code is built for when nothing asks.
The heap ceiling a compile would be given, in words, or 0 for none.
The bounded form of a compile failure's reason, as diagnostics/0 keeps it.
Compile M's functions into one unit for slot Slot (0 to 15), as the bytes
of a unit file (wasm_unit_file), without an instance.
Load a unit file's bytes into the slot it names and publish it, with Owner
holding a lease on it while it lives. wasm:preload/1 is the way in.
Record one call the interpreter made into generated code.
Give back the slot lease this instance took, if it took one.
For tests, which need to count what one run did rather than what a node did.
How many units this many functions are split into.
How many units this instance's module is actually resident in.
What the generator needs to know about indirect calls in Inst's module.
Types
-type annotated() :: {Height :: non_neg_integer(), instr()} | {Height :: non_neg_integer(), Base :: non_neg_integer(), instr()}.
-type externtype() :: {func, typeidx()} | {table, #tabletype{limits :: #limits{min :: non_neg_integer(), max :: undefined | non_neg_integer(), shared :: boolean(), index_type :: i32 | i64}, elemtype :: reftype(), init :: undefined | [instr()]}} | {mem, #memtype{limits :: #limits{min :: non_neg_integer(), max :: undefined | non_neg_integer(), shared :: boolean(), index_type :: i32 | i64}}} | {global, #globaltype{valtype :: valtype(), mut :: mut()}} | {tag, #tagtype{type :: typeidx()}}.
-type funcidx() :: non_neg_integer().
-type heaptype() :: func | extern | exn | any | eq | i31 | struct | array | nofunc | noextern | noexn | none | {type, typeidx()}.
-type memidx() :: non_neg_integer().
-type mut() :: const | var.
-type numtype() :: i32 | i64 | f32 | f64.
-type reftype() :: {ref, null | nonull, heaptype()}.
-type tableidx() :: non_neg_integer().
-type typeidx() :: non_neg_integer().
-type vectype() :: v128.
Functions
-spec abi() -> pos_integer().
The version of generated code this runtime makes and accepts, which a unit
file records: scripts/wasm-units.escript compares it to decide a unit is
current.
-spec after_call(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}, map()) -> ok.
Called once at the end of an outermost invocation, to decide about compiling.
At the end, and that is the whole point. Which functions a workload runs is recorded for free by the lowering cache, and at the start of a call that record is empty: an instance asking then compiles all 1666 of QuickJS's functions because it cannot yet know that 223 of them is the answer. Asking here, when the invocation has finished and the record is full, is the difference between compiling what exists and compiling what ran.
Adopting a module somebody else compiled happens here too, so entry/3 on the
hot path is one atomics read and nothing else.
-spec await(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}, timeout()) -> ok | timeout.
Wait for this instance's module to finish compiling, or give up.
Compilation is asynchronous, so a caller that wants to measure compiled code, or
to warm an instance before serving with it, needs to know when it has arrived.
Answers ok as soon as the instance has adopted a slot.
-spec compile_budget_heap_words() -> non_neg_integer().
The node's whole compile budget in heap words, or 0 for none.
A heap ceiling bounds one compiler; sixteen of them under it is not a bound on the node. This is what the whole node may have in flight at once. Off by default, and like the ceiling it refuses rather than queues: a request that does not fit interprets and asks again at the next hot call.
-spec compile_limits() -> #{atom() => non_neg_integer()}.
Every bound the compiled tier applies to a request, so a caller can ask rather
than infer it from a refusal. wasm_core:limits/0 is the same idea for the
bounds a single unit has.
-spec compiled_functions(wasm_module_cache:handle()) -> {ok, [non_neg_integer()]} | {error, not_compiled}.
The function indexes the tier has compiled for the module behind Handle, a
handle from wasm:load/1, across every unit it is split into.
Run your representative requests on a development node with the tier on, wait
for it (await/2), and pass this to wasm:precompile/2 as functions: the
unit you ship is then the one a warm node would have built. {error, not_compiled} when nothing is compiled for it.
-spec compiler_loop() -> ok.
A compiler, waiting to be told what to compile. Started by wasm_jit_sup.
This process owns the slot reservation for as long as it holds one, which is why the work happens here rather than in a long-lived pool worker: the slot is released when its owner dies, and that is what makes a compiler that crashes or is killed cost nothing but the work it had done.
The wait has a deadline for the same reason: a child whose sender died between
start_child and the message would otherwise sit in the tree for ever.
-spec counts() -> #{atom() => non_neg_integer()}.
How much has been compiled, and how often generated code was entered.
Why the last compiles that did not happen did not happen.
counts/0 says how many were refused or failed; this says what they were.
Oldest first, a bounded number of them, and every reason normalised to a
bounded shape: a {compile, _} from the OTP compiler carries its whole
diagnostic list and an exit reason carries a stacktrace, and neither belongs in
a table that is read back for diagnosis.
crashed compiles are counted and not listed, for the same reason.
Answers [] rather than raising when the table is not there, which is what a
node that loaded these modules without restarting the application has.
-spec dump(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}) -> iodata() | {error, term()}.
The Core Erlang this instance's module would compile to, as text.
Read it when you have changed the generator and want to see what came out. A
differential test tells you a lowering is wrong; this tells you how. Nothing in
the tier depends on it and it compiles nothing: it builds the same unit
generate/5 builds and stops one step earlier.
{ok, I} = wasm:instantiate(M, #{}, #{}),
io:format("~s~n", [wasm_jit:dump(I)]).Answers {error, nothing_to_compile} when the generator refuses every function
of the module, which is the same condition that makes the tier decline it.
-spec dump(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}, all | non_neg_integer()) -> iodata() | {error, term()}.
As dump/1, for one function index.
Real modules are large and a maintainer is usually looking at one function.
wasm_core names functions by position in the unit rather than by module
index, so a whole-module dump means counting; this takes the index the module
uses.
-spec ensure_counts() -> ok.
Make the call-path counters now, at application start, rather than on the first
compiled call. Two processes making them at once would each keep an array and
one of them would count into the one counts/0 does not read.
-spec entry(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}, map(), fun()) -> fun().
The entry to run this invocation through: generated code, or the one given.
Called once per outermost invocation. Everything it can answer cheaply it answers first -- the tier being off, or fuel being finite -- so a workload that does not use this pays one map lookup.
-spec executed(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}) -> [non_neg_integer()].
The function indexes the calling process has run in Inst, for a guest whose
calls never return and so never reach the tier: ask in each process that runs
it and take the union, for wasm:precompile/2's functions.
Empty for a module of 256 functions or fewer, whose functions are prepared up front rather than on first call: there it says nothing about what ran.
-spec home_slot(#module{identity :: undefined | {sha256, binary()} | reference(), types :: [#subtype{final :: boolean(), supers :: [typeidx()], body :: #functype{params :: [valtype()], results :: [valtype()]} | #structtype{fields :: [#fieldtype{type :: valtype() | i8 | i16, mut :: mut()}]} | #arraytype{field :: #fieldtype{type :: valtype() | i8 | i16, mut :: mut()}}}], rec_groups :: [{non_neg_integer(), non_neg_integer()}], imports :: [#import{module :: binary(), name :: binary(), desc :: externtype()}], funcs :: [#func{type :: typeidx(), locals :: [valtype()], body :: [instr()] | {validated, [annotated()]}}], tables :: [#tabletype{limits :: #limits{min :: non_neg_integer(), max :: undefined | non_neg_integer(), shared :: boolean(), index_type :: i32 | i64}, elemtype :: reftype(), init :: undefined | [instr()]}], mems :: [#memtype{limits :: #limits{min :: non_neg_integer(), max :: undefined | non_neg_integer(), shared :: boolean(), index_type :: i32 | i64}}], tags :: [#tagtype{type :: typeidx()}], globals :: [#global{type :: #globaltype{valtype :: valtype(), mut :: mut()}, init :: [instr()]}], exports :: [#export{name :: binary(), desc :: {func | table | mem | global | tag, non_neg_integer()}}], start :: undefined | funcidx(), elems :: [#elem{type :: reftype(), init :: [[instr()]], mode :: passive | declarative | {active, tableidx(), [instr()]}}], datas :: [#data{init :: binary(), mode :: passive | {active, memidx(), [instr()]}}], data_count :: undefined | non_neg_integer(), customs :: [{binary(), binary()}]}) -> 0..15.
The slot, 0 to 15, M's compiled code is built for when nothing asks.
-spec max_heap_words() -> non_neg_integer().
The heap ceiling a compile would be given, in words, or 0 for none.
Reads compile_max_heap_words and reports the effective value, so a caller is
told what the tier would actually apply rather than what the code defaults to.
Asking never reports: it does not log, move a counter, or clear what
wasm_code_slots is holding, because a question must not have the side effects
of a compile.
The bounded form of a compile failure's reason, as diagnostics/0 keeps it.
Bounded by structure, not by formatting. io_lib:format("~P", [R, 8]) bounds
depth: a flat million-character list at depth 8 still formats to a million
bytes, and truncating afterwards has already built the whole thing. So the two
shapes that carry unbounded data lose it here -- the OTP compiler's diagnostics
become their count, an exit reason becomes its tag -- and anything unrecognised
becomes an atom and nothing else.
Exported because it is the guarantee diagnostics/0 rests on, and a guarantee
that cannot be checked directly is not one.
-spec precompile(#module{identity :: undefined | {sha256, binary()} | reference(), types :: [#subtype{final :: boolean(), supers :: [typeidx()], body :: #functype{params :: [valtype()], results :: [valtype()]} | #structtype{fields :: [#fieldtype{type :: valtype() | i8 | i16, mut :: mut()}]} | #arraytype{field :: #fieldtype{type :: valtype() | i8 | i16, mut :: mut()}}}], rec_groups :: [{non_neg_integer(), non_neg_integer()}], imports :: [#import{module :: binary(), name :: binary(), desc :: externtype()}], funcs :: [#func{type :: typeidx(), locals :: [valtype()], body :: [instr()] | {validated, [annotated()]}}], tables :: [#tabletype{limits :: #limits{min :: non_neg_integer(), max :: undefined | non_neg_integer(), shared :: boolean(), index_type :: i32 | i64}, elemtype :: reftype(), init :: undefined | [instr()]}], mems :: [#memtype{limits :: #limits{min :: non_neg_integer(), max :: undefined | non_neg_integer(), shared :: boolean(), index_type :: i32 | i64}}], tags :: [#tagtype{type :: typeidx()}], globals :: [#global{type :: #globaltype{valtype :: valtype(), mut :: mut()}, init :: [instr()]}], exports :: [#export{name :: binary(), desc :: {func | table | mem | global | tag, non_neg_integer()}}], start :: undefined | funcidx(), elems :: [#elem{type :: reftype(), init :: [[instr()]], mode :: passive | declarative | {active, tableidx(), [instr()]}}], datas :: [#data{init :: binary(), mode :: passive | {active, memidx(), [instr()]}}], data_count :: undefined | non_neg_integer(), customs :: [{binary(), binary()}]}, map(), 0..15) -> {ok, binary(), #{compiled := non_neg_integer(), left_out := non_neg_integer()}} | {error, atom(), map()}.
Compile M's functions into one unit for slot Slot (0 to 15), as the bytes
of a unit file (wasm_unit_file), without an instance.
M is a module from the cache, with a content hash. Opts takes functions,
all or a list of function indexes, and quality, full or baseline. A
function the generator refuses is left out; Info counts both. It claims no
slot and loads nothing. wasm:precompile/2 is the documented way in and picks
the slot; the build script calls this to choose another.
Load a unit file's bytes into the slot it names and publish it, with Owner
holding a lease on it while it lives. wasm:preload/1 is the way in.
A file built for another runtime, a slot something else holds, or a load the code server refuses is a miss, and the module interprets until the tier compiles it, as it would have without the file.
-spec reentered() -> ok.
Record one call the interpreter made into generated code.
A diagnostic on a hot path, and it is here rather than inlined so that its cost is one place to look when it is time to decide whether to keep it. Without it a green run says nothing: re-entry that silently never happens looks exactly like re-entry that happens and does not pay.
-spec release(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}) -> ok.
Give back the slot lease this instance took, if it took one.
Called from wasm:destroy/1 beside the memory, table and global releases, and
for the same reason: the lease names the instance, so it has to go when the
instance does. Until this existed it went only when the owning process died,
and a long-lived process serving many distinct modules pinned the slots one at
a time until the pool was gone and every later module interpreted for the life
of the node. wasm_code_slots's moduledoc describes exactly this shape as the
usage it expects and nothing called it.
Idempotent, because destroy/1 is: releasing a lease that is not there is a
no-op in wasm_code_slots, which is the same property that makes a double
release of a memory harmless.
-spec reset_counts() -> ok.
For tests, which need to count what one run did rather than what a node did.
-spec shard_count(non_neg_integer(), map()) -> pos_integer().
How many units this many functions are split into.
Pure, and exported so the policy can be asserted without running a compile.
wasm_core draws every name a unit can use from a pre-generated pool, because
nothing a guest supplies may become an atom, and that pool is max_funs deep.
A unit past it is refused, so the split exists to keep each unit under it and
for no other reason: a guest that fits in one unit stays in one unit and its
generated code is unchanged.
The answer is the number of bins requested. bins/3 drops empty ones, so
asking for four on a one-function unit gives one actual part; shards/1 is
what reports the actual count.
-spec shards(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}) -> non_neg_integer().
How many units this instance's module is actually resident in.
Zero when nothing is compiled, and otherwise the length of the contiguous chain
starting at shard one. shard_count/2 says how many units were asked for;
this says how many there are, which is what an acceptance run has to assert
rather than infer from a wall time.
-spec tsigs(#inst{id :: reference(), ckpt :: reference(), entry_key :: undefined | reference(), types :: tuple(), funcs :: tuple(), exports :: #{binary() => {func | table | mem | global, non_neg_integer()}}, elems :: tuple(), datas :: tuple(), globaltypes :: tuple(), tags :: tuple(), canon :: tuple(), fields :: tuple(), kinds :: tuple(), supers :: tuple(), heap :: undefined | wasm_heap:heap(), identity :: undefined | {sha256, binary()} | reference(), module_handle :: undefined | wasm_module_cache:handle(), leases :: undefined | atomics:atomics_ref(), store :: term(), version :: term(), limits :: map(), ctx :: term(), shared_ir :: undefined | {wasm_ir_shared, binary(), term()}}) -> map().
What the generator needs to know about indirect calls in Inst's module.
An indirect call is typed by the type it names, not by any function, since
which function it reaches is not known until it runs: type index =>
{NParams, NResults}. Beside those, {canon, TypeIdx} => the type's
canonical identity, and {table, TableIdx} => the contents of each table
that cannot change after instantiation, so a call_indirect through one can
be resolved once: a candidate from #ctx.table_candidates that no function of
the module writes. All of it follows from the module alone. Exported for
tests, which build units by hand.