Call asc app exported new/pin/unpin APIs to align with its latest compiler (#577)
AssemblyScript's latest compiler 0.18 exports __new__/__pin__/unpin APIs to allocate/retain/free memory instead of __new/__retain/__release APIs in older version, we lookup functions of both version to make it compatible for both version.
This commit is contained in:
@ -1502,6 +1502,8 @@ aot_module_malloc(AOTModuleInstance *module_inst, uint32 size,
|
||||
malloc_func_sig = "(ii)i";
|
||||
retain_func =
|
||||
aot_lookup_function(module_inst, "__retain", "(i)i");
|
||||
if (!retain_func)
|
||||
retain_func = aot_lookup_function(module_inst, "__pin", "(i)i");
|
||||
bh_assert(retain_func);
|
||||
}
|
||||
else {
|
||||
@ -1573,6 +1575,8 @@ aot_module_free(AOTModuleInstance *module_inst, uint32 ptr)
|
||||
}
|
||||
free_func =
|
||||
aot_lookup_function(module_inst, free_func_name, "(i)i");
|
||||
if (!free_func && module->retain_func_index != (uint32)-1)
|
||||
free_func = aot_lookup_function(module_inst, "__unpin", "(i)i");
|
||||
|
||||
bh_assert(free_func);
|
||||
execute_free_function(module_inst, free_func, ptr);
|
||||
|
||||
Reference in New Issue
Block a user