The following files and functions were ported:
- jit.c
- codegen.c
- _jit functions in instructions*.c and misc_instr.c
- generate_{analyzer,jit}.js (produces Rust code)
- jit_* from cpu.c
And the following data structures:
- hot_code_addresses
- wasm_table_index_free_list
- entry_points
- jit_cache_array
- page_first_jit_cache_entry
Other miscellaneous changes:
- Page is an abstract type
- Addresses, locals and bitflags are unsigned
- Make the number of entry points a growable type
- Avoid use of global state wherever possible
- Delete string packing
- Make CachedStateFlags abstract
- Make AnalysisType product type
- Make BasicBlockType product type
- Restore opcode assertion
- Set opt-level=2 in debug mode (for test performance)
- Delete JIT_ALWAYS instrumentation (now possible via api)
- Refactor generate_analyzer.js
- Refactor generate_jit.js
This changes the strategy of finding basic blocks. Instead of starting
at a single address (the current instruction pointer, which was found to
be hot), we record all entries of control flow per page while
interpreting code; we also determine hotness per page. Once a page is
hot, all entries that were recorded in this page are compiled into a
single wasm module.
The code generator didn't need much changes, as it already supported
multiple entry points.
- How often do_many_cycles is run and how much time it takes per call
- How many entries are currently being compiled ("pending")
- Relative frequencies of opcodes
- Reason for interpreting code (not hot, at end of page, pending or no
block boundary)
- Number of compiled basic blocks and entry blocks
- How many pages and entries are invalidated
- How often cycle_internal, do_many_cycles and do_run are called
- introduce multiple entry points per compiled wasm module, by passing
the initial state to the generated function.
- continue analysing and compiling after instructions that change eip, but
will eventually return to the next instruction, in particular CALLs
(and generate an entry point for the following instruction)
This commit is incomplete in the sense that the container will crash
after some time of execution, as wasm table indices are never freed