Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
wasmi interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
NikVolf committed Feb 5, 2018
1 parent 8587df1 commit 95783b4
Show file tree
Hide file tree
Showing 13 changed files with 876 additions and 1,284 deletions.
45 changes: 21 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ethcore/res/wasm-tests
6 changes: 1 addition & 5 deletions ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,7 @@ impl TransactOptions<trace::NoopTracer, trace::NoopVMTracer> {

pub fn executor(machine: &Machine, vm_factory: &Factory, params: &ActionParams) -> Box<vm::Vm> {
if machine.supports_wasm() && params.code.as_ref().map_or(false, |code| code.len() > 4 && &code[0..4] == WASM_MAGIC_NUMBER) {
Box::new(
wasm::WasmInterpreter::new()
// prefer to fail fast
.expect("Failed to create wasm runtime")
)
Box::new(wasm::WasmInterpreter)
} else {
vm_factory.create(params.gas)
}
Expand Down
28 changes: 13 additions & 15 deletions ethcore/vm/src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,19 @@ pub struct WasmCosts {
pub mul: u32,
/// Memory (load/store) operations multiplier.
pub mem: u32,
/// Memory copy operation, per byte.
pub mem_cmp: u32,
/// Memory copy operation, per byte.
pub mem_copy: u32,
/// Memory move operation, per byte.
pub mem_move: u32,
/// Memory set operation, per byte.
pub mem_set: u32,
/// Static region charge, per byte.
pub static_region: u32,
/// General static query of U256 value from env-info
pub static_u256: u32,
/// General static query of Address value from env-info
pub static_address: u32,
/// Memory stipend. Amount of free memory (in 64kb pages) each contract can use for stack.
pub initial_mem: u32,
/// Grow memory cost, per page (64kb)
pub grow_mem: u32,
/// Cost of wasm opcode is calculated as TABLE_ENTRY_COST * `opcodes_mul` / `opcodes_div`
pub opcodes_mul: u32,
/// Cost of wasm opcode is calculated as TABLE_ENTRY_COST * `opcodes_mul` / `opcodes_div`
pub opcodes_div: u32,

}

impl Default for WasmCosts {
Expand All @@ -150,13 +149,12 @@ impl Default for WasmCosts {
div: 16,
mul: 4,
mem: 2,
mem_cmp: 1,
mem_copy: 1,
mem_move: 1,
mem_set: 1,
static_region: 1,
static_u256: 64,
static_address: 40,
initial_mem: 4096,
grow_mem: 8192,
opcodes_mul: 3,
opcodes_div: 8,
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion ethcore/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ authors = ["Parity Technologies <admin@parity.io>"]
byteorder = "1.0"
ethereum-types = "0.1"
log = "0.3"
parity-wasm = "0.15"
parity-wasm = "0.23"
libc = "0.2"
wasm-utils = { git = "https://github.com/paritytech/wasm-utils" }
vm = { path = "../vm" }
ethcore-logger = { path = "../../logger" }
wasmi = { git = "https://github.com/pepyakin/wasmi" }
2 changes: 1 addition & 1 deletion ethcore/wasm/run/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn load_code<P: AsRef<path::Path>>(p: P) -> io::Result<Vec<u8>> {
}

fn wasm_interpreter() -> WasmInterpreter {
WasmInterpreter::new().expect("wasm interpreter to create without errors")
WasmInterpreter
}

#[derive(Debug)]
Expand Down
Loading

0 comments on commit 95783b4

Please sign in to comment.