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:
Ivan Enderlin
2019-03-12 22:00:33 +01:00
committed by Mackenzie Clark
parent ef69f6151c
commit 20d1023abe
15 changed files with 177 additions and 210 deletions

View File

@ -1,14 +1,16 @@
#![allow(non_snake_case)]
use crate::env::get_emscripten_data;
use wasmer_runtime_core::vm::Ctx;
pub fn setTempRet0(ctx: &mut Ctx, a: i32) {
pub fn setTempRet0(_ctx: &mut Ctx, _a: i32) {
debug!("emscripten::setTempRet0");
}
pub fn getTempRet0(ctx: &mut Ctx) -> i32 {
pub fn getTempRet0(_ctx: &mut Ctx) -> i32 {
debug!("emscripten::getTempRet0");
0
}
pub fn nullFunc_ji(ctx: &mut Ctx, a: i32) {
pub fn nullFunc_ji(_ctx: &mut Ctx, _a: i32) {
debug!("emscripten::nullFunc_ji");
}
pub fn invoke_i(ctx: &mut Ctx, index: i32) -> i32 {
@ -83,158 +85,166 @@ pub fn invoke_viiii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i3
panic!("dyn_call_viiii is set to None");
}
}
pub fn __Unwind_Backtrace(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn __Unwind_Backtrace(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::__Unwind_Backtrace");
0
}
pub fn __Unwind_FindEnclosingFunction(ctx: &mut Ctx, a: i32) -> i32 {
pub fn __Unwind_FindEnclosingFunction(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::__Unwind_FindEnclosingFunction");
0
}
pub fn __Unwind_GetIPInfo(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn __Unwind_GetIPInfo(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::__Unwind_GetIPInfo");
0
}
pub fn ___cxa_find_matching_catch_2(ctx: &mut Ctx) -> i32 {
pub fn ___cxa_find_matching_catch_2(_ctx: &mut Ctx) -> i32 {
debug!("emscripten::___cxa_find_matching_catch_2");
0
}
pub fn ___cxa_find_matching_catch_3(ctx: &mut Ctx, a: i32) -> i32 {
pub fn ___cxa_find_matching_catch_3(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::___cxa_find_matching_catch_3");
0
}
pub fn ___cxa_free_exception(ctx: &mut Ctx, a: i32) {
pub fn ___cxa_free_exception(_ctx: &mut Ctx, _a: i32) {
debug!("emscripten::___cxa_free_exception");
}
pub fn ___resumeException(ctx: &mut Ctx, a: i32) {
pub fn ___resumeException(_ctx: &mut Ctx, _a: i32) {
debug!("emscripten::___resumeException");
}
pub fn _dladdr(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn _dladdr(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_dladdr");
0
}
pub fn _pthread_cond_destroy(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_cond_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_destroy");
0
}
pub fn _pthread_cond_init(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn _pthread_cond_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_init");
0
}
pub fn _pthread_cond_signal(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_cond_signal(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_cond_signal");
0
}
pub fn _pthread_cond_wait(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn _pthread_cond_wait(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_cond_wait");
0
}
pub fn _pthread_condattr_destroy(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_condattr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_condattr_destroy");
0
}
pub fn _pthread_condattr_init(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_condattr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_condattr_init");
0
}
pub fn _pthread_condattr_setclock(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn _pthread_condattr_setclock(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_condattr_setclock");
0
}
pub fn _pthread_mutex_destroy(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_mutex_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_mutex_destroy");
0
}
pub fn _pthread_mutex_init(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn _pthread_mutex_init(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_mutex_init");
0
}
pub fn _pthread_mutexattr_destroy(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_mutexattr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_mutexattr_destroy");
0
}
pub fn _pthread_mutexattr_init(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_mutexattr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_mutexattr_init");
0
}
pub fn _pthread_mutexattr_settype(ctx: &mut Ctx, a: i32, b: i32) -> i32 {
pub fn _pthread_mutexattr_settype(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
debug!("emscripten::_pthread_mutexattr_settype");
0
}
pub fn _pthread_rwlock_rdlock(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_rwlock_rdlock(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_rdlock");
0
}
pub fn _pthread_rwlock_unlock(ctx: &mut Ctx, a: i32) -> i32 {
pub fn _pthread_rwlock_unlock(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_rwlock_unlock");
0
}
pub fn ___gxx_personality_v0(ctx: &mut Ctx, a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) -> i32 {
pub fn ___gxx_personality_v0(
_ctx: &mut Ctx,
_a: i32,
_b: i32,
_c: i32,
_d: i32,
_e: i32,
_f: i32,
) -> i32 {
debug!("emscripten::___gxx_personality_v0");
0
}
// round 2
pub fn nullFunc_dii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_dii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_dii");
}
pub fn nullFunc_diiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_diiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_diiii");
}
pub fn nullFunc_iiji(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_iiji(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_iiji");
}
pub fn nullFunc_j(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_j(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_j");
}
pub fn nullFunc_jij(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_jij(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_jij");
}
pub fn nullFunc_jjj(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_jjj(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_jjj");
}
pub fn nullFunc_vd(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_vd(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_vd");
}
pub fn nullFunc_viiiiiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viiiiiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viiiiiii");
}
pub fn nullFunc_viiiiiiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viiiiiiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viiiiiiii");
}
pub fn nullFunc_viiiiiiiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viiiiiiiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viiiiiiiii");
}
pub fn nullFunc_viiij(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viiij(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viiij");
}
pub fn nullFunc_viiijiiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viiijiiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viiijiiii");
}
pub fn nullFunc_viiijiiiiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viiijiiiiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viiijiiiiii");
}
pub fn nullFunc_viij(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viij(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viij");
}
pub fn nullFunc_viiji(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viiji(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viiji");
}
pub fn nullFunc_viijiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viijiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viijiii");
}
pub fn nullFunc_viijj(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viijj(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viijj");
}
pub fn nullFunc_vij(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_vij(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_vij");
}
pub fn nullFunc_viji(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_viji(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_viji");
}
pub fn nullFunc_vijiii(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_vijiii(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_vijiii");
}
pub fn nullFunc_vijj(ctx: &mut Ctx, index: i32) {
pub fn nullFunc_vijj(_ctx: &mut Ctx, _index: i32) {
debug!("emscripten::nullFunc_vijj");
}
pub fn invoke_dii(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) -> f64 {