mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-12 22:05:33 +00:00
Update bin/wasmer and run cargo fmt.
This commit is contained in:
parent
e7297b9465
commit
14fcd78b30
@ -29,52 +29,58 @@ impl FunctionMiddleware for Metering {
|
|||||||
match op {
|
match op {
|
||||||
Event::Internal(InternalEvent::FunctionBegin(_)) => {
|
Event::Internal(InternalEvent::FunctionBegin(_)) => {
|
||||||
self.current_block = 0;
|
self.current_block = 0;
|
||||||
},
|
}
|
||||||
Event::Wasm(&ref op) | Event::WasmOwned(ref op) => {
|
Event::Wasm(&ref op) | Event::WasmOwned(ref op) => {
|
||||||
self.current_block += 1;
|
self.current_block += 1;
|
||||||
match *op {
|
match *op {
|
||||||
Operator::Loop { .. }
|
Operator::Loop { .. }
|
||||||
| Operator::Block { .. }
|
| Operator::Block { .. }
|
||||||
| Operator::End
|
| Operator::End
|
||||||
| Operator::If { .. }
|
| Operator::If { .. }
|
||||||
| Operator::Else
|
| Operator::Else
|
||||||
| Operator::Unreachable
|
| Operator::Unreachable
|
||||||
| Operator::Br { .. }
|
| Operator::Br { .. }
|
||||||
| Operator::BrTable { .. }
|
| Operator::BrTable { .. }
|
||||||
| Operator::BrIf { .. }
|
| Operator::BrIf { .. }
|
||||||
| Operator::Call { .. }
|
| Operator::Call { .. }
|
||||||
| Operator::CallIndirect { .. }
|
| Operator::CallIndirect { .. } => {
|
||||||
=> {
|
sink.push(Event::Internal(InternalEvent::GetInternal(0)));
|
||||||
sink.push(Event::Internal(InternalEvent::GetInternal(0)));
|
sink.push(Event::WasmOwned(Operator::I64Const {
|
||||||
sink.push(Event::WasmOwned(Operator::I64Const { value: self.current_block as i64 }));
|
value: self.current_block as i64,
|
||||||
sink.push(Event::WasmOwned(Operator::I64Add));
|
}));
|
||||||
sink.push(Event::Internal(InternalEvent::SetInternal(0)));
|
sink.push(Event::WasmOwned(Operator::I64Add));
|
||||||
self.current_block = 0;
|
sink.push(Event::Internal(InternalEvent::SetInternal(0)));
|
||||||
},
|
self.current_block = 0;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
match *op {
|
match *op {
|
||||||
Operator::Br { .. }
|
Operator::Br { .. }
|
||||||
| Operator::BrTable { .. }
|
| Operator::BrTable { .. }
|
||||||
| Operator::BrIf { .. }
|
| Operator::BrIf { .. }
|
||||||
| Operator::Call { .. }
|
| Operator::Call { .. }
|
||||||
| Operator::CallIndirect { .. }
|
| Operator::CallIndirect { .. } => {
|
||||||
=> {
|
sink.push(Event::Internal(InternalEvent::GetInternal(0)));
|
||||||
sink.push(Event::Internal(InternalEvent::GetInternal(0)));
|
sink.push(Event::WasmOwned(Operator::I64Const {
|
||||||
sink.push(Event::WasmOwned(Operator::I64Const { value: self.limit as i64 }));
|
value: self.limit as i64,
|
||||||
sink.push(Event::WasmOwned(Operator::I64GeU));
|
}));
|
||||||
sink.push(Event::WasmOwned(Operator::If { ty: WpType::EmptyBlockType }));
|
sink.push(Event::WasmOwned(Operator::I64GeU));
|
||||||
sink.push(Event::Internal(InternalEvent::Breakpoint(Box::new(move |ctx| {
|
sink.push(Event::WasmOwned(Operator::If {
|
||||||
|
ty: WpType::EmptyBlockType,
|
||||||
|
}));
|
||||||
|
sink.push(Event::Internal(InternalEvent::Breakpoint(Box::new(
|
||||||
|
move |ctx| {
|
||||||
eprintln!("execution limit reached");
|
eprintln!("execution limit reached");
|
||||||
unsafe {
|
unsafe {
|
||||||
(ctx.throw)();
|
(ctx.throw)();
|
||||||
}
|
}
|
||||||
}))));
|
},
|
||||||
sink.push(Event::WasmOwned(Operator::End));
|
))));
|
||||||
},
|
sink.push(Event::WasmOwned(Operator::End));
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
sink.push(op);
|
sink.push(op);
|
||||||
|
@ -15,10 +15,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
vm,
|
vm,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{fmt::Debug, slice};
|
||||||
slice,
|
|
||||||
fmt::Debug,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const INTERNALS_SIZE: usize = 256;
|
pub const INTERNALS_SIZE: usize = 256;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ impl fmt::Debug for InternalEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct BkptInfo {
|
pub struct BkptInfo {
|
||||||
pub throw: unsafe extern "C" fn () -> !,
|
pub throw: unsafe extern "C" fn() -> !,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule, E: Debug> {
|
pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule, E: Debug> {
|
||||||
|
@ -1494,7 +1494,6 @@ impl FunctionCodeGenerator<CodegenError> for X64FunctionCode {
|
|||||||
|
|
||||||
let a = self.assembler.as_mut().unwrap();
|
let a = self.assembler.as_mut().unwrap();
|
||||||
|
|
||||||
|
|
||||||
let op = match ev {
|
let op = match ev {
|
||||||
Event::Wasm(x) => x,
|
Event::Wasm(x) => x,
|
||||||
Event::WasmOwned(ref x) => x,
|
Event::WasmOwned(ref x) => x,
|
||||||
|
@ -35,9 +35,7 @@ extern "C" fn signal_trap_handler(
|
|||||||
let bkpt_map = BKPT_MAP.with(|x| x.borrow().last().map(|x| x.clone()));
|
let bkpt_map = BKPT_MAP.with(|x| x.borrow().last().map(|x| x.clone()));
|
||||||
if let Some(bkpt_map) = bkpt_map {
|
if let Some(bkpt_map) = bkpt_map {
|
||||||
if let Some(ref x) = bkpt_map.get(&(ip as usize)) {
|
if let Some(ref x) = bkpt_map.get(&(ip as usize)) {
|
||||||
(x)(BkptInfo {
|
(x)(BkptInfo { throw: throw });
|
||||||
throw: throw,
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,18 +17,22 @@ use wasmer::*;
|
|||||||
use wasmer_clif_backend::CraneliftCompiler;
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
#[cfg(feature = "backend:llvm")]
|
#[cfg(feature = "backend:llvm")]
|
||||||
use wasmer_llvm_backend::LLVMCompiler;
|
use wasmer_llvm_backend::LLVMCompiler;
|
||||||
|
#[cfg(feature = "backend:singlepass")]
|
||||||
|
use wasmer_middleware_common::metering::Metering;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime::{
|
||||||
cache::{Cache as BaseCache, FileSystemCache, WasmHash, WASMER_VERSION_HASH},
|
cache::{Cache as BaseCache, FileSystemCache, WasmHash, WASMER_VERSION_HASH},
|
||||||
error::RuntimeError,
|
error::RuntimeError,
|
||||||
Func, Value,
|
Func, Value,
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "backend:singlepass")]
|
||||||
|
use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
self,
|
self,
|
||||||
backend::{Compiler, CompilerConfig, MemoryBoundCheckMode},
|
backend::{Compiler, CompilerConfig, MemoryBoundCheckMode},
|
||||||
loader::{Instance as LoadedInstance, LocalLoader},
|
loader::{Instance as LoadedInstance, LocalLoader},
|
||||||
};
|
};
|
||||||
#[cfg(feature = "backend:singlepass")]
|
#[cfg(feature = "backend:singlepass")]
|
||||||
use wasmer_singlepass_backend::SinglePassCompiler;
|
use wasmer_singlepass_backend::ModuleCodeGenerator as SinglePassMCG;
|
||||||
#[cfg(feature = "wasi")]
|
#[cfg(feature = "wasi")]
|
||||||
use wasmer_wasi;
|
use wasmer_wasi;
|
||||||
|
|
||||||
@ -110,6 +114,9 @@ struct Run {
|
|||||||
/// Application arguments
|
/// Application arguments
|
||||||
#[structopt(name = "--", raw(multiple = "true"))]
|
#[structopt(name = "--", raw(multiple = "true"))]
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
|
|
||||||
|
#[structopt(long = "inst-limit")]
|
||||||
|
instruction_limit: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -286,7 +293,16 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
|
|
||||||
let compiler: Box<dyn Compiler> = match options.backend {
|
let compiler: Box<dyn Compiler> = match options.backend {
|
||||||
#[cfg(feature = "backend:singlepass")]
|
#[cfg(feature = "backend:singlepass")]
|
||||||
Backend::Singlepass => Box::new(SinglePassCompiler::new()),
|
Backend::Singlepass => {
|
||||||
|
let c: StreamingCompiler<SinglePassMCG, _, _, _, _> = StreamingCompiler::new(|| {
|
||||||
|
let mut chain = MiddlewareChain::new();
|
||||||
|
if let Some(limit) = options.instruction_limit {
|
||||||
|
chain.push(Metering::new(limit));
|
||||||
|
}
|
||||||
|
chain
|
||||||
|
});
|
||||||
|
Box::new(c)
|
||||||
|
}
|
||||||
#[cfg(not(feature = "backend:singlepass"))]
|
#[cfg(not(feature = "backend:singlepass"))]
|
||||||
Backend::Singlepass => return Err("The singlepass backend is not enabled".to_string()),
|
Backend::Singlepass => return Err("The singlepass backend is not enabled".to_string()),
|
||||||
Backend::Cranelift => Box::new(CraneliftCompiler::new()),
|
Backend::Cranelift => Box::new(CraneliftCompiler::new()),
|
||||||
|
Loading…
Reference in New Issue
Block a user