bytecodealliance / wasm-micro-runtime

WebAssembly Micro Runtime (WAMR)
Apache License 2.0
4.98k stars 628 forks source link

Refine looking up aot function with index #3882

Closed wenyongh closed 3 weeks ago

lum1n0us commented 4 weeks ago

Is it because DefPointer(WASMExportFuncInstance *, export_functions); now are sorted by names instead of function indexes?

wenyongh commented 4 weeks ago

Is it because DefPointer(WASMExportFuncInstance *, export_functions); now are sorted by names instead of function indexes?

No, event if the export_functions isn't sorted by names, it doesn't mean that it will be sorted by function index, it's in random order. This PR's optimization is suitable no matter whether export_functions is sorted by names or not.

lum1n0us commented 4 weeks ago

Totally true. It sticks to the order given by the export section context, which is based on toolchains and seems random now.

So, we now need to sort the list export_functions by name and store them in that order, and then search by both name and function index.

wenyongh commented 4 weeks ago

Totally true. It sticks to the order given by the export section context, which is based on toolchains and seems random now.

So, we now need to sort the list export_functions by name and store them in that order, and then search by both name and function index.

Yes, sort export_functions by name, and create another map array whose element is <func_idx, export_ith> and sort the array by func_idx.