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:
Javan
2021-03-18 16:33:02 +08:00
committed by GitHub
parent fda3a26903
commit ca67af91bc
5 changed files with 24 additions and 14 deletions

View File

@ -2768,7 +2768,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
else if (!strcmp(export->name, "__new")
&& export->index >= module->import_function_count) {
/* __new && __retain for AssemblyScript */
/* __new && __pin for AssemblyScript */
func_index = export->index - module->import_function_count;
func_type = module->functions[func_index]->func_type;
if (func_type->param_count == 2
@ -2789,7 +2789,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
export_tmp = module->exports;
for (j = 0; j < module->export_count; j++, export_tmp++) {
if ((export_tmp->kind == EXPORT_KIND_FUNC)
&& (!strcmp(export_tmp->name, "__retain"))
&& (!strcmp(export_tmp->name, "__retain")
|| (!strcmp(export_tmp->name, "__pin")))
&& (export_tmp->index
>= module->import_function_count)) {
func_index = export_tmp->index
@ -2818,7 +2819,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
}
}
else if (((!strcmp(export->name, "free"))
|| (!strcmp(export->name, "__release")))
|| (!strcmp(export->name, "__release"))
|| (!strcmp(export->name, "__unpin")))
&& export->index >= module->import_function_count) {
func_index = export->index - module->import_function_count;
func_type = module->functions[func_index]->func_type;