mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-07-21 06:35:45 +00:00
optimizer fully working
This commit is contained in:
+12
-4
@@ -260,6 +260,9 @@ fn main() {
|
|||||||
if let Some(elements_section) = module.elements_section() {
|
if let Some(elements_section) = module.elements_section() {
|
||||||
for segment in elements_section.entries() {
|
for segment in elements_section.entries() {
|
||||||
push_code_symbols(&module, segment.offset().code(), &mut init_symbols);
|
push_code_symbols(&module, segment.offset().code(), &mut init_symbols);
|
||||||
|
for func_index in segment.members() {
|
||||||
|
stay.insert(resolve_function(&module, *func_index));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for symbol in init_symbols.drain(..) { stay.insert(symbol); }
|
for symbol in init_symbols.drain(..) { stay.insert(symbol); }
|
||||||
@@ -410,17 +413,22 @@ fn main() {
|
|||||||
&mut elements::Section::Global(ref mut global_section) => {
|
&mut elements::Section::Global(ref mut global_section) => {
|
||||||
for ref mut global_entry in global_section.entries_mut() {
|
for ref mut global_entry in global_section.entries_mut() {
|
||||||
update_global_index(global_entry.init_expr_mut().code_mut(), &eliminated_globals)
|
update_global_index(global_entry.init_expr_mut().code_mut(), &eliminated_globals)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
&mut elements::Section::Data(ref mut data_section) => {
|
&mut elements::Section::Data(ref mut data_section) => {
|
||||||
for ref mut segment in data_section.entries_mut() {
|
for ref mut segment in data_section.entries_mut() {
|
||||||
update_global_index(segment.offset_mut().code_mut(), &eliminated_globals)
|
update_global_index(segment.offset_mut().code_mut(), &eliminated_globals)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
&mut elements::Section::Element(ref mut elements_section) => {
|
&mut elements::Section::Element(ref mut elements_section) => {
|
||||||
for ref mut segment in elements_section.entries_mut() {
|
for ref mut segment in elements_section.entries_mut() {
|
||||||
update_global_index(segment.offset_mut().code_mut(), &eliminated_globals)
|
update_global_index(segment.offset_mut().code_mut(), &eliminated_globals);
|
||||||
}
|
// update all indirect call addresses initial values
|
||||||
|
for func_index in segment.members_mut() {
|
||||||
|
let totalle = eliminated_funcs.iter().take_while(|i| (**i as u32) < *func_index).count();
|
||||||
|
*func_index -= totalle as u32;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user