| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502 |
- /*
- * Copyright (C) 2019 Intel Corporation. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- */
- #include "wasm_native.h"
- #include "wasm_runtime_common.h"
- #include "bh_log.h"
- #if WASM_ENABLE_INTERP != 0
- #include "../interpreter/wasm_runtime.h"
- #endif
- #if WASM_ENABLE_AOT != 0
- #include "../aot/aot_runtime.h"
- #endif
- #if WASM_ENABLE_THREAD_MGR != 0
- #include "../libraries/thread-mgr/thread_manager.h"
- #endif
- static NativeSymbolsList g_native_symbols_list = NULL;
- #if WASM_ENABLE_LIBC_WASI != 0
- static void *g_wasi_context_key;
- #endif /* WASM_ENABLE_LIBC_WASI */
- uint32
- get_libc_builtin_export_apis(NativeSymbol **p_libc_builtin_apis);
- #if WASM_ENABLE_SPEC_TEST != 0
- uint32
- get_spectest_export_apis(NativeSymbol **p_libc_builtin_apis);
- #endif
- uint32
- get_libc_wasi_export_apis(NativeSymbol **p_libc_wasi_apis);
- uint32_t
- get_wasi_nn_export_apis(NativeSymbol **p_libc_wasi_apis);
- uint32
- get_base_lib_export_apis(NativeSymbol **p_base_lib_apis);
- uint32
- get_ext_lib_export_apis(NativeSymbol **p_ext_lib_apis);
- #if WASM_ENABLE_LIB_PTHREAD != 0
- bool
- lib_pthread_init();
- void
- lib_pthread_destroy();
- uint32
- get_lib_pthread_export_apis(NativeSymbol **p_lib_pthread_apis);
- #endif
- #if WASM_ENABLE_LIB_WASI_THREADS != 0
- bool
- lib_wasi_threads_init(void);
- void
- lib_wasi_threads_destroy(void);
- uint32
- get_lib_wasi_threads_export_apis(NativeSymbol **p_lib_wasi_threads_apis);
- #endif
- uint32
- get_libc_emcc_export_apis(NativeSymbol **p_libc_emcc_apis);
- uint32
- get_lib_rats_export_apis(NativeSymbol **p_lib_rats_apis);
- static bool
- compare_type_with_signautre(uint8 type, const char signature)
- {
- const char num_sig_map[] = { 'F', 'f', 'I', 'i' };
- if (VALUE_TYPE_F64 <= type && type <= VALUE_TYPE_I32
- && signature == num_sig_map[type - VALUE_TYPE_F64]) {
- return true;
- }
- #if WASM_ENABLE_REF_TYPES != 0
- if ('r' == signature
- #if WASM_ENABLE_GC != 0
- #if WASM_ENABLE_STRINGREF != 0
- && (type >= REF_TYPE_STRINGVIEWITER && type <= REF_TYPE_FUNCREF)
- #else
- && (type >= REF_TYPE_NULLREF && type <= REF_TYPE_FUNCREF)
- #endif
- #else
- && type == VALUE_TYPE_EXTERNREF
- #endif
- )
- return true;
- #endif
- /* TODO: a v128 parameter */
- return false;
- }
- static bool
- check_symbol_signature(const WASMFuncType *type, const char *signature)
- {
- const char *p = signature, *p_end;
- char sig;
- uint32 i = 0;
- if (!p || strlen(p) < 2)
- return false;
- p_end = p + strlen(signature);
- if (*p++ != '(')
- return false;
- if ((uint32)(p_end - p) < (uint32)(type->param_count + 1))
- /* signatures of parameters, and ')' */
- return false;
- for (i = 0; i < type->param_count; i++) {
- sig = *p++;
- /* a f64/f32/i64/i32/externref parameter */
- if (compare_type_with_signautre(type->types[i], sig))
- continue;
- /* a pointer/string paramter */
- if (type->types[i] != VALUE_TYPE_I32)
- /* pointer and string must be i32 type */
- return false;
- if (sig == '*') {
- /* it is a pointer */
- if (i + 1 < type->param_count
- && type->types[i + 1] == VALUE_TYPE_I32 && *p == '~') {
- /* pointer length followed */
- i++;
- p++;
- }
- }
- else if (sig == '$') {
- /* it is a string */
- }
- else {
- /* invalid signature */
- return false;
- }
- }
- if (*p++ != ')')
- return false;
- if (type->result_count) {
- if (p >= p_end)
- return false;
- /* result types includes: f64,f32,i64,i32,externref */
- if (!compare_type_with_signautre(type->types[i], *p))
- return false;
- p++;
- }
- if (*p != '\0')
- return false;
- return true;
- }
- static int
- native_symbol_cmp(const void *native_symbol1, const void *native_symbol2)
- {
- return strcmp(((const NativeSymbol *)native_symbol1)->symbol,
- ((const NativeSymbol *)native_symbol2)->symbol);
- }
- static void *
- lookup_symbol(NativeSymbol *native_symbols, uint32 n_native_symbols,
- const char *symbol, const char **p_signature, void **p_attachment)
- {
- NativeSymbol *native_symbol, key = { 0 };
- key.symbol = symbol;
- if ((native_symbol = bsearch(&key, native_symbols, n_native_symbols,
- sizeof(NativeSymbol), native_symbol_cmp))) {
- *p_signature = native_symbol->signature;
- *p_attachment = native_symbol->attachment;
- return native_symbol->func_ptr;
- }
- return NULL;
- }
- /**
- * allow func_type and all outputs, like p_signature, p_attachment and
- * p_call_conv_raw to be NULL
- */
- void *
- wasm_native_resolve_symbol(const char *module_name, const char *field_name,
- const WASMFuncType *func_type,
- const char **p_signature, void **p_attachment,
- bool *p_call_conv_raw)
- {
- NativeSymbolsNode *node, *node_next;
- const char *signature = NULL;
- void *func_ptr = NULL, *attachment = NULL;
- node = g_native_symbols_list;
- while (node) {
- node_next = node->next;
- if (!strcmp(node->module_name, module_name)) {
- if ((func_ptr =
- lookup_symbol(node->native_symbols, node->n_native_symbols,
- field_name, &signature, &attachment))
- || (field_name[0] == '_'
- && (func_ptr = lookup_symbol(
- node->native_symbols, node->n_native_symbols,
- field_name + 1, &signature, &attachment))))
- break;
- }
- node = node_next;
- }
- if (!p_signature || !p_attachment || !p_call_conv_raw)
- return func_ptr;
- if (func_ptr) {
- if (signature && signature[0] != '\0') {
- /* signature is not empty, check its format */
- if (!func_type || !check_symbol_signature(func_type, signature)) {
- #if WASM_ENABLE_WAMR_COMPILER == 0
- /* Output warning except running aot compiler */
- LOG_WARNING("failed to check signature '%s' and resolve "
- "pointer params for import function (%s %s)\n",
- signature, module_name, field_name);
- #endif
- return NULL;
- }
- else
- /* Save signature for runtime to do pointer check and
- address conversion */
- *p_signature = signature;
- }
- else
- /* signature is empty */
- *p_signature = NULL;
- *p_attachment = attachment;
- *p_call_conv_raw = node->call_conv_raw;
- }
- return func_ptr;
- }
- static bool
- register_natives(const char *module_name, NativeSymbol *native_symbols,
- uint32 n_native_symbols, bool call_conv_raw)
- {
- NativeSymbolsNode *node;
- if (!(node = wasm_runtime_malloc(sizeof(NativeSymbolsNode))))
- return false;
- #if WASM_ENABLE_MEMORY_TRACING != 0
- os_printf("Register native, size: %u\n", sizeof(NativeSymbolsNode));
- #endif
- node->module_name = module_name;
- node->native_symbols = native_symbols;
- node->n_native_symbols = n_native_symbols;
- node->call_conv_raw = call_conv_raw;
- /* Add to list head */
- node->next = g_native_symbols_list;
- g_native_symbols_list = node;
- qsort(native_symbols, n_native_symbols, sizeof(NativeSymbol),
- native_symbol_cmp);
- return true;
- }
- bool
- wasm_native_register_natives(const char *module_name,
- NativeSymbol *native_symbols,
- uint32 n_native_symbols)
- {
- return register_natives(module_name, native_symbols, n_native_symbols,
- false);
- }
- bool
- wasm_native_register_natives_raw(const char *module_name,
- NativeSymbol *native_symbols,
- uint32 n_native_symbols)
- {
- return register_natives(module_name, native_symbols, n_native_symbols,
- true);
- }
- bool
- wasm_native_unregister_natives(const char *module_name,
- NativeSymbol *native_symbols)
- {
- NativeSymbolsNode **prevp;
- NativeSymbolsNode *node;
- prevp = &g_native_symbols_list;
- while ((node = *prevp) != NULL) {
- if (node->native_symbols == native_symbols
- && !strcmp(node->module_name, module_name)) {
- *prevp = node->next;
- wasm_runtime_free(node);
- return true;
- }
- prevp = &node->next;
- }
- return false;
- }
- #if WASM_ENABLE_MODULE_INST_CONTEXT != 0
- static uint32
- context_key_to_idx(void *key)
- {
- bh_assert(key != NULL);
- uint32 idx = (uint32)(uintptr_t)key;
- bh_assert(idx > 0);
- bh_assert(idx <= WASM_MAX_INSTANCE_CONTEXTS);
- return idx - 1;
- }
- static void *
- context_idx_to_key(uint32 idx)
- {
- bh_assert(idx < WASM_MAX_INSTANCE_CONTEXTS);
- return (void *)(uintptr_t)(idx + 1);
- }
- typedef void (*dtor_t)(WASMModuleInstanceCommon *, void *);
- static dtor_t g_context_dtors[WASM_MAX_INSTANCE_CONTEXTS];
- static void
- dtor_noop(WASMModuleInstanceCommon *inst, void *ctx)
- {}
- void *
- wasm_native_create_context_key(void (*dtor)(WASMModuleInstanceCommon *inst,
- void *ctx))
- {
- uint32 i;
- for (i = 0; i < WASM_MAX_INSTANCE_CONTEXTS; i++) {
- if (g_context_dtors[i] == NULL) {
- if (dtor == NULL) {
- dtor = dtor_noop;
- }
- g_context_dtors[i] = dtor;
- return context_idx_to_key(i);
- }
- }
- LOG_ERROR("failed to allocate instance context key");
- return NULL;
- }
- void
- wasm_native_destroy_context_key(void *key)
- {
- uint32 idx = context_key_to_idx(key);
- bh_assert(g_context_dtors[idx] != NULL);
- g_context_dtors[idx] = NULL;
- }
- static WASMModuleInstanceExtraCommon *
- wasm_module_inst_extra_common(WASMModuleInstanceCommon *inst)
- {
- #if WASM_ENABLE_INTERP != 0
- if (inst->module_type == Wasm_Module_Bytecode) {
- return &((WASMModuleInstance *)inst)->e->common;
- }
- #endif
- #if WASM_ENABLE_AOT != 0
- if (inst->module_type == Wasm_Module_AoT) {
- return &((AOTModuleInstanceExtra *)((AOTModuleInstance *)inst)->e)
- ->common;
- }
- #endif
- bh_assert(false);
- return NULL;
- }
- void
- wasm_native_set_context(WASMModuleInstanceCommon *inst, void *key, void *ctx)
- {
- uint32 idx = context_key_to_idx(key);
- WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst);
- common->contexts[idx] = ctx;
- }
- void
- wasm_native_set_context_spread(WASMModuleInstanceCommon *inst, void *key,
- void *ctx)
- {
- #if WASM_ENABLE_THREAD_MGR != 0
- wasm_cluster_set_context(inst, key, ctx);
- #else
- wasm_native_set_context(inst, key, ctx);
- #endif
- }
- void *
- wasm_native_get_context(WASMModuleInstanceCommon *inst, void *key)
- {
- uint32 idx = context_key_to_idx(key);
- WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst);
- return common->contexts[idx];
- }
- void
- wasm_native_call_context_dtors(WASMModuleInstanceCommon *inst)
- {
- WASMModuleInstanceExtraCommon *common = wasm_module_inst_extra_common(inst);
- uint32 i;
- for (i = 0; i < WASM_MAX_INSTANCE_CONTEXTS; i++) {
- dtor_t dtor = g_context_dtors[i];
- if (dtor != NULL) {
- dtor(inst, common->contexts[i]);
- }
- }
- }
- void
- wasm_native_inherit_contexts(WASMModuleInstanceCommon *child,
- WASMModuleInstanceCommon *parent)
- {
- WASMModuleInstanceExtraCommon *parent_common =
- wasm_module_inst_extra_common(parent);
- WASMModuleInstanceExtraCommon *child_common =
- wasm_module_inst_extra_common(child);
- bh_memcpy_s(child_common->contexts,
- sizeof(*child_common->contexts) * WASM_MAX_INSTANCE_CONTEXTS,
- parent_common->contexts,
- sizeof(*parent_common->contexts) * WASM_MAX_INSTANCE_CONTEXTS);
- }
- #endif /* WASM_ENABLE_MODULE_INST_CONTEXT != 0 */
- #if WASM_ENABLE_LIBC_WASI != 0
- WASIContext *
- wasm_runtime_get_wasi_ctx(WASMModuleInstanceCommon *module_inst_comm)
- {
- return wasm_native_get_context(module_inst_comm, g_wasi_context_key);
- }
- void
- wasm_runtime_set_wasi_ctx(WASMModuleInstanceCommon *module_inst_comm,
- WASIContext *wasi_ctx)
- {
- wasm_native_set_context(module_inst_comm, g_wasi_context_key, wasi_ctx);
- }
- static void
- wasi_context_dtor(WASMModuleInstanceCommon *inst, void *ctx)
- {
- if (ctx == NULL) {
- return;
- }
- wasm_runtime_destroy_wasi(inst);
- }
- #endif /* end of WASM_ENABLE_LIBC_WASI */
- #if WASM_ENABLE_QUICK_AOT_ENTRY != 0
- static bool
- quick_aot_entry_init();
- #endif
- bool
- wasm_native_init()
- {
- #if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \
- || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \
- || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \
- || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \
- || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0
- NativeSymbol *native_symbols;
- uint32 n_native_symbols;
- #endif
- #if WASM_ENABLE_LIBC_BUILTIN != 0
- n_native_symbols = get_libc_builtin_export_apis(&native_symbols);
- if (!wasm_native_register_natives("env", native_symbols, n_native_symbols))
- goto fail;
- #endif /* WASM_ENABLE_LIBC_BUILTIN */
- #if WASM_ENABLE_SPEC_TEST
- n_native_symbols = get_spectest_export_apis(&native_symbols);
- if (!wasm_native_register_natives("spectest", native_symbols,
- n_native_symbols))
- goto fail;
- #endif /* WASM_ENABLE_SPEC_TEST */
- #if WASM_ENABLE_LIBC_WASI != 0
- g_wasi_context_key = wasm_native_create_context_key(wasi_context_dtor);
- if (g_wasi_context_key == NULL) {
- goto fail;
- }
- n_native_symbols = get_libc_wasi_export_apis(&native_symbols);
- if (!wasm_native_register_natives("wasi_unstable", native_symbols,
- n_native_symbols))
- goto fail;
- if (!wasm_native_register_natives("wasi_snapshot_preview1", native_symbols,
- n_native_symbols))
- goto fail;
- #endif
- #if WASM_ENABLE_BASE_LIB != 0
- n_native_symbols = get_base_lib_export_apis(&native_symbols);
- if (n_native_symbols > 0
- && !wasm_native_register_natives("env", native_symbols,
- n_native_symbols))
- goto fail;
- #endif
- #if WASM_ENABLE_APP_FRAMEWORK != 0
- n_native_symbols = get_ext_lib_export_apis(&native_symbols);
- if (n_native_symbols > 0
- && !wasm_native_register_natives("env", native_symbols,
- n_native_symbols))
- goto fail;
- #endif
- #if WASM_ENABLE_LIB_PTHREAD != 0
- if (!lib_pthread_init())
- goto fail;
- n_native_symbols = get_lib_pthread_export_apis(&native_symbols);
- if (n_native_symbols > 0
- && !wasm_native_register_natives("env", native_symbols,
- n_native_symbols))
- goto fail;
- #endif
- #if WASM_ENABLE_LIB_WASI_THREADS != 0
- if (!lib_wasi_threads_init())
- goto fail;
- n_native_symbols = get_lib_wasi_threads_export_apis(&native_symbols);
- if (n_native_symbols > 0
- && !wasm_native_register_natives("wasi", native_symbols,
- n_native_symbols))
- goto fail;
- #endif
- #if WASM_ENABLE_LIBC_EMCC != 0
- n_native_symbols = get_libc_emcc_export_apis(&native_symbols);
- if (n_native_symbols > 0
- && !wasm_native_register_natives("env", native_symbols,
- n_native_symbols))
- goto fail;
- #endif /* WASM_ENABLE_LIBC_EMCC */
- #if WASM_ENABLE_LIB_RATS != 0
- n_native_symbols = get_lib_rats_export_apis(&native_symbols);
- if (n_native_symbols > 0
- && !wasm_native_register_natives("env", native_symbols,
- n_native_symbols))
- goto fail;
- #endif /* WASM_ENABLE_LIB_RATS */
- #if WASM_ENABLE_WASI_NN != 0
- n_native_symbols = get_wasi_nn_export_apis(&native_symbols);
- if (!wasm_native_register_natives("wasi_nn", native_symbols,
- n_native_symbols))
- goto fail;
- #endif
- #if WASM_ENABLE_QUICK_AOT_ENTRY != 0
- if (!quick_aot_entry_init()) {
- #if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \
- || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \
- || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \
- || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \
- || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0
- goto fail;
- #else
- return false;
- #endif
- }
- #endif
- return true;
- #if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_LIBC_BUILTIN != 0 \
- || WASM_ENABLE_BASE_LIB != 0 || WASM_ENABLE_LIBC_EMCC != 0 \
- || WASM_ENABLE_LIB_RATS != 0 || WASM_ENABLE_WASI_NN != 0 \
- || WASM_ENABLE_APP_FRAMEWORK != 0 || WASM_ENABLE_LIBC_WASI != 0 \
- || WASM_ENABLE_LIB_PTHREAD != 0 || WASM_ENABLE_LIB_WASI_THREADS != 0
- fail:
- wasm_native_destroy();
- return false;
- #endif
- }
- void
- wasm_native_destroy()
- {
- NativeSymbolsNode *node, *node_next;
- #if WASM_ENABLE_LIBC_WASI != 0
- if (g_wasi_context_key != NULL) {
- wasm_native_destroy_context_key(g_wasi_context_key);
- g_wasi_context_key = NULL;
- }
- #endif
- #if WASM_ENABLE_LIB_PTHREAD != 0
- lib_pthread_destroy();
- #endif
- #if WASM_ENABLE_LIB_WASI_THREADS != 0
- lib_wasi_threads_destroy();
- #endif
- node = g_native_symbols_list;
- while (node) {
- node_next = node->next;
- wasm_runtime_free(node);
- node = node_next;
- }
- g_native_symbols_list = NULL;
- }
- #if WASM_ENABLE_QUICK_AOT_ENTRY != 0
- static void
- invoke_no_args_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *) = func_ptr;
- native_code(exec_env);
- }
- static void
- invoke_no_args_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *) = func_ptr;
- argv_ret[0] = native_code(exec_env);
- }
- static void
- invoke_no_args_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *) = func_ptr;
- int64 ret = native_code(exec_env);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_i_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32) = func_ptr;
- native_code(exec_env, argv[0]);
- }
- static void
- invoke_i_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0]);
- }
- static void
- invoke_i_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32) = func_ptr;
- int64 ret = native_code(exec_env, argv[0]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_I_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv));
- }
- static void
- invoke_I_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv));
- }
- static void
- invoke_I_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_ii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32) = func_ptr;
- native_code(exec_env, argv[0], argv[1]);
- }
- static void
- invoke_ii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0], argv[1]);
- }
- static void
- invoke_ii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32) = func_ptr;
- int64 ret = native_code(exec_env, argv[0], argv[1]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int64) = func_ptr;
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1));
- }
- static void
- invoke_iI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int64) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1));
- }
- static void
- invoke_iI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int64) = func_ptr;
- int64 ret =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_Ii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int32) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2]);
- }
- static void
- invoke_Ii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int32) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2]);
- }
- static void
- invoke_Ii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int32) = func_ptr;
- int64 ret =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_II_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2));
- }
- static void
- invoke_II_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2));
- }
- static void
- invoke_II_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int64) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32, int32) = func_ptr;
- native_code(exec_env, argv[0], argv[1], argv[2]);
- }
- static void
- invoke_iii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0], argv[1], argv[2]);
- }
- static void
- invoke_iii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32, int32) = func_ptr;
- int64 ret = native_code(exec_env, argv[0], argv[1], argv[2]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32, int64) = func_ptr;
- native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2));
- }
- static void
- invoke_iiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2));
- }
- static void
- invoke_iiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32, int64) = func_ptr;
- int64 ret = native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int64, int32) = func_ptr;
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- argv[3]);
- }
- static void
- invoke_iIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int64, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0],
- GET_I64_FROM_ADDR((uint32 *)argv + 1), argv[3]);
- }
- static void
- invoke_iIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int64, int32) = func_ptr;
- int64 ret = native_code(exec_env, argv[0],
- GET_I64_FROM_ADDR((uint32 *)argv + 1), argv[3]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int64, int64) = func_ptr;
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3));
- }
- static void
- invoke_iII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int64, int64) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3));
- }
- static void
- invoke_iII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int64, int64) = func_ptr;
- int64 ret =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_Iii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int32, int32) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], argv[3]);
- }
- static void
- invoke_Iii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int32, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], argv[3]);
- }
- static void
- invoke_Iii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int32, int32) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], argv[3]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int32, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3));
- }
- static void
- invoke_IiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int32, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3));
- }
- static void
- invoke_IiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int32, int64) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int64, int32) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]);
- }
- static void
- invoke_IIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int64, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]);
- }
- static void
- invoke_IIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int64, int32) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_III_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int64, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_III_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int64, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_III_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int64, int64) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iiii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32, int32, int32) = func_ptr;
- native_code(exec_env, argv[0], argv[1], argv[2], argv[3]);
- }
- static void
- invoke_iiii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32, int32, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0], argv[1], argv[2], argv[3]);
- }
- static void
- invoke_iiii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32, int32, int32) = func_ptr;
- int64 ret = native_code(exec_env, argv[0], argv[1], argv[2], argv[3]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iiiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32, int32, int64) = func_ptr;
- native_code(exec_env, argv[0], argv[1], argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3));
- }
- static void
- invoke_iiiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32, int32, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0], argv[1], argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3));
- }
- static void
- invoke_iiiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32, int32, int64) = func_ptr;
- int64 ret = native_code(exec_env, argv[0], argv[1], argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iiIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32, int64, int32) = func_ptr;
- native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]);
- }
- static void
- invoke_iiIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32, int64, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]);
- }
- static void
- invoke_iiIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32, int64, int32) = func_ptr;
- int64 ret = native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iiII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32, int64, int64) = func_ptr;
- native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_iiII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32, int64, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_iiII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32, int64, int64) = func_ptr;
- int64 ret = native_code(exec_env, argv[0], argv[1],
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iIii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int64, int32, int32) = func_ptr;
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- argv[3], argv[4]);
- }
- static void
- invoke_iIii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int64, int32, int32) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- argv[3], argv[4]);
- }
- static void
- invoke_iIii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int64, int32, int32) = func_ptr;
- int64 ret =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- argv[3], argv[4]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iIiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int64, int32, int64) = func_ptr;
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_iIiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int64, int32, int64) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_iIiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int64, int32, int64) = func_ptr;
- int64 ret =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iIIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int64, int64, int32) = func_ptr;
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]);
- }
- static void
- invoke_iIIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int64, int64, int32) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]);
- }
- static void
- invoke_iIIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int64, int64, int32) = func_ptr;
- int64 ret =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iIII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int64, int64, int64) = func_ptr;
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3),
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- }
- static void
- invoke_iIII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int64, int64, int64) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3),
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- }
- static void
- invoke_iIII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int64, int64, int64) = func_ptr;
- int64 ret =
- native_code(exec_env, argv[0], GET_I64_FROM_ADDR((uint32 *)argv + 1),
- GET_I64_FROM_ADDR((uint32 *)argv + 3),
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_Iiii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int32, int32, int32) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], argv[3],
- argv[4]);
- }
- static void
- invoke_Iiii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int32, int32, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], argv[3], argv[4]);
- }
- static void
- invoke_Iiii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int32, int32, int32) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], argv[3], argv[4]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IiiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int32, int32, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2], argv[3],
- GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_IiiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int32, int32, int64) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2],
- argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4));
- }
- static void
- invoke_IiiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int32, int32, int64) = func_ptr;
- int64 ret =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2],
- argv[3], GET_I64_FROM_ADDR((uint32 *)argv + 4));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IiIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int32, int64, int32) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]);
- }
- static void
- invoke_IiIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int32, int64, int32) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]);
- }
- static void
- invoke_IiIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int32, int64, int32) = func_ptr;
- int64 ret =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3), argv[5]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IiII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int32, int64, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv), argv[2],
- GET_I64_FROM_ADDR((uint32 *)argv + 3),
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- }
- static void
- invoke_IiII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int32, int64, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3),
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- }
- static void
- invoke_IiII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int32, int64, int64) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- argv[2], GET_I64_FROM_ADDR((uint32 *)argv + 3),
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IIii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int64, int32, int32) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], argv[5]);
- }
- static void
- invoke_IIii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int64, int32, int32) = func_ptr;
- argv_ret[0] =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], argv[5]);
- }
- static void
- invoke_IIii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int64, int32, int32) = func_ptr;
- int64 ret =
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4], argv[5]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IIiI_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int64, int32, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4],
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- }
- static void
- invoke_IIiI_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int64, int32, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4],
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- }
- static void
- invoke_IIiI_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int64, int32, int64) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2), argv[4],
- GET_I64_FROM_ADDR((uint32 *)argv + 5));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IIIi_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int64, int64, int32) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4), argv[6]);
- }
- static void
- invoke_IIIi_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int64, int64, int32) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4), argv[6]);
- }
- static void
- invoke_IIIi_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int64, int64, int32) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4), argv[6]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_IIII_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int64, int64, int64, int64) = func_ptr;
- native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4),
- GET_I64_FROM_ADDR((uint32 *)argv + 6));
- }
- static void
- invoke_IIII_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int64, int64, int64, int64) = func_ptr;
- argv_ret[0] = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4),
- GET_I64_FROM_ADDR((uint32 *)argv + 6));
- }
- static void
- invoke_IIII_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int64, int64, int64, int64) = func_ptr;
- int64 ret = native_code(exec_env, GET_I64_FROM_ADDR((uint32 *)argv),
- GET_I64_FROM_ADDR((uint32 *)argv + 2),
- GET_I64_FROM_ADDR((uint32 *)argv + 4),
- GET_I64_FROM_ADDR((uint32 *)argv + 6));
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- static void
- invoke_iiiii_v(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- void (*native_code)(WASMExecEnv *, int32, int32, int32, int32, int32) =
- func_ptr;
- native_code(exec_env, argv[0], argv[1], argv[2], argv[3], argv[4]);
- }
- static void
- invoke_iiiii_i(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int32 (*native_code)(WASMExecEnv *, int32, int32, int32, int32, int32) =
- func_ptr;
- argv_ret[0] =
- native_code(exec_env, argv[0], argv[1], argv[2], argv[3], argv[4]);
- }
- static void
- invoke_iiiii_I(void *func_ptr, void *exec_env, int32 *argv, int32 *argv_ret)
- {
- int64 (*native_code)(WASMExecEnv *, int32, int32, int32, int32, int32) =
- func_ptr;
- int64 ret =
- native_code(exec_env, argv[0], argv[1], argv[2], argv[3], argv[4]);
- PUT_I64_TO_ADDR(argv_ret, ret);
- }
- typedef struct QuickAOTEntry {
- const char *signature;
- void *func_ptr;
- } QuickAOTEntry;
- /* clang-format off */
- static QuickAOTEntry quick_aot_entries[] = {
- { "()v", invoke_no_args_v },
- { "()i", invoke_no_args_i },
- { "()I", invoke_no_args_I },
- { "(i)v", invoke_i_v }, { "(i)i", invoke_i_i }, { "(i)I", invoke_i_I },
- { "(I)v", invoke_I_v }, { "(I)i", invoke_I_i }, { "(I)I", invoke_I_I },
- { "(ii)v", invoke_ii_v }, { "(ii)i", invoke_ii_i }, { "(ii)I", invoke_ii_I },
- { "(iI)v", invoke_iI_v }, { "(iI)i", invoke_iI_i }, { "(iI)I", invoke_iI_I },
- { "(Ii)v", invoke_Ii_v }, { "(Ii)i", invoke_Ii_i }, { "(Ii)I", invoke_Ii_I },
- { "(II)v", invoke_II_v }, { "(II)i", invoke_II_i }, { "(II)I", invoke_II_I },
- { "(iii)v", invoke_iii_v }, { "(iii)i", invoke_iii_i }, { "(iii)I", invoke_iii_I },
- { "(iiI)v", invoke_iiI_v }, { "(iiI)i", invoke_iiI_i }, { "(iiI)I", invoke_iiI_I },
- { "(iIi)v", invoke_iIi_v }, { "(iIi)i", invoke_iIi_i }, { "(iIi)I", invoke_iIi_I },
- { "(iII)v", invoke_iII_v }, { "(iII)i", invoke_iII_i }, { "(iII)I", invoke_iII_I },
- { "(Iii)v", invoke_Iii_v }, { "(Iii)i", invoke_Iii_i }, { "(Iii)I", invoke_Iii_I },
- { "(IiI)v", invoke_IiI_v }, { "(IiI)i", invoke_IiI_i }, { "(IiI)I", invoke_IiI_I },
- { "(IIi)v", invoke_IIi_v }, { "(IIi)i", invoke_IIi_i }, { "(IIi)I", invoke_IIi_I },
- { "(III)v", invoke_III_v }, { "(III)i", invoke_III_i }, { "(III)I", invoke_III_I },
- { "(iiii)v", invoke_iiii_v }, { "(iiii)i", invoke_iiii_i }, { "(iiii)I", invoke_iiii_I },
- { "(iiiI)v", invoke_iiiI_v }, { "(iiiI)i", invoke_iiiI_i }, { "(iiiI)I", invoke_iiiI_I },
- { "(iiIi)v", invoke_iiIi_v }, { "(iiIi)i", invoke_iiIi_i }, { "(iiIi)I", invoke_iiIi_I },
- { "(iiII)v", invoke_iiII_v }, { "(iiII)i", invoke_iiII_i }, { "(iiII)I", invoke_iiII_I },
- { "(iIii)v", invoke_iIii_v }, { "(iIii)i", invoke_iIii_i }, { "(iIii)I", invoke_iIii_I },
- { "(iIiI)v", invoke_iIiI_v }, { "(iIiI)i", invoke_iIiI_i }, { "(iIiI)I", invoke_iIiI_I },
- { "(iIIi)v", invoke_iIIi_v }, { "(iIIi)i", invoke_iIIi_i }, { "(iIIi)I", invoke_iIIi_I },
- { "(iIII)v", invoke_iIII_v }, { "(iIII)i", invoke_iIII_i }, { "(iIII)I", invoke_iIII_I },
- { "(Iiii)v", invoke_Iiii_v }, { "(Iiii)i", invoke_Iiii_i }, { "(Iiii)I", invoke_Iiii_I },
- { "(IiiI)v", invoke_IiiI_v }, { "(IiiI)i", invoke_IiiI_i }, { "(IiiI)I", invoke_IiiI_I },
- { "(IiIi)v", invoke_IiIi_v }, { "(IiIi)i", invoke_IiIi_i }, { "(IiIi)I", invoke_IiIi_I },
- { "(IiII)v", invoke_IiII_v }, { "(IiII)i", invoke_IiII_i }, { "(IiII)I", invoke_IiII_I },
- { "(IIii)v", invoke_IIii_v }, { "(IIii)i", invoke_IIii_i }, { "(IIii)I", invoke_IIii_I },
- { "(IIiI)v", invoke_IIiI_v }, { "(IIiI)i", invoke_IIiI_i }, { "(IIiI)I", invoke_IIiI_I },
- { "(IIIi)v", invoke_IIIi_v }, { "(IIIi)i", invoke_IIIi_i }, { "(IIIi)I", invoke_IIIi_I },
- { "(IIII)v", invoke_IIII_v }, { "(IIII)i", invoke_IIII_i }, { "(IIII)I", invoke_IIII_I },
- { "(iiiii)v", invoke_iiiii_v }, { "(iiiii)i", invoke_iiiii_i }, { "(iiiii)I", invoke_iiiii_I },
- };
- /* clang-format on */
- static int
- quick_aot_entry_cmp(const void *quick_aot_entry1, const void *quick_aot_entry2)
- {
- return strcmp(((const QuickAOTEntry *)quick_aot_entry1)->signature,
- ((const QuickAOTEntry *)quick_aot_entry2)->signature);
- }
- static bool
- quick_aot_entry_init()
- {
- qsort(quick_aot_entries, sizeof(quick_aot_entries) / sizeof(QuickAOTEntry),
- sizeof(QuickAOTEntry), quick_aot_entry_cmp);
- return true;
- }
- void *
- wasm_native_lookup_quick_aot_entry(const WASMFuncType *func_type)
- {
- char signature[16] = { 0 };
- uint32 param_count = func_type->param_count;
- uint32 result_count = func_type->result_count, i, j = 0;
- const uint8 *types = func_type->types;
- QuickAOTEntry *quick_aot_entry, key = { 0 };
- if (param_count > 5 || result_count > 1)
- return NULL;
- signature[j++] = '(';
- for (i = 0; i < param_count; i++) {
- if (types[i] == VALUE_TYPE_I32)
- signature[j++] = 'i';
- else if (types[i] == VALUE_TYPE_I64)
- signature[j++] = 'I';
- else
- return NULL;
- }
- signature[j++] = ')';
- if (result_count == 0) {
- signature[j++] = 'v';
- }
- else {
- if (types[i] == VALUE_TYPE_I32)
- signature[j++] = 'i';
- else if (types[i] == VALUE_TYPE_I64)
- signature[j++] = 'I';
- else
- return NULL;
- }
- key.signature = signature;
- if ((quick_aot_entry =
- bsearch(&key, quick_aot_entries,
- sizeof(quick_aot_entries) / sizeof(QuickAOTEntry),
- sizeof(QuickAOTEntry), quick_aot_entry_cmp))) {
- return quick_aot_entry->func_ptr;
- }
- return NULL;
- }
- #endif /* end of WASM_ENABLE_QUICK_AOT_ENTRY != 0 */
|