Fix dummy function replacement

This commit is contained in:
Brian Carroll 2022-11-16 21:25:53 +00:00
parent ba99870de0
commit 0c81063c68
No known key found for this signature in database
GPG Key ID: 5C7B2EC4101703C0

View File

@ -283,7 +283,7 @@ impl<'a> WasmModule<'a> {
} }
// //
// Dead code elimination. Replace dead functions with tiny dummies. // Code section: Replace dead functions with tiny dummies.
// Live function indices are unchanged, so no relocations are needed. // Live function indices are unchanged, so no relocations are needed.
// //
let mut buffer = Vec::with_capacity_in(self.code.bytes.len(), arena); let mut buffer = Vec::with_capacity_in(self.code.bytes.len(), arena);
@ -294,7 +294,7 @@ impl<'a> WasmModule<'a> {
let code_end = self.code.function_offsets[i + 1] as usize; let code_end = self.code.function_offsets[i + 1] as usize;
buffer.extend_from_slice(&self.code.bytes[code_start..code_end]); buffer.extend_from_slice(&self.code.bytes[code_start..code_end]);
} else { } else {
buffer.extend_from_slice(&DUMMY_FUNCTION); DUMMY_FUNCTION.serialize(&mut buffer);
} }
} }