Commit graph

182 commits

Author SHA1 Message Date
Fabian ca36680d52 PAGE_FAULT is u8 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 8051db8ac6 Access from allocated memory 2020-08-30 19:29:53 -05:00
Fabian 1a96072840 Use u8 for page_fault 2020-08-30 19:29:53 -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
Fabian 1faf8ccc86 Allocate memory via Rust instead of ahead-of-time 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 4d7f87c515 avoid local in gen_safe_read_write 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 2f5b1311c6 re-add gen_safe_read_write 2020-08-30 19:29:53 -05:00
Awal Garg fb9a6e714a remove unused codegen functions (register related) 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 bad796b9eb deduplicate safe_{read,write}* functions 2020-08-30 19:29:53 -05:00
Awal Garg 22e570e1eb remove commented out code 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 57d79c256d remove unused local 2020-08-30 19:29:53 -05:00
Awal Garg 07630b3947 fix comment 2020-08-30 19:29:53 -05:00
Awal Garg 5f22e393ff jit safe_read16 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 bdef74eced Generate code for task_switch_test{,_mmx}, use non-raising exceptions 2020-08-30 19:29:53 -05:00
Awal Garg 56714600eb has_flat_segmentation optimization 2020-08-30 19:29:53 -05:00
Awal Garg 8303948954 use local for storing {e}sp 2020-08-30 19:29:53 -05:00
Awal Garg b3e415cf9f jit inline 0xC3 2020-08-30 19:29:53 -05:00
Awal Garg 9224fc3878 jit inline 0xEB 2020-08-30 19:29:53 -05:00
Fabian 8585af1f89 Use dbg_assert over assert 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