Create serializer module

This commit is contained in:
Brian Carroll 2021-10-28 10:59:35 +01:00
parent eb47b5183c
commit 82acf55d38
5 changed files with 298 additions and 231 deletions

View file

@ -10,8 +10,9 @@ use roc_mono::layout::{Builtin, Layout};
use crate::code_builder::{BlockType, CodeBuilder, ValueType};
use crate::layout::WasmLayout;
use crate::serialize::SerialBuffer;
use crate::storage::{Storage, StoredValue, StoredValueKind};
use crate::{copy_memory, overwrite_padded_u32, CopyMemoryConfig, Env, LocalId, PTR_TYPE};
use crate::{copy_memory, CopyMemoryConfig, Env, LocalId, PTR_TYPE};
// Don't allocate any constant data at address zero or near it. Would be valid, but bug-prone.
// Follow Emscripten's example by using 1kB (4 bytes would probably do)
@ -49,7 +50,7 @@ impl<'a> WasmBackend<'a> {
// Reserve space for code section header: inner byte length and number of functions
// Padded to the maximum 5 bytes each, so we can update later without moving everything
code_section_bytes.resize(10, 0);
overwrite_padded_u32(&mut code_section_bytes[5..10], proc_symbols.len() as u32); // gets modified in unit tests
code_section_bytes.overwrite_padded_u32(5, proc_symbols.len() as u32); // gets modified in unit tests
WasmBackend {
env,