Comments (7)
Hi, it seems both two methods are not so straightforward, how about we just introduce a new API to set the native stack size required for the host native APIs? Some what like:
struct NativeSymbolStack {
const char *name;
uint32 stack_size;
}
wasm_runtime_set_native_api_stacks(NativeSymbolStack *native_stacks, uint32 n_symbol_stack);
And the info will be propagated into a field in WASMFunctionImport and AOTFuncImport, and runtime does native stack overflow check according to the field's value before calling the native API, and by default the field value is WASM_STACK_GUARD_SIZE if it isn't set by the API. Also runtime can set the field value of some native APIs after registering some built-in native APIs.
from wasm-micro-runtime.
Hi, it seems both two methods are not so straightforward, how about we just introduce a new API to set the native stack size required for the host native APIs? Some what like:
struct NativeSymbolStack { const char *name; uint32 stack_size; } wasm_runtime_set_native_api_stacks(NativeSymbolStack *native_stacks, uint32 n_symbol_stack);And the info will be propagated into a field in WASMFunctionImport and AOTFuncImport, and runtime does native stack overflow check according to the field's value before calling the native API, and by default the field value is WASM_STACK_GUARD_SIZE if it isn't set by the API. Also runtime can set the field value of some native APIs after registering some built-in native APIs.
at this point, i don't have strong opinion on the api. (how to give the n_symbol_stack value.)
your suggested api would have almost same overflow detection implementation with the first approach, right?
how do you think about the last item in cons?
this one:
"direct call (what aot_compile_op_call does when signature is available)
needs something different. maybe the aot compiler can emit the check.
however, it would effectively make the stack requirement of the native
function a part of the AOT ABI. i'm not sure if it's acceptable.")
from wasm-micro-runtime.
Yes, it is very similar to the first approach, but no need to make changes for current runtime native libraries implementation and developer's native library registration if there is no extra requirement from him.
For the last item, yes, had better let aot compiler emit the check directly, not sure whether it is good to pass the native stack size info to wamrc like registering the empty native apis for it with wamrc --native-lib=xxx.so
? We can add another option like wamrc --native-stack-lib=xxx.so
?
from wasm-micro-runtime.
BTW, the api had better use module name as the first argument, like wasm_runtime_register_natives: wasm_runtime_set_native_api_stacks(const char *module_name, NativeSymbolStack *native_stacks, uint32 n_symbol_stack)
from wasm-micro-runtime.
Yes, it is very similar to the first approach, but no need to make changes for current runtime native libraries implementation and developer's native library registration if there is no extra requirement from him.
For the last item, yes, had better let aot compiler emit the check directly, not sure whether it is good to pass the native stack size info to wamrc like registering the empty native apis for it with
wamrc --native-lib=xxx.so
? We can add another option likewamrc --native-stack-lib=xxx.so
?
Or just reuse the option wamrc --native-lib=xxx.so
,but require the so to provide extra api to get the native stack info
from wasm-micro-runtime.
Yes, it is very similar to the first approach, but no need to make changes for current runtime native libraries implementation and developer's native library registration if there is no extra requirement from him.
even with the first approach, users who don't care can leave it default.
(similarly to what we do for NativeSymbol attachment
today)
For the last item, yes, had better let aot compiler emit the check directly, not sure whether it is good to pass the native stack size info to wamrc like registering the empty native apis for it with
wamrc --native-lib=xxx.so
?
with the first approach, wamrc --native-lib
would work as of today.
We can add another option like
wamrc --native-stack-lib=xxx.so
?
i'm not sure how it looks like.
does xxx.so for --native-stack-lib use an api different from the current get_native_lib/init_native_lib/deinit_native_lib?
Or just reuse the option wamrc --native-lib=xxx.so,but require the so to provide extra api to get the native stack info
do you mean to export an extra symbol?
anyway, my original concern was not really about --native-lib
.
let me explain.
by making the aot compiler emit the caller-side check for a native function,
we effectively embed the corresponding n_symbol_stack value into the aot-compiled module.
if we later modify the implementation of the native function and it ends up with changing the n_symbol_stack value,
we need to re-aot-compile all modules which potentially use the native function.
for that reason, right now, i'm inclined toward the approach (b).
from wasm-micro-runtime.
Yes, it is very similar to the first approach, but no need to make changes for current runtime native libraries implementation and developer's native library registration if there is no extra requirement from him.
even with the first approach, users who don't care can leave it default. (similarly to what we do for NativeSymbol
attachment
today)For the last item, yes, had better let aot compiler emit the check directly, not sure whether it is good to pass the native stack size info to wamrc like registering the empty native apis for it with
wamrc --native-lib=xxx.so
?with the first approach,
wamrc --native-lib
would work as of today.We can add another option like
wamrc --native-stack-lib=xxx.so
?i'm not sure how it looks like. does xxx.so for --native-stack-lib use an api different from the current get_native_lib/init_native_lib/deinit_native_lib?
Or just reuse the option wamrc --native-lib=xxx.so,but require the so to provide extra api to get the native stack info
do you mean to export an extra symbol?
anyway, my original concern was not really about
--native-lib
. let me explain. by making the aot compiler emit the caller-side check for a native function, we effectively embed the corresponding n_symbol_stack value into the aot-compiled module. if we later modify the implementation of the native function and it ends up with changing the n_symbol_stack value, we need to re-aot-compile all modules which potentially use the native function. for that reason, right now, i'm inclined toward the approach (b).
OK, b is also good as long as it is not very trivial for you to add checks in the native apis.
from wasm-micro-runtime.
Related Issues (20)
- Wrong execution reuslt on fast interpreter mode HOT 2
- aot_load_const_from_table is inefficient
- "duplicate export name" check is O(n^2) HOT 3
- Compilation errors when build iwasm with GC and EH support
- iwasm: WASM module load failed: struct or array as field is not supported in constant expr HOT 6
- iwasm: WASM module load failed: type mismatch: expect (ref null ht) but got other1 unknown type HOT 5
- exception handler intercepts c++ exceptions in the host on windows HOT 2
- WASM module instantiate failed on Mac HOT 1
- aot: xtensa xip triggers llvm assertion failure
- BH_DEBUG not set in multi-configuration cmake (eg. visual studio)
- printf_wrapper (libc builtin) makes multiple calls to os_printf with individual characters HOT 6
- Can AOT file built on windows run directly on other platforms? HOT 5
- How to load and run another wasm in a running wasm? HOT 4
- Exception Handling Support in Fast Interpreter HOT 1
- iwasm with aot file fail with SIGSEGV HOT 4
- Exception for Assemblyscript HOT 1
- How to cross compile to riscv64 HOT 2
- Unexpected behavior on fast interpreter mode
- A bug in validation
- Report some typo in wamr.gitbook HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasm-micro-runtime.