summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanjie Wu <hanjiew@andrew.cmu.edu>2022-12-08 20:10:53 -0500
committerHanjie Wu <hanjiew@andrew.cmu.edu>2022-12-08 20:10:53 -0500
commit78061fe66132bf053ed70c5a1d3cf1d9e2495afa (patch)
tree562ab1ece2df3ae4b37d088bcc284eeecb6ce286
parenta054755b62e660d3d8aba42fdb0a992e2d215599 (diff)
add option to choose from JIT/interpertermain
-rw-r--r--weerun.c11
-rw-r--r--weerun.hpp3
-rw-r--r--weerun_dis.cpp2
-rw-r--r--weerun_jit.cpp4
-rw-r--r--weerun_jit.hpp2
-rw-r--r--weerun_parse.cpp10
6 files changed, 24 insertions, 8 deletions
diff --git a/weerun.c b/weerun.c
index 32b1ff0..dd0105a 100644
--- a/weerun.c
+++ b/weerun.c
@@ -8,6 +8,9 @@
#include "ir.h"
#include "weewasm.h"
+extern uint32_t jit_enable;
+extern uint32_t jit_check;
+
// Initialize the runtime functions.
void init_runtime();
void init_libc_runtime();
@@ -33,6 +36,14 @@ int main(int argc, char* argv[]) {
g_disassemble = 1;
continue;
}
+ if (strcmp(arg, "-no-jit") == 0) {
+ jit_enable = 0;
+ continue;
+ }
+ if (strcmp(arg, "-no-jit-check") == 0) {
+ jit_check = 0;
+ continue;
+ }
byte* start = NULL;
byte* end = NULL;
diff --git a/weerun.hpp b/weerun.hpp
index e9f0ed3..d2f7bb7 100644
--- a/weerun.hpp
+++ b/weerun.hpp
@@ -252,4 +252,5 @@ struct wasm_e_box_t : public wasm_externref_t {
};
extern wasm_instance_t* active_instance;
-extern uint32_t jit;
+extern "C" uint32_t jit_enable;
+extern "C" uint32_t jit_check;
diff --git a/weerun_dis.cpp b/weerun_dis.cpp
index 0e930aa..932b421 100644
--- a/weerun_dis.cpp
+++ b/weerun_dis.cpp
@@ -275,7 +275,7 @@ std::vector<wasm_code_decl_t> decode_vector_code_decl(buffer_t* buf,
std::vector<wasm_code_decl_t> result;
uint32_t num_elem = read_u32leb(buf);
for (uint32_t i = 0; i < num_elem; i++) {
- if (jit != 0) {
+ if (jit_enable != 0) {
result.push_back(decode_code_decl_jit(buf, module));
} else {
result.push_back(decode_code_decl(buf, module));
diff --git a/weerun_jit.cpp b/weerun_jit.cpp
index ece5b4f..542748f 100644
--- a/weerun_jit.cpp
+++ b/weerun_jit.cpp
@@ -212,8 +212,8 @@ void trap() {
std::exit(-1);
}
-wasm_jit_t::wasm_jit_t(uint64_t code_size)
- : CodeGenerator(code_size), enable_check_(true) {
+wasm_jit_t::wasm_jit_t(uint64_t code_size, bool check)
+ : CodeGenerator(code_size), enable_check_(check) {
size_t pos = getSize();
endbr64();
push(rbp);
diff --git a/weerun_jit.hpp b/weerun_jit.hpp
index 509f02c..4c76e0e 100644
--- a/weerun_jit.hpp
+++ b/weerun_jit.hpp
@@ -130,7 +130,7 @@ struct wasm_jit_t : public Xbyak::CodeGenerator {
};
std::vector<block_t> block_stack_;
- wasm_jit_t(uint64_t code_size);
+ wasm_jit_t(uint64_t code_size, bool check);
void compile_instance(wasm_instance_t* ins);
void emit_runtime_functions();
diff --git a/weerun_parse.cpp b/weerun_parse.cpp
index 2e2a5df..3e58d49 100644
--- a/weerun_parse.cpp
+++ b/weerun_parse.cpp
@@ -78,7 +78,11 @@ extern "C" wasm_module_t* parse(buffer_t* buf) {
}
wasm_instance_t* active_instance;
-uint32_t jit = 1;
+
+uint32_t jit_enable = 1;
+uint32_t jit_check = 1;
+
+static uint64_t default_code_size = (1 << 20);
extern "C" wasm_typed_value_t run(const byte* start,
const byte* end,
@@ -88,7 +92,7 @@ extern "C" wasm_typed_value_t run(const byte* start,
wasm_module_t* module = parse(&onstack_buf);
wasm_instance_t* instance = module->create_instance();
wasm_value_t result;
- if (jit != 0) {
+ if (jit_enable != 0) {
result =
instance->run_jit(std::vector<wasm_value_t>(args, args + num_args));
} else {
@@ -334,7 +338,7 @@ wasm_value_t wasm_instance_t::run(std::vector<wasm_value_t> args) {
}
wasm_value_t wasm_instance_t::run_jit(std::vector<wasm_value_t> args) {
- wasm_jit_t jit(1 << 20); // 1M code size
+ wasm_jit_t jit(default_code_size, jit_check != 0); // 1M code size
jit.compile_instance(this);
active_instance = this;