-
Notifications
You must be signed in to change notification settings - Fork 824
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
Refactor singlepass init stack assembly #2012
Refactor singlepass init stack assembly #2012
Conversation
Since the direction of rep stosq is in reverse order (DF=0), The trap handler is judged as a heap oob exception based on the start address.
99ad186
to
71f4e15
Compare
Thanks for the pull request! I added stack probe for large allocations before |
…it-stack-assembly
bors try |
1 similar comment
bors try |
tryAlready running a review |
bors try- |
bors try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Co-authored-by: Ivan Enderlin <[email protected]>
Co-authored-by: Ivan Enderlin <[email protected]>
@losfair Can you approve this PR if it's OK please? :-) |
bors r+ |
2012: Refactor singlepass init stack assembly r=syrusakbary a=slave5vw <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> The old method generated 1 mov assembly instruction per stack slot. This takes up 15 bytes * slots count size. So more local stack variables use, the larger the code size. The suggested method is the same as c memset. Initialize with a fixed instructions (24 bytes) using the rep stosq assembly instruction. It works on a range basis. https://www.felixcloutier.com/x86/stos:stosb:stosw:stosd:stosq However, in this way, the skip_stack_guard_page test fails. https://github.com/wasmerio/wasmer/blob/1b49fe8475e335c6cdbb702a7100ba044201afd0/lib/vm/src/trap/traphandlers.rs#L124 The reason is that DF Flag is 0, so it is accessed in reverse order and initialized. However, The vm trap handler checks the last address and determines it as a heap oob without range. the stack oob is correct, and the test condition fails because it is a stack oob occurrence. I think there are two ways. 1. improve stack oob check in VM trap handler -> Abstract. There is no information on the range of access, so this may not be possible. 2. pushf/popf/std(set DF=1), and access to sequential order -> Not recommended. Unnecessarily increases assembly size. So for now, I added it to ignores.txt like cranelift/llvm. # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Jiyong Ha <[email protected]> Co-authored-by: losfair <[email protected]> Co-authored-by: Jiyong Ha <[email protected]> Co-authored-by: Syrus Akbary <[email protected]>
Build failed: |
bors r+ |
Description
The old method generated 1 mov assembly instruction per stack slot.
This takes up 15 bytes * slots count size. So more local stack variables use, the larger the code size.
The suggested method is the same as c memset.
Initialize with a fixed instructions (24 bytes) using the rep stosq assembly instruction. It works on a range basis.
https://www.felixcloutier.com/x86/stos:stosb:stosw:stosd:stosq
However, in this way, the skip_stack_guard_page test fails.
wasmer/lib/vm/src/trap/traphandlers.rs
Line 124 in 1b49fe8
The reason is that DF Flag is 0, so it is accessed in reverse order and initialized.
However, The vm trap handler checks the last address and determines it as a heap oob without range.
the stack oob is correct, and the test condition fails because it is a stack oob occurrence.
I think there are two ways.
-> Abstract. There is no information on the range of access, so this may not be possible.
-> Not recommended. Unnecessarily increases assembly size.
So for now, I added it to ignores.txt like cranelift/llvm.
Review