Cargo fmt

This commit is contained in:
losfair
2019-05-23 20:10:34 +08:00
parent cf58305889
commit dcf52ef1a7
2 changed files with 17 additions and 5 deletions

View File

@ -1,8 +1,8 @@
use wasmer_runtime_core::{ use wasmer_runtime_core::{
codegen::{Event, EventSink, FunctionMiddleware, InternalEvent}, codegen::{Event, EventSink, FunctionMiddleware, InternalEvent},
module::ModuleInfo, module::ModuleInfo,
wasmparser::{Operator, Type as WpType},
vm::InternalField, vm::InternalField,
wasmparser::{Operator, Type as WpType},
}; };
static INTERNAL_FIELD: InternalField = InternalField::allocate(); static INTERNAL_FIELD: InternalField = InternalField::allocate();
@ -48,12 +48,16 @@ impl FunctionMiddleware for Metering {
| Operator::Call { .. } | Operator::Call { .. }
| Operator::CallIndirect { .. } | Operator::CallIndirect { .. }
| Operator::Return => { | Operator::Return => {
sink.push(Event::Internal(InternalEvent::GetInternal(INTERNAL_FIELD.index() as _))); sink.push(Event::Internal(InternalEvent::GetInternal(
INTERNAL_FIELD.index() as _,
)));
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::WasmOwned(Operator::I64Add));
sink.push(Event::Internal(InternalEvent::SetInternal(INTERNAL_FIELD.index() as _))); sink.push(Event::Internal(InternalEvent::SetInternal(
INTERNAL_FIELD.index() as _,
)));
self.current_block = 0; self.current_block = 0;
} }
_ => {} _ => {}
@ -64,7 +68,9 @@ impl FunctionMiddleware for Metering {
| Operator::BrIf { .. } | Operator::BrIf { .. }
| Operator::Call { .. } | Operator::Call { .. }
| Operator::CallIndirect { .. } => { | Operator::CallIndirect { .. } => {
sink.push(Event::Internal(InternalEvent::GetInternal(INTERNAL_FIELD.index() as _))); sink.push(Event::Internal(InternalEvent::GetInternal(
INTERNAL_FIELD.index() as _,
)));
sink.push(Event::WasmOwned(Operator::I64Const { sink.push(Event::WasmOwned(Operator::I64Const {
value: self.limit as i64, value: self.limit as i64,
})); }));

View File

@ -6,7 +6,13 @@ use crate::{
types::{LocalOrImport, MemoryIndex}, types::{LocalOrImport, MemoryIndex},
vmcalls, vmcalls,
}; };
use std::{ffi::c_void, mem, ptr, sync::atomic::{AtomicUsize, Ordering}, sync::Once, cell::UnsafeCell}; use std::{
cell::UnsafeCell,
ffi::c_void,
mem, ptr,
sync::atomic::{AtomicUsize, Ordering},
sync::Once,
};
use hashbrown::HashMap; use hashbrown::HashMap;