mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Merge branch 'feature/add-all-jobs-to-bors' into feature/improved-tests
This commit is contained in:
commit
beeeb4ebcf
@ -24,12 +24,17 @@ struct Listen {
|
|||||||
socket: String,
|
socket: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "loader:kernel")]
|
||||||
const CMD_RUN_CODE: u32 = 0x901;
|
const CMD_RUN_CODE: u32 = 0x901;
|
||||||
|
#[cfg(feature = "loader:kernel")]
|
||||||
const CMD_READ_MEMORY: u32 = 0x902;
|
const CMD_READ_MEMORY: u32 = 0x902;
|
||||||
|
#[cfg(feature = "loader:kernel")]
|
||||||
const CMD_WRITE_MEMORY: u32 = 0x903;
|
const CMD_WRITE_MEMORY: u32 = 0x903;
|
||||||
|
|
||||||
#[cfg(feature = "loader:kernel")]
|
#[cfg(feature = "loader:kernel")]
|
||||||
fn handle_client(mut stream: UnixStream) {
|
fn handle_client(mut stream: UnixStream) {
|
||||||
|
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
|
||||||
|
use std::io::{Read, Write};
|
||||||
let binary_size = stream.read_u32::<LittleEndian>().unwrap();
|
let binary_size = stream.read_u32::<LittleEndian>().unwrap();
|
||||||
if binary_size > 1048576 * 16 {
|
if binary_size > 1048576 * 16 {
|
||||||
println!("binary too large");
|
println!("binary too large");
|
||||||
@ -38,6 +43,11 @@ fn handle_client(mut stream: UnixStream) {
|
|||||||
let mut wasm_binary: Vec<u8> = Vec::with_capacity(binary_size as usize);
|
let mut wasm_binary: Vec<u8> = Vec::with_capacity(binary_size as usize);
|
||||||
unsafe { wasm_binary.set_len(binary_size as usize) };
|
unsafe { wasm_binary.set_len(binary_size as usize) };
|
||||||
stream.read_exact(&mut wasm_binary).unwrap();
|
stream.read_exact(&mut wasm_binary).unwrap();
|
||||||
|
use wasmer::webassembly;
|
||||||
|
use wasmer_runtime_core::{
|
||||||
|
backend::{CompilerConfig, MemoryBoundCheckMode},
|
||||||
|
loader::Instance,
|
||||||
|
};
|
||||||
let module = webassembly::compile_with_config_with(
|
let module = webassembly::compile_with_config_with(
|
||||||
&wasm_binary[..],
|
&wasm_binary[..],
|
||||||
CompilerConfig {
|
CompilerConfig {
|
||||||
@ -72,6 +82,7 @@ fn handle_client(mut stream: UnixStream) {
|
|||||||
println!("Too many arguments");
|
println!("Too many arguments");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
use wasmer_runtime::Value;
|
||||||
let mut args: Vec<Value> = Vec::with_capacity(arg_count as usize);
|
let mut args: Vec<Value> = Vec::with_capacity(arg_count as usize);
|
||||||
for _ in 0..arg_count {
|
for _ in 0..arg_count {
|
||||||
args.push(Value::I64(stream.read_u64::<LittleEndian>().unwrap() as _));
|
args.push(Value::I64(stream.read_u64::<LittleEndian>().unwrap() as _));
|
||||||
@ -123,6 +134,7 @@ fn handle_client(mut stream: UnixStream) {
|
|||||||
#[cfg(feature = "loader:kernel")]
|
#[cfg(feature = "loader:kernel")]
|
||||||
fn run_listen(opts: Listen) {
|
fn run_listen(opts: Listen) {
|
||||||
let listener = UnixListener::bind(&opts.socket).unwrap();
|
let listener = UnixListener::bind(&opts.socket).unwrap();
|
||||||
|
use std::thread;
|
||||||
for stream in listener.incoming() {
|
for stream in listener.incoming() {
|
||||||
match stream {
|
match stream {
|
||||||
Ok(stream) => {
|
Ok(stream) => {
|
||||||
|
@ -505,7 +505,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
mapped_dirs,
|
mapped_dirs,
|
||||||
);
|
);
|
||||||
|
|
||||||
let instance = module
|
#[allow(unused_mut)] // mut used in feature
|
||||||
|
let mut instance = module
|
||||||
.instantiate(&import_object)
|
.instantiate(&import_object)
|
||||||
.map_err(|e| format!("Can't instantiate module: {:?}", e))?;
|
.map_err(|e| format!("Can't instantiate module: {:?}", e))?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user