wasm: Improve dead code elimination to handle indirect calls

This commit is contained in:
Brian Carroll 2022-02-12 00:09:35 +00:00
parent fcda6fabe2
commit 63c33d82e3
3 changed files with 83 additions and 22 deletions

View file

@ -133,18 +133,35 @@ impl<'a> WasmModule<'a> {
let mut types = TypeSection::preload(arena, bytes, &mut cursor);
types.parse_offsets();
let import = ImportSection::preload(arena, bytes, &mut cursor);
let mut import = ImportSection::preload(arena, bytes, &mut cursor);
let import_signatures = import.parse(arena);
let function = FunctionSection::preload(arena, bytes, &mut cursor);
let function_signatures = function.parse(arena);
let table = OpaqueSection::preload(SectionId::Table, arena, bytes, &mut cursor);
let memory = MemorySection::preload(arena, bytes, &mut cursor);
let global = GlobalSection::preload(arena, bytes, &mut cursor);
ExportSection::skip_bytes(bytes, &mut cursor);
let export = ExportSection::empty(arena);
let start = OpaqueSection::preload(SectionId::Start, arena, bytes, &mut cursor);
let element = ElementSection::preload(arena, bytes, &mut cursor);
let code = CodeSection::preload(arena, bytes, &mut cursor, import.function_count);
let indirect_callees = element.indirect_callees(arena);
let code = CodeSection::preload(
arena,
bytes,
&mut cursor,
&import_signatures,
&function_signatures,
&indirect_callees,
);
let data = DataSection::preload(arena, bytes, &mut cursor);