mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
wasm: use __data_end to account for all constant data including zero (bss) data
This commit is contained in:
parent
4d14fbf562
commit
9ae26c5aac
3 changed files with 67 additions and 34 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::{fmt::Debug, iter::FromIterator};
|
||||
|
||||
use bumpalo::collections::vec::Vec;
|
||||
use bumpalo::{collections::vec::Vec, Bump};
|
||||
use roc_error_macros::internal_error;
|
||||
|
||||
/// In the WebAssembly binary format, all integers are variable-length encoded (using LEB-128)
|
||||
|
@ -262,6 +262,15 @@ pub fn parse_u32_or_panic(bytes: &[u8], cursor: &mut usize) -> u32 {
|
|||
value
|
||||
}
|
||||
|
||||
pub fn parse_string_bytes<'a>(arena: &'a Bump, bytes: &[u8], cursor: &mut usize) -> &'a [u8] {
|
||||
let len = parse_u32_or_panic(bytes, cursor);
|
||||
let end = *cursor + len as usize;
|
||||
let bytes: &[u8] = &bytes[*cursor..end];
|
||||
let copy = arena.alloc_slice_copy(bytes);
|
||||
*cursor = end;
|
||||
copy
|
||||
}
|
||||
|
||||
/// Skip over serialized bytes for a type
|
||||
/// This may, or may not, require looking at the byte values
|
||||
pub trait SkipBytes {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue