mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Merge remote-tracking branch 'origin/master' into feature/dynasm-backend
This commit is contained in:
commit
08f4526b45
@ -27,7 +27,7 @@ wasmer-runtime-core = { path = "lib/runtime-core" }
|
|||||||
wasmer-emscripten = { path = "lib/emscripten" }
|
wasmer-emscripten = { path = "lib/emscripten" }
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
wasmer-llvm-backend = { path = "lib/llvm-backend" }
|
wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["lib/clif-backend", "lib/dynasm-backend", "lib/runtime", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend"]
|
members = ["lib/clif-backend", "lib/dynasm-backend", "lib/runtime", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend"]
|
||||||
@ -37,8 +37,8 @@ wabt = "0.7.2"
|
|||||||
glob = "0.2.11"
|
glob = "0.2.11"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["fast-tests"]
|
|
||||||
|
|
||||||
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
|
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
|
||||||
|
default = ["fast-tests"]
|
||||||
# This feature will allow cargo test to run much faster
|
# This feature will allow cargo test to run much faster
|
||||||
fast-tests = []
|
fast-tests = []
|
||||||
|
llvm = ["wasmer-llvm-backend"]
|
||||||
|
@ -4,13 +4,9 @@ use crate::trampoline::Trampoline;
|
|||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use wasmer_runtime_core::error::{RuntimeError, RuntimeResult};
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
use wasmer_runtime_core::vm::Func;
|
use wasmer_runtime_core::vm::Func;
|
||||||
use wasmer_runtime_core::{
|
|
||||||
error::{RuntimeError, RuntimeResult},
|
|
||||||
structures::TypedIndex,
|
|
||||||
types::{MemoryIndex, TableIndex},
|
|
||||||
};
|
|
||||||
use wasmer_win_exception_handler::CallProtectedData;
|
use wasmer_win_exception_handler::CallProtectedData;
|
||||||
pub use wasmer_win_exception_handler::_call_protected;
|
pub use wasmer_win_exception_handler::_call_protected;
|
||||||
use winapi::shared::minwindef::DWORD;
|
use winapi::shared::minwindef::DWORD;
|
||||||
@ -47,8 +43,8 @@ pub fn call_protected(
|
|||||||
|
|
||||||
let CallProtectedData {
|
let CallProtectedData {
|
||||||
code: signum,
|
code: signum,
|
||||||
exceptionAddress: exception_address,
|
exception_address,
|
||||||
instructionPointer: instruction_pointer,
|
instruction_pointer,
|
||||||
} = result.unwrap_err();
|
} = result.unwrap_err();
|
||||||
|
|
||||||
if let Some(TrapData {
|
if let Some(TrapData {
|
||||||
|
2
lib/emscripten/src/env/unix/mod.rs
vendored
2
lib/emscripten/src/env/unix/mod.rs
vendored
@ -66,6 +66,8 @@ pub fn _unsetenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
|||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||||
debug!("emscripten::_getpwnam {}", name_ptr);
|
debug!("emscripten::_getpwnam {}", name_ptr);
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
let _ = name_ptr;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct GuestPasswd {
|
struct GuestPasswd {
|
||||||
|
18
lib/emscripten/src/env/windows/mod.rs
vendored
18
lib/emscripten/src/env/windows/mod.rs
vendored
@ -7,7 +7,6 @@ use std::os::raw::c_char;
|
|||||||
|
|
||||||
use crate::env::call_malloc;
|
use crate::env::call_malloc;
|
||||||
use crate::utils::{copy_cstr_into_wasm, read_string_from_wasm};
|
use crate::utils::{copy_cstr_into_wasm, read_string_from_wasm};
|
||||||
use std::ffi::CStr;
|
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -29,10 +28,8 @@ pub fn _getenv(ctx: &mut Ctx, name: u32) -> u32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
|
/// emscripten: _setenv // (name: *const char, name: *const value, overwrite: int);
|
||||||
pub fn _setenv(ctx: &mut Ctx, name: u32, value: u32, overwrite: u32) -> c_int {
|
pub fn _setenv(ctx: &mut Ctx, name: u32, value: u32, _overwrite: u32) -> c_int {
|
||||||
debug!("emscripten::_setenv");
|
debug!("emscripten::_setenv");
|
||||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name);
|
|
||||||
let value_addr = emscripten_memory_pointer!(ctx.memory(0), value);
|
|
||||||
// setenv does not exist on windows, so we hack it with _putenv
|
// setenv does not exist on windows, so we hack it with _putenv
|
||||||
let name = read_string_from_wasm(ctx.memory(0), name);
|
let name = read_string_from_wasm(ctx.memory(0), name);
|
||||||
let value = read_string_from_wasm(ctx.memory(0), value);
|
let value = read_string_from_wasm(ctx.memory(0), value);
|
||||||
@ -47,17 +44,16 @@ pub fn _setenv(ctx: &mut Ctx, name: u32, value: u32, overwrite: u32) -> c_int {
|
|||||||
/// emscripten: _putenv // (name: *const char);
|
/// emscripten: _putenv // (name: *const char);
|
||||||
pub fn _putenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
pub fn _putenv(ctx: &mut Ctx, name: c_int) -> c_int {
|
||||||
debug!("emscripten::_putenv");
|
debug!("emscripten::_putenv");
|
||||||
|
|
||||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name) as *const c_char;
|
||||||
|
debug!("=> name({:?})", unsafe {
|
||||||
debug!("=> name({:?})", unsafe { CStr::from_ptr(name_addr) });
|
std::ffi::CStr::from_ptr(name_addr)
|
||||||
|
});
|
||||||
unsafe { putenv(name_addr) }
|
unsafe { putenv(name_addr) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// emscripten: _unsetenv // (name: *const char);
|
/// emscripten: _unsetenv // (name: *const char);
|
||||||
pub fn _unsetenv(ctx: &mut Ctx, name: u32) -> c_int {
|
pub fn _unsetenv(ctx: &mut Ctx, name: u32) -> c_int {
|
||||||
debug!("emscripten::_unsetenv");
|
debug!("emscripten::_unsetenv");
|
||||||
let name_addr = emscripten_memory_pointer!(ctx.memory(0), name);
|
|
||||||
let name = read_string_from_wasm(ctx.memory(0), name);
|
let name = read_string_from_wasm(ctx.memory(0), name);
|
||||||
// no unsetenv on windows, so use putenv with an empty value
|
// no unsetenv on windows, so use putenv with an empty value
|
||||||
let unsetenv_string = format!("{}=", name);
|
let unsetenv_string = format!("{}=", name);
|
||||||
@ -70,6 +66,8 @@ pub fn _unsetenv(ctx: &mut Ctx, name: u32) -> c_int {
|
|||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||||
debug!("emscripten::_getpwnam {}", name_ptr);
|
debug!("emscripten::_getpwnam {}", name_ptr);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = name_ptr;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct GuestPasswd {
|
struct GuestPasswd {
|
||||||
@ -102,6 +100,8 @@ pub fn _getpwnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
|||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
||||||
debug!("emscripten::_getgrnam {}", name_ptr);
|
debug!("emscripten::_getgrnam {}", name_ptr);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = name_ptr;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
struct GuestGroup {
|
struct GuestGroup {
|
||||||
@ -126,6 +126,8 @@ pub fn _getgrnam(ctx: &mut Ctx, name_ptr: c_int) -> c_int {
|
|||||||
|
|
||||||
pub fn _sysconf(_ctx: &mut Ctx, name: c_int) -> c_long {
|
pub fn _sysconf(_ctx: &mut Ctx, name: c_int) -> c_long {
|
||||||
debug!("emscripten::_sysconf {}", name);
|
debug!("emscripten::_sysconf {}", name);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = name;
|
||||||
// stub because sysconf is not valid on windows
|
// stub because sysconf is not valid on windows
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use libc::{c_char, c_int};
|
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
// This may be problematic for msvc which uses inline functions for the printf family
|
// This may be problematic for msvc which uses inline functions for the printf family
|
||||||
@ -15,13 +14,18 @@ use wasmer_runtime_core::vm::Ctx;
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
/// putchar
|
/// putchar
|
||||||
pub fn putchar(ctx: &mut Ctx, chr: i32) {
|
pub fn putchar(_ctx: &mut Ctx, chr: i32) {
|
||||||
unsafe { libc::putchar(chr) };
|
unsafe { libc::putchar(chr) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printf
|
/// printf
|
||||||
pub fn printf(ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
pub fn printf(_ctx: &mut Ctx, memory_offset: i32, extra: i32) -> i32 {
|
||||||
debug!("emscripten::printf {}, {}", memory_offset, extra);
|
debug!("emscripten::printf {}, {}", memory_offset, extra);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
{
|
||||||
|
let _ = memory_offset;
|
||||||
|
let _ = extra;
|
||||||
|
}
|
||||||
// unsafe {
|
// unsafe {
|
||||||
// let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _;
|
// let addr = emscripten_memory_pointer!(ctx.memory(0), memory_offset) as _;
|
||||||
// _printf(addr, extra)
|
// _printf(addr, extra)
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
use libc::{abort, c_char, c_int, exit, EAGAIN};
|
use libc::{abort, c_char, c_int, exit, EAGAIN};
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
use libc::pid_t;
|
type PidT = libc::pid_t;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
type pid_t = c_int;
|
type PidT = c_int;
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
@ -22,7 +21,7 @@ pub fn _abort(_ctx: &mut Ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _fork(_ctx: &mut Ctx) -> pid_t {
|
pub fn _fork(_ctx: &mut Ctx) -> PidT {
|
||||||
debug!("emscripten::_fork");
|
debug!("emscripten::_fork");
|
||||||
// unsafe {
|
// unsafe {
|
||||||
// fork()
|
// fork()
|
||||||
|
@ -15,7 +15,7 @@ pub struct StdioCapturer {
|
|||||||
use libc::{STDERR_FILENO, STDOUT_FILENO};
|
use libc::{STDERR_FILENO, STDOUT_FILENO};
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const STDIN_FILENO: libc::c_int = 0;
|
const _STDIN_FILENO: libc::c_int = 0;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
const STDOUT_FILENO: libc::c_int = 1;
|
const STDOUT_FILENO: libc::c_int = 1;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
@ -4,18 +4,20 @@ use libc::mkdir;
|
|||||||
use libc::open;
|
use libc::open;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::ffi::CStr;
|
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
use wasmer_runtime_core::vm::Ctx;
|
use wasmer_runtime_core::vm::Ctx;
|
||||||
|
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
type pid_t = c_int;
|
type pid_t = c_int;
|
||||||
|
|
||||||
/// open
|
/// open
|
||||||
pub fn ___syscall5(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall5(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall5 (open) {}", which);
|
debug!("emscripten::___syscall5 (open) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
let pathname: u32 = varargs.get(ctx);
|
let pathname: u32 = varargs.get(ctx);
|
||||||
let flags: i32 = varargs.get(ctx);
|
let flags: i32 = varargs.get(ctx);
|
||||||
let mode: u32 = varargs.get(ctx);
|
let mode: u32 = varargs.get(ctx);
|
||||||
@ -33,15 +35,15 @@ pub fn ___syscall5(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
|||||||
let mut urandom_file = File::create(tmp_dir).unwrap();
|
let mut urandom_file = File::create(tmp_dir).unwrap();
|
||||||
// create some random bytes and put them into the file
|
// create some random bytes and put them into the file
|
||||||
let random_bytes = rand::thread_rng().gen::<[u8; 32]>();
|
let random_bytes = rand::thread_rng().gen::<[u8; 32]>();
|
||||||
urandom_file.write_all(&random_bytes);
|
let _ = urandom_file.write_all(&random_bytes).unwrap();
|
||||||
// put the file path string into wasm memory
|
// put the file path string into wasm memory
|
||||||
let urandom_file_offset = unsafe { copy_cstr_into_wasm(ctx, ptr) };
|
let urandom_file_offset = unsafe { copy_cstr_into_wasm(ctx, ptr) };
|
||||||
let raw_pointer_to_urandom_file =
|
let raw_pointer_to_urandom_file =
|
||||||
emscripten_memory_pointer!(ctx.memory(0), urandom_file_offset) as *const i8;
|
emscripten_memory_pointer!(ctx.memory(0), urandom_file_offset) as *const i8;
|
||||||
let fd = unsafe { open(raw_pointer_to_urandom_file, flags, mode) };
|
let fd = unsafe { open(raw_pointer_to_urandom_file, flags, mode) };
|
||||||
debug!(
|
debug!(
|
||||||
"=> pathname: {}, flags: {}, mode: {} = fd: {}\npath: {}",
|
"=> pathname: {}, flags: {}, mode: {} = fd: {}",
|
||||||
pathname, flags, mode, fd, s
|
pathname, flags, mode, fd
|
||||||
);
|
);
|
||||||
fd
|
fd
|
||||||
}
|
}
|
||||||
@ -57,16 +59,19 @@ pub fn ___syscall5(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// chown
|
// chown
|
||||||
pub fn ___syscall212(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall212(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall212 (chown) {}", which);
|
debug!("emscripten::___syscall212 (chown) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// mkdir
|
// mkdir
|
||||||
pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall39(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall39 (mkdir) {}", which);
|
debug!("emscripten::___syscall39 (mkdir) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
let pathname: u32 = varargs.get(ctx);
|
let pathname: u32 = varargs.get(ctx);
|
||||||
let mode: u32 = varargs.get(ctx);
|
|
||||||
let pathname_addr = emscripten_memory_pointer!(ctx.memory(0), pathname) as *const i8;
|
let pathname_addr = emscripten_memory_pointer!(ctx.memory(0), pathname) as *const i8;
|
||||||
unsafe { mkdir(pathname_addr) }
|
unsafe { mkdir(pathname_addr) }
|
||||||
}
|
}
|
||||||
@ -85,59 +90,73 @@ pub fn ___syscall202(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// dup3
|
/// dup3
|
||||||
pub fn ___syscall330(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t {
|
pub fn ___syscall330(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
||||||
debug!("emscripten::___syscall330 (dup3)");
|
debug!("emscripten::___syscall330 (dup3)");
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ioctl
|
/// ioctl
|
||||||
pub fn ___syscall54(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall54(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall54 (ioctl) {}", which);
|
debug!("emscripten::___syscall54 (ioctl) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// socketcall
|
// socketcall
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub fn ___syscall102(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall102(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall102 (socketcall) {}", which);
|
debug!("emscripten::___syscall102 (socketcall) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// pread
|
// pread
|
||||||
pub fn ___syscall180(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall180(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall180 (pread) {}", which);
|
debug!("emscripten::___syscall180 (pread) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// pwrite
|
// pwrite
|
||||||
pub fn ___syscall181(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall181(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall181 (pwrite) {}", which);
|
debug!("emscripten::___syscall181 (pwrite) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// wait4
|
/// wait4
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub fn ___syscall114(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> pid_t {
|
pub fn ___syscall114(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> pid_t {
|
||||||
debug!("emscripten::___syscall114 (wait4)");
|
debug!("emscripten::___syscall114 (wait4)");
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// select
|
// select
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub fn ___syscall142(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall142(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall142 (newselect) {}", which);
|
debug!("emscripten::___syscall142 (newselect) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
// setpgid
|
// setpgid
|
||||||
pub fn ___syscall57(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall57(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall57 (setpgid) {}", which);
|
debug!("emscripten::___syscall57 (setpgid) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// uname
|
/// uname
|
||||||
// NOTE: Wondering if we should return custom utsname, like Emscripten.
|
// NOTE: Wondering if we should return custom utsname, like Emscripten.
|
||||||
pub fn ___syscall122(ctx: &mut Ctx, which: c_int, mut varargs: VarArgs) -> c_int {
|
pub fn ___syscall122(_ctx: &mut Ctx, which: c_int, mut _varargs: VarArgs) -> c_int {
|
||||||
debug!("emscripten::___syscall122 (uname) {}", which);
|
debug!("emscripten::___syscall122 (uname) {}", which);
|
||||||
|
#[cfg(not(feature = "debug"))]
|
||||||
|
let _ = which;
|
||||||
-1
|
-1
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ use libc::{clockid_t, time as libc_time};
|
|||||||
use libc::time_t;
|
use libc::time_t;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
type clockid_t = c_int;
|
type clockid_t = c_int;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
@ -90,6 +90,7 @@ pub unsafe fn allocate_cstr_on_stack<'a>(ctx: &'a mut Ctx, s: &str) -> (u32, &'a
|
|||||||
(offset, slice)
|
(offset, slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &mut Ctx, cstrs: *mut *mut c_char) -> u32 {
|
pub unsafe fn copy_terminated_array_of_cstrs(_ctx: &mut Ctx, cstrs: *mut *mut c_char) -> u32 {
|
||||||
let _total_num = {
|
let _total_num = {
|
||||||
let mut ptr = cstrs;
|
let mut ptr = cstrs;
|
||||||
|
@ -159,13 +159,13 @@ pub struct wasmer_byte_array {
|
|||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn wasmer_validate(
|
pub unsafe extern "C" fn wasmer_validate(
|
||||||
wasm_bytes: *mut uint8_t,
|
wasm_bytes: *const uint8_t,
|
||||||
wasm_bytes_len: uint32_t,
|
wasm_bytes_len: uint32_t,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if wasm_bytes.is_null() {
|
if wasm_bytes.is_null() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let bytes: &[u8] = ::std::slice::from_raw_parts_mut(wasm_bytes, wasm_bytes_len as usize);
|
let bytes: &[u8] = ::std::slice::from_raw_parts(wasm_bytes, wasm_bytes_len as usize);
|
||||||
|
|
||||||
wasmer_runtime_core::validate(bytes)
|
wasmer_runtime_core::validate(bytes)
|
||||||
}
|
}
|
||||||
|
@ -535,6 +535,6 @@ wasmer_result_t wasmer_table_new(wasmer_table_t **table, wasmer_limits_t limits)
|
|||||||
/**
|
/**
|
||||||
* Returns true for valid wasm bytes and false for invalid bytes
|
* Returns true for valid wasm bytes and false for invalid bytes
|
||||||
*/
|
*/
|
||||||
bool wasmer_validate(uint8_t *wasm_bytes, uint32_t wasm_bytes_len);
|
bool wasmer_validate(const uint8_t *wasm_bytes, uint32_t wasm_bytes_len);
|
||||||
|
|
||||||
#endif /* WASMER_H */
|
#endif /* WASMER_H */
|
||||||
|
@ -418,7 +418,7 @@ uint32_t wasmer_table_length(wasmer_table_t *table);
|
|||||||
wasmer_result_t wasmer_table_new(wasmer_table_t **table, wasmer_limits_t limits);
|
wasmer_result_t wasmer_table_new(wasmer_table_t **table, wasmer_limits_t limits);
|
||||||
|
|
||||||
/// Returns true for valid wasm bytes and false for invalid bytes
|
/// Returns true for valid wasm bytes and false for invalid bytes
|
||||||
bool wasmer_validate(uint8_t *wasm_bytes, uint32_t wasm_bytes_len);
|
bool wasmer_validate(const uint8_t *wasm_bytes, uint32_t wasm_bytes_len);
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
|
@ -284,6 +284,7 @@ impl Clone for UnsharedMemory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct SharedMemory {
|
pub struct SharedMemory {
|
||||||
|
#[allow(dead_code)]
|
||||||
desc: MemoryDescriptor,
|
desc: MemoryDescriptor,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,12 +29,14 @@ wabt = "0.7.4"
|
|||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies.wasmer-llvm-backend]
|
[target.'cfg(not(windows))'.dependencies.wasmer-llvm-backend]
|
||||||
path = "../llvm-backend"
|
path = "../llvm-backend"
|
||||||
|
optional = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["default-compiler"]
|
default = ["default-compiler"]
|
||||||
default-compiler = ["wasmer-clif-backend", "wasmer-dynasm-backend"]
|
default-compiler = ["wasmer-clif-backend", "wasmer-dynasm-backend"]
|
||||||
cache = ["default-compiler"]
|
cache = ["default-compiler"]
|
||||||
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
|
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
|
||||||
|
llvm = ["wasmer-llvm-backend"]
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "nginx"
|
name = "nginx"
|
||||||
|
@ -19,12 +19,12 @@ wasmer-clif-backend = { path = "../clif-backend", version = "0.2.0" }
|
|||||||
wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0" }
|
wasmer-dynasm-backend = { path = "../dynasm-backend", version = "0.1.0" }
|
||||||
wabt = "0.7.2"
|
wabt = "0.7.2"
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dev-dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0" }
|
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.1.0", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["fast-tests"]
|
default = ["fast-tests"]
|
||||||
fast-tests = []
|
fast-tests = []
|
||||||
clif = []
|
clif = []
|
||||||
llvm = []
|
llvm = ["wasmer-llvm-backend"]
|
||||||
dynasm = []
|
dynasm = []
|
@ -67,16 +67,16 @@ uint8_t callProtected(trampoline_t trampoline,
|
|||||||
savedStackPointer = get_callee_frame_address();
|
savedStackPointer = get_callee_frame_address();
|
||||||
trampoline(ctx, func, param_vec, return_vec);
|
trampoline(ctx, func, param_vec, return_vec);
|
||||||
out_result->code = 0;
|
out_result->code = 0;
|
||||||
out_result->exceptionAddress = 0;
|
out_result->exception_address = 0;
|
||||||
out_result->instructionPointer = 0;
|
out_result->instruction_pointer = 0;
|
||||||
|
|
||||||
removeExceptionHandler();
|
removeExceptionHandler();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_result->code = (uint64_t)signum;
|
out_result->code = (uint64_t)signum;
|
||||||
out_result->exceptionAddress = (uint64_t)caughtExceptionAddress;
|
out_result->exception_address = (uint64_t)caughtExceptionAddress;
|
||||||
out_result->instructionPointer = caughtInstructionPointer;
|
out_result->instruction_pointer = caughtInstructionPointer;
|
||||||
|
|
||||||
caughtExceptionAddress = 0;
|
caughtExceptionAddress = 0;
|
||||||
caughtInstructionPointer = 0;
|
caughtInstructionPointer = 0;
|
||||||
|
@ -10,8 +10,8 @@ typedef void(*trampoline_t)(struct wasmer_instance_context_t*, const struct fun
|
|||||||
|
|
||||||
struct call_protected_result_t {
|
struct call_protected_result_t {
|
||||||
uint64_t code;
|
uint64_t code;
|
||||||
uint64_t exceptionAddress;
|
uint64_t exception_address;
|
||||||
uint64_t instructionPointer;
|
uint64_t instruction_pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t callProtected(
|
uint8_t callProtected(
|
||||||
|
@ -7,8 +7,8 @@ type CallProtectedResult = Result<(), CallProtectedData>;
|
|||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct CallProtectedData {
|
pub struct CallProtectedData {
|
||||||
pub code: u64,
|
pub code: u64,
|
||||||
pub exceptionAddress: u64,
|
pub exception_address: u64,
|
||||||
pub instructionPointer: u64,
|
pub instruction_pointer: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -32,8 +32,8 @@ pub fn _call_protected(
|
|||||||
) -> CallProtectedResult {
|
) -> CallProtectedResult {
|
||||||
let mut out_result = CallProtectedData {
|
let mut out_result = CallProtectedData {
|
||||||
code: 0,
|
code: 0,
|
||||||
exceptionAddress: 0,
|
exception_address: 0,
|
||||||
instructionPointer: 0,
|
instruction_pointer: 0,
|
||||||
};
|
};
|
||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
__call_protected(
|
__call_protected(
|
||||||
|
Loading…
Reference in New Issue
Block a user