-
Notifications
You must be signed in to change notification settings - Fork 21
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
Merge side table into WASM module #730
base: dev/fast-interp
Are you sure you want to change the base?
Conversation
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.
Just did a quick review. I think we can also change next_branch_table
to return Self::BranchTable<'a, 'm>
instead of &'a mut Self::BranchTable<'m>
. This will permit removing the branch_table_view
field of SideTableView
. Also I think we can split this PR:
- One for the change above.
- One for using
[u8]
instead of[u16]
. - One for serializing/deserializing the side-table.
- One for adding and using merge.
The first 2 can be done in parallel.
@@ -26,6 +26,23 @@ use crate::toctou::*; | |||
use crate::util::*; | |||
use crate::*; | |||
|
|||
pub fn merge(binary: &[u8], side_table: Vec<MetadataEntry>) -> Vec<u8> { |
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.
We can take a slice: &[MetadataEntry]
.
let mut wasm = vec![]; | ||
wasm.extend_from_slice(&binary[0 .. 8]); | ||
wasm.push(0); | ||
wasm.extend_from_slice(&side_table.len().to_le_bytes()); |
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.
This one needs to be leb128 since that's part of wasm spec.
wasm.push(0); | ||
wasm.extend_from_slice(&side_table.len().to_le_bytes()); | ||
for entry in side_table { | ||
wasm.extend_from_slice(&entry.type_idx.to_le_bytes()); |
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.
We need to convert the usize
to u16
first.
for entry in side_table { | ||
wasm.extend_from_slice(&entry.type_idx.to_le_bytes()); | ||
wasm.extend_from_slice(&entry.parser_range.start.to_le_bytes()); | ||
wasm.extend_from_slice(&entry.parser_range.end.to_le_bytes()); |
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.
Same here, usize
has not a fixed size, and we expect a u32
.
wasm.extend_from_slice(&binary[0 .. 8]); | ||
wasm.push(0); | ||
wasm.extend_from_slice(&side_table.len().to_le_bytes()); | ||
for entry in side_table { |
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.
We also need to serialize the indices. Below is just the metadata.
Verify
mode #726.I'll debug in the meanwhile.
#46