Update parity-wasm dependency to 0.31

This commit is contained in:
Wei Tang
2018-06-29 19:01:06 +08:00
parent f4b75bd840
commit d6f82000ee
11 changed files with 100 additions and 100 deletions
+4 -4
View File
@@ -136,7 +136,7 @@ impl Stack {
/// This function expects the function to be validated.
pub(crate) fn compute(func_idx: u32, module: &elements::Module) -> Result<u32, Error> {
use parity_wasm::elements::Opcode::*;
use parity_wasm::elements::Instruction::*;
let func_section = module
.function_section()
@@ -165,7 +165,7 @@ pub(crate) fn compute(func_idx: u32, module: &elements::Module) -> Result<u32, E
.bodies()
.get(func_idx as usize)
.ok_or_else(|| Error("Function body for the index isn't found".into()))?;
let opcodes = body.code();
let instructions = body.code();
let mut stack = Stack::new();
let mut max_height: u32 = 0;
@@ -186,7 +186,7 @@ pub(crate) fn compute(func_idx: u32, module: &elements::Module) -> Result<u32, E
});
loop {
if pc >= opcodes.elements().len() {
if pc >= instructions.elements().len() {
break;
}
@@ -197,7 +197,7 @@ pub(crate) fn compute(func_idx: u32, module: &elements::Module) -> Result<u32, E
max_height = stack.height();
}
let opcode = &opcodes.elements()[pc];
let opcode = &instructions.elements()[pc];
trace!(target: "max_height", "{:?}", opcode);
match *opcode {
+8 -8
View File
@@ -57,7 +57,7 @@ use parity_wasm::builder;
/// Macro to generate preamble and postamble.
macro_rules! instrument_call {
($callee_idx: expr, $callee_stack_cost: expr, $stack_height_global_idx: expr, $stack_limit: expr) => {{
use $crate::parity_wasm::elements::Opcode::*;
use $crate::parity_wasm::elements::Instruction::*;
[
// stack_height += stack_cost(F)
GetGlobal($stack_height_global_idx),
@@ -160,7 +160,7 @@ fn generate_stack_height_global(ctx: &mut Context, module: &mut elements::Module
.value_type()
.i32()
.mutable()
.init_expr(elements::Opcode::I32Const(0))
.init_expr(elements::Instruction::I32Const(0))
.build();
// Try to find an existing global section.
@@ -268,13 +268,13 @@ fn instrument_functions(ctx: &mut Context, module: &mut elements::Module) -> Res
/// ```
fn instrument_function(
ctx: &mut Context,
opcodes: &mut elements::Opcodes,
instructions: &mut elements::Instructions,
) -> Result<(), Error> {
use parity_wasm::elements::Opcode::*;
use parity_wasm::elements::Instruction::*;
let mut cursor = 0;
loop {
if cursor >= opcodes.elements().len() {
if cursor >= instructions.elements().len() {
break;
}
@@ -287,8 +287,8 @@ fn instrument_function(
}
let action: Action = {
let opcode = &opcodes.elements()[cursor];
match *opcode {
let instruction = &instructions.elements()[cursor];
match *instruction {
Call(ref callee_idx) => {
let callee_stack_cost = ctx
.stack_cost(*callee_idx)
@@ -330,7 +330,7 @@ fn instrument_function(
//
// To splice actually take a place, we need to consume iterator
// splice returns. So we just `count()` it.
let _ = opcodes
let _ = instructions
.elements_mut()
.splice(cursor..(cursor + 1), new_seq.iter().cloned())
.count();
+4 -4
View File
@@ -93,17 +93,17 @@ pub(crate) fn generate_thunks(
// - argument pushing
// - instrumented call
// - end
let mut thunk_body: Vec<elements::Opcode> = Vec::with_capacity(
let mut thunk_body: Vec<elements::Instruction> = Vec::with_capacity(
thunk.signature.params().len() +
instrumented_call.len() +
1
);
for (arg_idx, _) in thunk.signature.params().iter().enumerate() {
thunk_body.push(elements::Opcode::GetLocal(arg_idx as u32));
thunk_body.push(elements::Instruction::GetLocal(arg_idx as u32));
}
thunk_body.extend(instrumented_call.iter().cloned());
thunk_body.push(elements::Opcode::End);
thunk_body.push(elements::Instruction::End);
// TODO: Don't generate a signature, but find an existing one.
@@ -114,7 +114,7 @@ pub(crate) fn generate_thunks(
.with_return_type(thunk.signature.return_type().clone())
.build()
.body()
.with_opcodes(elements::Opcodes::new(
.with_instructions(elements::Instructions::new(
thunk_body
))
.build()