Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append .aot to .wasm as a custom section named "aot" #2933

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

lum1n0us
Copy link
Collaborator

No description provided.

@yamt
Copy link
Collaborator

yamt commented Dec 27, 2023

how do you plan to use the section?

@lum1n0us
Copy link
Collaborator Author

a pre_compiled wasm plugin for Envoy

@yamt
Copy link
Collaborator

yamt commented Dec 27, 2023

a pre_compiled wasm plugin for Envoy

how does it load and execute the aot section?
i'm asking because i have alignment concerns.

@lum1n0us
Copy link
Collaborator Author

thanks for reminding. in a nutshell, envoy will load aot custom section and pass the content(in a string_view) to WAMR. https://github.com/proxy-wasm/proxy-wasm-cpp-host/blob/master/src/wasm.cc#L293

@yamt
Copy link
Collaborator

yamt commented Dec 27, 2023

thanks for reminding. in a nutshell, envoy will load aot custom section and pass the content(in a string_view) to WAMR. https://github.com/proxy-wasm/proxy-wasm-cpp-host/blob/master/src/wasm.cc#L293

i suppose that it's safer to make some padding so that the start offset of section_content within the file will have the max alignment we can use in our aot format. (4 byte?)

@lum1n0us
Copy link
Collaborator Author

the section layout likes:

| section id(0) | section length | section name | section content(.aot) |

IIUC, please correct me if wrong, the 4 byte padding goes to the beginning of section content, and the consumer(WAMR or embedder) needs to ignore the 4 padding.

@yamt
Copy link
Collaborator

yamt commented Dec 28, 2023

the section layout likes:

| section id(0) | section length | section name | section content(.aot) |

IIUC, please correct me if wrong, the 4 byte padding goes to the beginning of section content, and the consumer(WAMR or embedder) needs to ignore the 4 padding.

yea, i guess it's simplest to add the padding at the top of the custom section body.
like:

 | section id(0) | section length | section name | padding len | padding (zeros) | section content(.aot) |

note that the implementation might be a bit tricky as "section length" is variable lengh (leb128) and it affects the padding length.
you might want to use a redundant encoding of leb128. (eg. always use 5 byte)

@wenyongh wenyongh merged commit 38019f2 into bytecodealliance:main Jan 2, 2024
1 check passed
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
@lum1n0us lum1n0us deleted the fr/append_aot_to_wasm branch May 31, 2024 03:19
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.

None yet

3 participants