From ef1e3fb133eea8cc7bbea1110d6265fe09ec12c6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 7 Sep 2022 08:40:58 -0700 Subject: [PATCH] Use an unchecked function call for running the lex functions --- lib/src/wasm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/src/wasm.c b/lib/src/wasm.c index b424f0e7..284f1272 100644 --- a/lib/src/wasm.c +++ b/lib/src/wasm.c @@ -644,30 +644,24 @@ bool ts_wasm_store_run_lex_function(TSWasmStore *self, TSStateId state, unsigned assert(lex_val.kind == WASMTIME_FUNCREF); wasmtime_func_t lex_func = lex_val.of.funcref; - const wasmtime_val_t args[2] = { - {.kind = WASMTIME_I32, .of.i32 = LEXER_ADDRESS}, - {.kind = WASMTIME_I32, .of.i32 = state}, + wasmtime_val_raw_t args[2] = { + {.i32 = LEXER_ADDRESS}, + {.i32 = state}, }; - wasmtime_val_t results[1] = { - {.kind = WASMTIME_I32, .of.i32 = 0} - }; - - wasm_trap_t *trap = NULL; - wasmtime_func_call(context, &lex_func, args, 2, results, 1, &trap); + wasm_trap_t *trap = wasmtime_func_call_unchecked(context, &lex_func, args); if (trap) { wasm_message_t message; wasm_trap_message(trap, &message); printf("error calling lex function index %u: %s\n", function_index, message.data); abort(); } - assert(results[0].kind == WASM_I32); memcpy( &self->current_lexer->lookahead, &memory_data[LEXER_ADDRESS], sizeof(self->current_lexer->lookahead) + sizeof(self->current_lexer->result_symbol) ); - return results[0].of.i32; + return args[0].i32; } bool ts_wasm_store_run_main_lex_function(TSWasmStore *self, TSStateId state) {