Skip to content

Commit

Permalink
Merge wasmerio#557
Browse files Browse the repository at this point in the history
557: Update loader-kernel feature name, fix compilation track state r=syrusakbary a=bjfish

- feature name `loader:kernel` -> `loader-kernel` (no colons)
- add track state `false` to loader kernel default, @losfair let me know if this default is incorrect
- cargo fmt

Co-authored-by: Brandon Fish <[email protected]>
  • Loading branch information
bors[bot] and bjfish committed Jul 13, 2019
2 parents 09db8d6 + ed19fd2 commit 13abdfe
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ rustc_version = "0.2.3"

[features]
default = ["fast-tests", "wasi"]
"loader:kernel" = ["wasmer-kernel-loader"]
"loader-kernel" = ["wasmer-kernel-loader"]
debug = ["wasmer-runtime-core/debug"]
trace = ["wasmer-runtime-core/trace"]
extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ install:
cargo install --path .

check:
cargo check --release --features backend-singlepass,backend-llvm,loader:kernel
cargo check --release --features backend-singlepass,backend-llvm,loader-kernel

release:
cargo build --release --features backend-singlepass,backend-llvm,loader:kernel
cargo build --release --features backend-singlepass,backend-llvm,loader-kernel

# Only one backend (cranelift)
release-fast:
Expand Down
11 changes: 7 additions & 4 deletions lib/singlepass-backend/src/codegen_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
.unwrap()
.insert(a.get_offset(), callback);
}
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {},
InternalEvent::FunctionBegin(_) | InternalEvent::FunctionEnd => {}
InternalEvent::GetInternal(idx) => {
let idx = idx as usize;
assert!(idx < INTERNALS_SIZE);
Expand Down Expand Up @@ -1826,7 +1826,11 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
),
Location::GPR(tmp),
);
let loc = get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap());
let loc = get_location_released(
a,
&mut self.machine,
self.value_stack.pop().unwrap(),
);

// Move internal into storage.
Self::emit_relaxed_binop(
Expand All @@ -1838,8 +1842,7 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
Location::Memory(tmp, (idx * 8) as i32),
);
self.machine.release_temp_gpr(tmp);
}
//_ => unimplemented!(),
} //_ => unimplemented!(),
}
return Ok(());
}
Expand Down
19 changes: 10 additions & 9 deletions src/bin/kwasmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ extern crate structopt;

use structopt::StructOpt;

#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
use wasmer_singlepass_backend::SinglePassCompiler;

#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
use std::os::unix::net::{UnixListener, UnixStream};

#[derive(Debug, StructOpt)]
Expand All @@ -24,14 +24,14 @@ struct Listen {
socket: String,
}

#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
const CMD_RUN_CODE: u32 = 0x901;
#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
const CMD_READ_MEMORY: u32 = 0x902;
#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
const CMD_WRITE_MEMORY: u32 = 0x903;

#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
fn handle_client(mut stream: UnixStream) {
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::io::{Read, Write};
Expand All @@ -54,6 +54,7 @@ fn handle_client(mut stream: UnixStream) {
symbol_map: None,
memory_bound_check_mode: MemoryBoundCheckMode::Disable,
enforce_stack_check: true,
track_state: false,
},
&SinglePassCompiler::new(),
)
Expand Down Expand Up @@ -131,7 +132,7 @@ fn handle_client(mut stream: UnixStream) {
}
}

#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
fn run_listen(opts: Listen) {
let listener = UnixListener::bind(&opts.socket).unwrap();
use std::thread;
Expand All @@ -154,7 +155,7 @@ fn run_listen(opts: Listen) {
}
}

#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
fn main() {
let options = CLIOptions::from_args();
match options {
Expand All @@ -164,7 +165,7 @@ fn main() {
}
}

#[cfg(not(feature = "loader:kernel"))]
#[cfg(not(feature = "loader-kernel"))]
fn main() {
panic!("Kwasm loader is not enabled during compilation.");
}
12 changes: 6 additions & 6 deletions src/bin/wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ struct Run {
#[derive(Debug, Copy, Clone)]
enum LoaderName {
Local,
#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
Kernel,
}

impl LoaderName {
pub fn variants() -> &'static [&'static str] {
&[
"local",
#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
"kernel",
]
}
Expand All @@ -162,7 +162,7 @@ impl FromStr for LoaderName {
fn from_str(s: &str) -> Result<LoaderName, String> {
match s.to_lowercase().as_str() {
"local" => Ok(LoaderName::Local),
#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
"kernel" => Ok(LoaderName::Kernel),
_ => Err(format!("The loader {} doesn't exist", s)),
}
Expand Down Expand Up @@ -334,14 +334,14 @@ fn execute_wasm(options: &Run) -> Result<(), String> {

let track_state = !options.no_track_state;

#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
let is_kernel_loader = if let Some(LoaderName::Kernel) = options.loader {
true
} else {
false
};

#[cfg(not(feature = "loader:kernel"))]
#[cfg(not(feature = "loader-kernel"))]
let is_kernel_loader = false;

let module = if is_kernel_loader {
Expand Down Expand Up @@ -451,7 +451,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
.load(LocalLoader)
.expect("Can't use the local loader"),
),
#[cfg(feature = "loader:kernel")]
#[cfg(feature = "loader-kernel")]
LoaderName::Kernel => Box::new(
instance
.load(::wasmer_kernel_loader::KernelLoader)
Expand Down

0 comments on commit 13abdfe

Please sign in to comment.