Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
58c6636
initial setup
kentosugama Mar 10, 2023
551bc8c
add wasm-opt crate
kentosugama Apr 6, 2023
9e77b4b
wasm-opt scaffolding
kentosugama Apr 6, 2023
cbc47eb
remove boiler
kentosugama Apr 6, 2023
959a69d
scaffold
kentosugama Apr 6, 2023
cf8e985
extract the custom sectionsg
kentosugama Apr 6, 2023
645fc35
reinsert data sections
kentosugama Apr 6, 2023
6c41502
let user specify optimization level
kentosugama Apr 6, 2023
077559f
use proper temp file
kentosugama Apr 7, 2023
a7af326
recurse for actor classes
kentosugama Apr 7, 2023
c59205e
nicer error messages
kentosugama Apr 7, 2023
ccd1622
add some file tests
kentosugama Apr 7, 2023
65f18ca
add semantic tests
kentosugama Apr 7, 2023
2fae562
test different optimization levels
kentosugama Apr 10, 2023
a8e62ac
make test cases more complex
kentosugama Apr 10, 2023
a07a95a
test preservation of metadata sections
kentosugama Apr 10, 2023
9df6cbc
Add documentation in readme
kentosugama Apr 10, 2023
21dced7
Update README.md
kentosugama Apr 10, 2023
09d0424
move into shrink and remove test cases
kentosugama Apr 10, 2023
ec44977
merge conflict
kentosugama Apr 10, 2023
b40649c
move tests into shrink test
kentosugama Apr 10, 2023
d9229cd
change error handling to not exit
kentosugama Apr 10, 2023
deec640
remove a reparsing of module
kentosugama Apr 11, 2023
82fcb3d
update tests
kentosugama Apr 11, 2023
da85724
Bump version
kentosugama Apr 11, 2023
c163dcf
inline call to list_metadata
kentosugama Apr 11, 2023
1427f59
remove keep_name_section and rename function
kentosugama Apr 11, 2023
dd0b87c
remove redundant get
kentosugama Apr 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wasm-opt scaffolding
  • Loading branch information
kentosugama committed Apr 6, 2023
commit 9e77b4b4b822497c7d417b1358888283547f9276
2 changes: 1 addition & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn main() -> anyhow::Result<()> {
}
SubCommand::Optimize => {
use ic_wasm::optimize::optimize;
optimize(&mut m)
optimize(&mut m, keep_name_section)
}
};
if let Some(output) = opts.output {
Expand Down
21 changes: 17 additions & 4 deletions src/optimize.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::utils::*;
use std::path::PathBuf;
use walrus::ir::*;
use walrus::*;

use crate::utils::*;
use wasm_opt::OptimizationOptions;

#[derive(Copy, Clone)]
struct CallNew {
Expand All @@ -27,8 +28,20 @@ impl VisitorMut for Replacer {
}
}

pub fn optimize(m: &mut Module) {
println!("FIXME");
pub fn optimize(m: &mut Module, keep_name_section: bool) {
let temp_file_name = "temp.opt.wasm";
let temp_path = PathBuf::from(temp_file_name);

// write to fs
m.emit_wasm_file(temp_file_name).unwrap();

// read in from fs and optimize
OptimizationOptions::new_opt_level_3()
.run(temp_file_name, temp_file_name)
.unwrap();

// read back in from fs and assign back to m
*m = parse_wasm_file(temp_path, keep_name_section).unwrap();
}

fn make_redirect_call_new(m: &mut Module, redirect_id: &[u8]) -> FunctionId {
Expand Down