mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 10:02:38 +03:00
wasm: add stack_bytes field to Env
This commit is contained in:
parent
11929a7b6d
commit
dd040d5f73
@ -474,6 +474,7 @@ fn gen_from_mono_module_dev_wasm32(
|
||||
arena,
|
||||
module_id,
|
||||
exposed_to_host,
|
||||
stack_bytes: roc_gen_wasm::Env::DEFAULT_STACK_BYTES,
|
||||
};
|
||||
|
||||
let host_bytes = std::fs::read(preprocessed_host_path).unwrap_or_else(|_| {
|
||||
|
@ -272,9 +272,7 @@ impl<'a> WasmBackend<'a> {
|
||||
}
|
||||
|
||||
pub fn finalize(mut self) -> (WasmModule<'a>, BitVec<usize>) {
|
||||
// TODO: get this from a CLI parameter with some default
|
||||
const STACK_SIZE: u32 = 1024 * 1024;
|
||||
self.set_memory_layout(STACK_SIZE);
|
||||
self.set_memory_layout(self.env.stack_bytes);
|
||||
self.export_globals();
|
||||
|
||||
self.maybe_call_host_main();
|
||||
|
@ -45,6 +45,11 @@ pub struct Env<'a> {
|
||||
pub arena: &'a Bump,
|
||||
pub module_id: ModuleId,
|
||||
pub exposed_to_host: MutSet<Symbol>,
|
||||
pub stack_bytes: u32,
|
||||
}
|
||||
|
||||
impl Env<'_> {
|
||||
pub const DEFAULT_STACK_BYTES: u32 = 1024 * 1024;
|
||||
}
|
||||
|
||||
/// Parse the preprocessed host binary
|
||||
|
@ -122,6 +122,7 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
|
||||
arena,
|
||||
module_id,
|
||||
exposed_to_host,
|
||||
stack_bytes: roc_gen_wasm::Env::DEFAULT_STACK_BYTES,
|
||||
};
|
||||
|
||||
let host_module = roc_gen_wasm::parse_host(env.arena, host_bytes).unwrap_or_else(|e| {
|
||||
|
@ -161,6 +161,7 @@ impl<'a> BackendInputs<'a> {
|
||||
arena,
|
||||
module_id,
|
||||
exposed_to_host,
|
||||
stack_bytes: Env::DEFAULT_STACK_BYTES,
|
||||
};
|
||||
|
||||
// Identifier stuff for the backend
|
||||
|
@ -213,6 +213,7 @@ pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
|
||||
let env = roc_gen_wasm::Env {
|
||||
arena,
|
||||
module_id,
|
||||
stack_bytes: roc_gen_wasm::Env::DEFAULT_STACK_BYTES,
|
||||
exposed_to_host: exposed_to_host
|
||||
.values
|
||||
.keys()
|
||||
|
Loading…
Reference in New Issue
Block a user