mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-17 19:01:20 +00:00
fix(emscripten) Various warning fixes and cleanups (#266)
* fix(emscripten) Remove unused imports. This patch removes unused imports reported by `rustc` as warnings. * fix(emscripten) Allow unreachable patterns in `_clock_gettime`. The compiler thinks `CLOCK_MONOTONIC_COARSE` is unreachable, which is not always the case. Add an attribute to allow unreachable patterns to remove the warning. * fix(emscripten) Rename unused variables. This patch renames various unused variables by appending an underscore to them. * fix(emscripten) Declare `table` as immutable. The `table` variable in `EmscriptenGlobals::new` was declared as mutable, but it's never mutated. * fix(emscripten) Remove an unnecessary `unsafe` block. * fix(emscripten) Remove duplicate definition of `SO_NOSIGPIPE`. The `SO_NOSIGPIPE` constant is defined in `syscalls/mod.rs` and `syscalls/unix.rs`. It's never used in the first case. We can safely remove it in this file, and keep it in `unix.rs`. * fix(emscripten) `read_string_from_wasm` is used only on Windows. Mark `read_string_from_wasm` as possible deadcode, since it's used only on Windows. * fix(emscripten) Remove `DYNAMICTOP_PTR_DIFF`, `stacktop`, `stack_max`, `dynamic_base` and `dynamic_ptr`. Four functions and one constant are used together but never used inside or outside this file. They are deadcode. * fix(emscripten) Remove `infinity` and `nan` fields of `EmscriptenGlobalsData`. Those fields are never used. * fix(emscripten) Allow non snake case in `emscripten_target.rs`. Many functions in this file don't follow the snake case style for Rust function names. The reason is that we want the names to match the emscripten symbol names; even if a mapping is done in `lib.rs`, it's easier to get the same names. * fix(emscripten) Rename `STATIC_TOP` to `static_top`. This variable is not a constant.
This commit is contained in:
committed by
Mackenzie Clark
parent
ef69f6151c
commit
20d1023abe
@ -56,8 +56,6 @@ pub use self::utils::{
|
||||
|
||||
// TODO: Magic number - how is this calculated?
|
||||
const TOTAL_STACK: u32 = 5_242_880;
|
||||
// TODO: Magic number - how is this calculated?
|
||||
const DYNAMICTOP_PTR_DIFF: u32 = 1088;
|
||||
// TODO: make this variable
|
||||
const STATIC_BUMP: u32 = 215_536;
|
||||
|
||||
@ -73,22 +71,6 @@ lazy_static! {
|
||||
const GLOBAL_BASE: u32 = 1024;
|
||||
const STATIC_BASE: u32 = GLOBAL_BASE;
|
||||
|
||||
fn stacktop(static_bump: u32) -> u32 {
|
||||
align_memory(dynamictop_ptr(static_bump) + 4)
|
||||
}
|
||||
|
||||
fn stack_max(static_bump: u32) -> u32 {
|
||||
stacktop(static_bump) + TOTAL_STACK
|
||||
}
|
||||
|
||||
fn dynamic_base(static_bump: u32) -> u32 {
|
||||
align_memory(stack_max(static_bump))
|
||||
}
|
||||
|
||||
fn dynamictop_ptr(static_bump: u32) -> u32 {
|
||||
static_bump + DYNAMICTOP_PTR_DIFF
|
||||
}
|
||||
|
||||
pub struct EmscriptenData<'a> {
|
||||
pub malloc: Func<'a, u32, u32>,
|
||||
pub free: Func<'a, u32>,
|
||||
@ -311,10 +293,6 @@ pub struct EmscriptenGlobalsData {
|
||||
table_base: u32,
|
||||
temp_double_ptr: u32,
|
||||
use_old_abort_on_cannot_grow_memory: bool,
|
||||
|
||||
// Global namespace
|
||||
infinity: f64,
|
||||
nan: f64,
|
||||
}
|
||||
|
||||
pub struct EmscriptenGlobals {
|
||||
@ -366,22 +344,22 @@ impl EmscriptenGlobals {
|
||||
minimum: table_min,
|
||||
maximum: table_max,
|
||||
};
|
||||
let mut table = Table::new(table_type).unwrap();
|
||||
let table = Table::new(table_type).unwrap();
|
||||
|
||||
let data = {
|
||||
let static_bump = STATIC_BUMP;
|
||||
|
||||
let mut STATIC_TOP = STATIC_BASE + static_bump;
|
||||
let mut static_top = STATIC_BASE + static_bump;
|
||||
|
||||
let memory_base = STATIC_BASE;
|
||||
let table_base = 0;
|
||||
|
||||
let temp_double_ptr = STATIC_TOP;
|
||||
STATIC_TOP += 16;
|
||||
let temp_double_ptr = static_top;
|
||||
static_top += 16;
|
||||
|
||||
let dynamictop_ptr = static_alloc(&mut STATIC_TOP, 4);
|
||||
let dynamictop_ptr = static_alloc(&mut static_top, 4);
|
||||
|
||||
let stacktop = align_memory(STATIC_TOP);
|
||||
let stacktop = align_memory(static_top);
|
||||
let stack_max = stacktop + TOTAL_STACK;
|
||||
|
||||
EmscriptenGlobalsData {
|
||||
@ -393,9 +371,6 @@ impl EmscriptenGlobals {
|
||||
table_base,
|
||||
temp_double_ptr,
|
||||
use_old_abort_on_cannot_grow_memory,
|
||||
|
||||
infinity: std::f64::INFINITY,
|
||||
nan: std::f64::NAN,
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user