Commit graph

28 commits

Author SHA1 Message Date
Fabian cfb9cd8abe Partial custom implementation for arithmethic instructions with read-memory 2020-08-30 19:29:54 -05:00
Fabian 9de2b926a7 Custom implementations for test instruction (only wrapper) 2020-08-30 19:29:54 -05:00
Fabian 9164e0a48f Custom implementation for 'mov r/m, imm' 2020-08-30 19:29:54 -05:00
Fabian 1d24c5952d Cleanup of codegen api 2020-08-30 19:29:54 -05:00
Fabian b0eff6b951 Implement 8-bit memory accesses 2020-08-30 19:29:54 -05:00
Fabian d4d7d236d5 Make all instructions non-faulting; handle faulting case in gen_safe_{read,write} (#44) 2020-08-30 19:29:54 -05:00
Fabian a5cbf53da5 Fix jit in presence of new page fault handling
Makes the following a block boundary:

- push
- Any non-custom instruction that uses modrm encoding
- Any sse/fpu instruction

This commit affects performance negatively. In order to fix this, the
above instructions need to be implemented using custom code generators
for the memory access.
2020-08-30 19:29:53 -05:00
Awal Garg 26fc44a61f simplify push16,32 2020-08-30 19:29:53 -05:00
Awal Garg bfc04b80fb jit E8 2020-08-30 19:29:53 -05:00
Awal Garg b6aa8efc37 merge push16_ss* and push32_ss* functions 2020-08-30 19:29:53 -05:00
Awal Garg 73cbea7d0f call gen_pop{16,32} instead of using interpreted variants, update expect
tests
2020-08-30 19:29:53 -05:00
Awal Garg be7d21e79f add gen_push32_ss{16,32} 2020-08-30 19:29:53 -05:00
Awal Garg 5c2ab56b3b add gen_push16_ss{16,32}
This adds the ImmVal enum type too.
2020-08-30 19:29:53 -05:00
Awal Garg 470246651d move {set,tee}_new_local to builder 2020-08-30 19:29:53 -05:00
Awal Garg 046e399b55 extend Vec<u8> with wasm_util functions 2020-08-30 19:29:53 -05:00
Awal Garg 9b0fdc5019 Improve locals handling
Issuing of locals should only happen with set_new_local and
tee_new_local now
2020-08-30 19:29:53 -05:00
Awal Garg 6f45d5f6ed add gen_safe_write16, jit instr16_C7_0_mem 2020-08-30 19:29:53 -05:00
Awal Garg 7a14a010a8 Improve handling of locals and add tests
- adds alloc_local and free_local
- slightly better wasmgen tests
- caller of gen_safe_write32 is responsible for allocating
  and freeing locals for address and value
- updates expect-tests
2020-08-30 19:29:53 -05:00
Fabian 49961ade7c Remove hintable nops that were refitted for mpx instructions 2020-08-30 19:29:53 -05:00
Fabian 02a7bbb8f7 Implement hintable nops 2020-08-30 19:29:53 -05:00
Awal Garg b3e415cf9f jit inline 0xC3 2020-08-30 19:29:53 -05:00
Awal Garg f944c19748 jit inline 0xE9 2020-08-30 19:29:53 -05:00
Awal Garg 9224fc3878 jit inline 0xEB 2020-08-30 19:29:53 -05:00
Awal Garg c2c5e4f35c jit inline 0xC7
The generated rust code doesn't call read_imm* functions for custom
instructions now for the memory variant branches when both immediate
values and modrm byte is used
2020-08-30 19:29:53 -05:00
Awal Garg 4d622c165e jit inline nop instructions 2020-08-30 19:29:53 -05:00
Fabian 8585af1f89 Use dbg_assert over assert 2020-08-30 19:29:13 -05:00
Fabian bdcaa62f51 Don't generate code for string prefixes 2020-08-30 19:29:13 -05:00
Fabian 3a8d644d75 Port jit to Rust
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
2020-08-30 19:29:13 -05:00