Skip to content

Conversation

@yamt
Copy link
Contributor

@yamt yamt commented Oct 12, 2022

This partially revert 1c89a37.

The need of pointer conversions is actually more than a recommendation.

This partially revert 1c89a37.

The need of pointer conversions is actually more than a recommendation.
- Never pass any structure/class object pointer to native (do data serialization instead)
- Do the pointer address conversion in the native API if "$\*" is not used for the pointer in the function signature
- Never pass a function pointer to the native
Copy link
Contributor

@tonibofarull tonibofarull Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add, "if you plan to call it, from native side, as a C/C++ callback. In that case, you must use wasm_runtime_call_indirect or any other variant provided by WAMR.".

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand what you mean. what's a "regular" callback? is there a "non-regular" callback?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edited for better description!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this doc is basically about what the author recommends. i feel it's a bit awkward to explain more about what's discouraged here.
anyway, i added some clarifications.

C function pointers are usually represented as table indexes which
the native API can call with wasm_runtime_call_indirect() or similar.
However, in this document, we don't recommend to implement your native
API that way unless necessary because it needs extra carefulness.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"because it needs extra carefulness" is just my guess of the intention of this document.

@wenyongh wenyongh merged commit e6c7125 into bytecodealliance:main Oct 13, 2022
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants