Fix nasm test with forced jit
This is a (partial) fix for #8. It manually forces compilation of the first set of basic blocks in the nasm tests, waits for the blocks to be compiled and then runs the test. It doesn't make use of the fragile compile-time machinery to force compilation. Analysis currently doesn't follow execution after the popf instructions, which is included in most tests. It has been manually verified that tests pass when the popf instruction is compiled, and this limitation will be lifted soon. Analysis also doesn't follow through call and return instructions, so nasm tests can't currently test these in their compiled form.
This commit is contained in:
parent
5886077633
commit
f2274e0a60
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
./tests/nasm/create_tests.js
|
||||
make -j $(nproc --all) JIT_ALWAYS=1 nasmtests
|
||||
make -j $(nproc --all) nasmtests-force-jit
|
||||
|
|
5
Makefile
5
Makefile
|
@ -277,6 +277,11 @@ nasmtests: build/libv86-debug.js build/v86-debug.wasm
|
|||
$(NASM_TEST_DIR)/gen_fixtures.js
|
||||
$(NASM_TEST_DIR)/run.js
|
||||
|
||||
nasmtests-force-jit: build/libv86-debug.js build/v86-debug.wasm
|
||||
$(MAKE) -C $(NASM_TEST_DIR) all
|
||||
$(NASM_TEST_DIR)/gen_fixtures.js
|
||||
$(NASM_TEST_DIR)/run.js --force-jit
|
||||
|
||||
jitpagingtests: build/libv86-debug.js build/v86-debug.wasm
|
||||
$(MAKE) -C tests/jit-paging test-jit
|
||||
./tests/jit-paging/run.js
|
||||
|
|
|
@ -1304,6 +1304,11 @@ CPU.prototype.codegen_finalize = function(wasm_table_index, start, end, first_op
|
|||
|
||||
// The following will throw if f isn't an exported function
|
||||
this.wm.imports["env"].table.set(wasm_table_index, f);
|
||||
|
||||
if(this.test_hook_did_finalize_wasm)
|
||||
{
|
||||
this.test_hook_did_finalize_wasm(code);
|
||||
}
|
||||
});
|
||||
|
||||
if(DEBUG)
|
||||
|
|
|
@ -1380,7 +1380,8 @@ static void jit_generate(uint32_t phys_addr, uint32_t page_dirtiness)
|
|||
void jit_force_generate_unsafe(uint32_t phys_addr)
|
||||
{
|
||||
*instruction_pointer = phys_addr;
|
||||
jit_generate(phys_addr, 0);
|
||||
uint32_t page_dirtiness = group_dirtiness[phys_addr >> DIRTY_ARR_SHIFT];
|
||||
jit_generate(phys_addr, page_dirtiness);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ const TEST_DIR = __dirname + "/build/";
|
|||
const DONE_MSG = "DONE";
|
||||
const TERMINATE_MSG = "DONE";
|
||||
|
||||
const FORCE_JIT = process.argv.includes("--force-jit");
|
||||
|
||||
const MASK_ARITH = 1 | 1 << 2 | 1 << 4 | 1 << 6 | 1 << 7 | 1 << 11;
|
||||
|
||||
try {
|
||||
|
@ -230,7 +232,24 @@ else {
|
|||
cpu.reset_memory();
|
||||
cpu.load_multiboot(fs.readFileSync(TEST_DIR + current_test.img_name).buffer);
|
||||
|
||||
emulator.run();
|
||||
if(FORCE_JIT)
|
||||
{
|
||||
cpu.jit_force_generate_unsafe(cpu.instruction_pointer[0]);
|
||||
|
||||
cpu.test_hook_did_finalize_wasm = function()
|
||||
{
|
||||
cpu.test_hook_did_finalize_wasm = null;
|
||||
|
||||
// don't synchronously call into the emulator from this callback
|
||||
setTimeout(() => {
|
||||
emulator.run();
|
||||
}, 0);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
emulator.run();
|
||||
}
|
||||
}
|
||||
|
||||
let loaded = false;
|
||||
|
|
Loading…
Reference in a new issue