mirror of
https://github.com/fluencelabs/wasm-utils
synced 2025-05-17 01:31:24 +00:00
Merge pull request #39 from paritytech/dont-externalize-setTempRet0
Don't externalize setTempRet0
This commit is contained in:
commit
6b3719fa3d
@ -12,7 +12,7 @@ use std::path::PathBuf;
|
|||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use parity_wasm::elements;
|
use parity_wasm::elements;
|
||||||
|
|
||||||
use wasm_utils::{CREATE_SYMBOL, CALL_SYMBOL, SET_TEMP_RET_SYMBOL};
|
use wasm_utils::{CREATE_SYMBOL, CALL_SYMBOL};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
@ -113,7 +113,7 @@ fn main() {
|
|||||||
let mut ctor_module = module.clone();
|
let mut ctor_module = module.clone();
|
||||||
|
|
||||||
if !matches.is_present("skip_optimization") {
|
if !matches.is_present("skip_optimization") {
|
||||||
wasm_utils::optimize(&mut module, vec![CALL_SYMBOL, SET_TEMP_RET_SYMBOL]).expect("Optimizer to finish without errors");
|
wasm_utils::optimize(&mut module, vec![CALL_SYMBOL]).expect("Optimizer to finish without errors");
|
||||||
}
|
}
|
||||||
|
|
||||||
let raw_module = parity_wasm::serialize(module).expect("Failed to serialize module");
|
let raw_module = parity_wasm::serialize(module).expect("Failed to serialize module");
|
||||||
@ -123,7 +123,7 @@ fn main() {
|
|||||||
// Otherwise it will just save an optimised raw_module
|
// Otherwise it will just save an optimised raw_module
|
||||||
if has_ctor(&ctor_module) {
|
if has_ctor(&ctor_module) {
|
||||||
if !matches.is_present("skip_optimization") {
|
if !matches.is_present("skip_optimization") {
|
||||||
wasm_utils::optimize(&mut ctor_module, vec![CREATE_SYMBOL, SET_TEMP_RET_SYMBOL]).expect("Optimizer to finish without errors");
|
wasm_utils::optimize(&mut ctor_module, vec![CREATE_SYMBOL]).expect("Optimizer to finish without errors");
|
||||||
}
|
}
|
||||||
wasm_utils::pack_instance(raw_module, &mut ctor_module);
|
wasm_utils::pack_instance(raw_module, &mut ctor_module);
|
||||||
parity_wasm::serialize_to_file(&path, ctor_module).expect("Failed to serialize to file");
|
parity_wasm::serialize_to_file(&path, ctor_module).expect("Failed to serialize to file");
|
||||||
@ -165,4 +165,4 @@ mod tests {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ extern crate byteorder;
|
|||||||
|
|
||||||
pub static CREATE_SYMBOL: &'static str = "_create";
|
pub static CREATE_SYMBOL: &'static str = "_create";
|
||||||
pub static CALL_SYMBOL: &'static str = "_call";
|
pub static CALL_SYMBOL: &'static str = "_call";
|
||||||
pub static SET_TEMP_RET_SYMBOL: &'static str = "setTempRet0";
|
|
||||||
|
|
||||||
pub mod rules;
|
pub mod rules;
|
||||||
|
|
||||||
|
@ -103,7 +103,6 @@ mod test {
|
|||||||
use parity_wasm::ModuleInstanceInterface;
|
use parity_wasm::ModuleInstanceInterface;
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::super::optimize;
|
use super::super::optimize;
|
||||||
use super::super::SET_TEMP_RET_SYMBOL;
|
|
||||||
use byteorder::{ByteOrder, LittleEndian};
|
use byteorder::{ByteOrder, LittleEndian};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -150,8 +149,8 @@ mod test {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
let mut ctor_module = module.clone();
|
let mut ctor_module = module.clone();
|
||||||
optimize(&mut module, vec![CALL_SYMBOL, SET_TEMP_RET_SYMBOL]).expect("Optimizer to finish without errors");
|
optimize(&mut module, vec![CALL_SYMBOL]).expect("Optimizer to finish without errors");
|
||||||
optimize(&mut ctor_module, vec![CREATE_SYMBOL, SET_TEMP_RET_SYMBOL]).expect("Optimizer to finish without errors");
|
optimize(&mut ctor_module, vec![CREATE_SYMBOL]).expect("Optimizer to finish without errors");
|
||||||
|
|
||||||
let raw_module = parity_wasm::serialize(module).unwrap();
|
let raw_module = parity_wasm::serialize(module).unwrap();
|
||||||
pack_instance(raw_module.clone(), &mut ctor_module);
|
pack_instance(raw_module.clone(), &mut ctor_module);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user