mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-01 13:34:15 +00:00
Move some wasm constants and macros
This commit is contained in:
parent
63d9187343
commit
2e67bdf4d0
4 changed files with 31 additions and 29 deletions
|
|
@ -19,8 +19,8 @@ use crate::layout::{CallConv, ReturnMethod, WasmLayout};
|
|||
use crate::low_level::{call_higher_order_lowlevel, LowLevelCall};
|
||||
use crate::storage::{AddressValue, Storage, StoredValue, StoredVarKind};
|
||||
use crate::{
|
||||
copy_memory, round_up_to_alignment, CopyMemoryConfig, Env, DEBUG_SETTINGS, MEMORY_NAME,
|
||||
PTR_SIZE, PTR_TYPE, TARGET_INFO,
|
||||
copy_memory, CopyMemoryConfig, Env, DEBUG_SETTINGS, MEMORY_NAME, PTR_SIZE, PTR_TYPE,
|
||||
TARGET_INFO,
|
||||
};
|
||||
use roc_wasm_module::linking::{DataSymbol, WasmObjectSymbol};
|
||||
use roc_wasm_module::sections::{
|
||||
|
|
@ -28,7 +28,8 @@ use roc_wasm_module::sections::{
|
|||
MemorySection, NameSection,
|
||||
};
|
||||
use roc_wasm_module::{
|
||||
code_builder, CodeBuilder, ExportType, LocalId, Signature, SymInfo, ValueType, WasmModule,
|
||||
code_builder, round_up_to_alignment, CodeBuilder, ExportType, LocalId, Signature, SymInfo,
|
||||
ValueType, WasmModule,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ const PTR_SIZE: u32 = {
|
|||
};
|
||||
const PTR_TYPE: ValueType = ValueType::I32;
|
||||
|
||||
pub const STACK_POINTER_GLOBAL_ID: u32 = 0;
|
||||
pub const FRAME_ALIGNMENT_BYTES: i32 = 16;
|
||||
pub const MEMORY_NAME: &str = "memory";
|
||||
pub const BUILTINS_IMPORT_MODULE_NAME: &str = "env";
|
||||
pub const STACK_POINTER_NAME: &str = "__stack_pointer";
|
||||
|
|
@ -234,26 +232,6 @@ pub fn copy_memory(code_builder: &mut CodeBuilder, config: CopyMemoryConfig) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Round up to alignment_bytes (which must be a power of 2)
|
||||
#[macro_export]
|
||||
macro_rules! round_up_to_alignment {
|
||||
($unaligned: expr, $alignment_bytes: expr) => {
|
||||
if $alignment_bytes <= 1 {
|
||||
$unaligned
|
||||
} else if $alignment_bytes.count_ones() != 1 {
|
||||
internal_error!(
|
||||
"Cannot align to {} bytes. Not a power of 2.",
|
||||
$alignment_bytes
|
||||
);
|
||||
} else {
|
||||
let mut aligned = $unaligned;
|
||||
aligned += $alignment_bytes - 1; // if lower bits are non-zero, push it over the next boundary
|
||||
aligned &= !$alignment_bytes + 1; // mask with a flag that has upper bits 1, lower bits 0
|
||||
aligned
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub struct WasmDebugSettings {
|
||||
proc_start_end: bool,
|
||||
user_procs_ir: bool,
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ use roc_module::symbol::Symbol;
|
|||
use roc_mono::layout::{Layout, STLayoutInterner};
|
||||
|
||||
use crate::layout::{CallConv, ReturnMethod, StackMemoryFormat, WasmLayout};
|
||||
use crate::{copy_memory, round_up_to_alignment, CopyMemoryConfig, PTR_TYPE};
|
||||
use roc_wasm_module::{Align, CodeBuilder, LocalId, ValueType, VmSymbolState};
|
||||
use crate::{copy_memory, CopyMemoryConfig, PTR_TYPE};
|
||||
use roc_wasm_module::{
|
||||
round_up_to_alignment, Align, CodeBuilder, LocalId, ValueType, VmSymbolState,
|
||||
};
|
||||
|
||||
pub enum StoredVarKind {
|
||||
Variable,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue