Update parity-wasm and wasmi

This commit is contained in:
Alex Crichton
2018-04-26 18:39:08 -07:00
parent 7937d02bcb
commit 6d5ebaf5ac
3 changed files with 12 additions and 8 deletions

View File

@ -13,10 +13,10 @@ Shared support for the wasm-bindgen-cli package, an internal dependency
[dependencies] [dependencies]
base64 = "0.9" base64 = "0.9"
failure = "0.1" failure = "0.1"
parity-wasm = "0.27" parity-wasm = "0.28"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
serde_json = "1.0" serde_json = "1.0"
wasm-bindgen-shared = { path = "../shared", version = '=0.2.5' } wasm-bindgen-shared = { path = "../shared", version = '=0.2.5' }
wasm-gc-api = "0.1" wasm-gc-api = "0.1"
wasmi = { version = "0.1", features = ["opt-in-32bit"] } wasmi = "0.2"

View File

@ -11,7 +11,7 @@ extern crate failure;
use std::collections::BTreeSet; use std::collections::BTreeSet;
use std::fmt; use std::fmt;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::{Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use failure::{Error, ResultExt}; use failure::{Error, ResultExt};
@ -96,7 +96,11 @@ impl Bindgen {
None => bail!("must have a path input for now"), None => bail!("must have a path input for now"),
}; };
let stem = input.file_stem().unwrap().to_str().unwrap(); let stem = input.file_stem().unwrap().to_str().unwrap();
let mut module = parity_wasm::deserialize_file(input) let mut contents = Vec::new();
File::open(&input)
.and_then(|mut f| f.read_to_end(&mut contents))
.with_context(|_| format!("failed to read `{}`", input.display()))?;
let mut module = parity_wasm::deserialize_buffer::<Module>(&contents)
.with_context(|_| "failed to parse input file as wasm")?; .with_context(|_| "failed to parse input file as wasm")?;
let programs = extract_programs(&mut module) let programs = extract_programs(&mut module)
.with_context(|_| "failed to extract wasm-bindgen custom sections")?; .with_context(|_| "failed to extract wasm-bindgen custom sections")?;
@ -114,7 +118,7 @@ impl Bindgen {
// This means that whenever we encounter an import or export we'll // This means that whenever we encounter an import or export we'll
// execute a shim function which informs us about its type so we can // execute a shim function which informs us about its type so we can
// then generate the appropriate bindings. // then generate the appropriate bindings.
let instance = wasmi::Module::from_parity_wasm_module(module.clone()) let instance = wasmi::Module::from_buffer(&contents)
.with_context(|_| "failed to create wasmi module")?; .with_context(|_| "failed to create wasmi module")?;
let instance = wasmi::ModuleInstance::new(&instance, &MyResolver) let instance = wasmi::ModuleInstance::new(&instance, &MyResolver)
.with_context(|_| "failed to instantiate wasm module")?; .with_context(|_| "failed to instantiate wasm module")?;
@ -305,8 +309,8 @@ impl wasmi::ImportResolver for MyResolver {
let val = match descriptor.value_type() { let val = match descriptor.value_type() {
wasmi::ValueType::I32 => wasmi::RuntimeValue::I32(0), wasmi::ValueType::I32 => wasmi::RuntimeValue::I32(0),
wasmi::ValueType::I64 => wasmi::RuntimeValue::I64(0), wasmi::ValueType::I64 => wasmi::RuntimeValue::I64(0),
wasmi::ValueType::F32 => wasmi::RuntimeValue::F32(0.0), wasmi::ValueType::F32 => wasmi::RuntimeValue::F32(0.0.into()),
wasmi::ValueType::F64 => wasmi::RuntimeValue::F64(0.0), wasmi::ValueType::F64 => wasmi::RuntimeValue::F64(0.0.into()),
}; };
Ok(wasmi::GlobalInstance::alloc(val, descriptor.is_mutable())) Ok(wasmi::GlobalInstance::alloc(val, descriptor.is_mutable()))
} }

View File

@ -15,7 +15,7 @@ information see https://github.com/alexcrichton/wasm-bindgen.
[dependencies] [dependencies]
docopt = "0.8" docopt = "0.8"
failure = "0.1" failure = "0.1"
parity-wasm = "0.27" parity-wasm = "0.28"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.5" } wasm-bindgen-cli-support = { path = "../cli-support", version = "=0.2.5" }