diff options
author | Wojciech Kosior <kwojtus@protonmail.com> | 2020-09-21 11:53:13 +0200 |
---|---|---|
committer | Wojciech Kosior <kwojtus@protonmail.com> | 2020-09-21 11:53:13 +0200 |
commit | ca4e5c1cca9f0e6db5f564e6786a356bcdffb956 (patch) | |
tree | d0d53f9f13bf29271f8207996707d9cd6a7bb76b /tools/translate.c | |
parent | 6dfb056f484e98f627d16a44eca8f6fff87f5f0e (diff) | |
download | AGH-engineering-thesis-ca4e5c1cca9f0e6db5f564e6786a356bcdffb956.tar.gz AGH-engineering-thesis-ca4e5c1cca9f0e6db5f564e6786a356bcdffb956.zip |
put function call wasm_compile test in separate bench
Diffstat (limited to 'tools/translate.c')
-rw-r--r-- | tools/translate.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/translate.c b/tools/translate.c index ee6ea99..4361d6f 100644 --- a/tools/translate.c +++ b/tools/translate.c @@ -3,6 +3,7 @@ /* WebAssembly opcodes */ #define WASM_END 0x0B +#define WASM_CALL 0x10 #define WASM_LOCAL_GET 0x20 #define WASM_I32_LOAD 0x28 #define WASM_I32_LOAD8_S 0x2C @@ -63,6 +64,26 @@ int translate(FILE *handle, struct function *function, struct module *module) goto fail; matched = 1; + } else if (wasm_opcode == WASM_CALL) { + uint32_t funcidx; + struct instruction **target; + + if (leb_u32(handle, &funcidx)) { + PRERR(MSG_BAD_NUM); + goto fail; + } + + if (funcidx >= module->functions_count) { + PRERR(MSG_BAD_IDX("funcidx")); + goto fail; + } + + target = &module->functions[funcidx].translated_body; + + if (i_call(ptr(target), &expr)) + goto fail; + + matched = 1; } else if (wasm_opcode <= WASM_I64_STORE32 && wasm_opcode >= WASM_I32_LOAD) { uint32_t align, offset; |