diff --git a/cranelift/codegen/src/binemit/memorysink.rs b/cranelift/codegen/src/binemit/memorysink.rs index dc86530b7c..6635bff876 100644 --- a/cranelift/codegen/src/binemit/memorysink.rs +++ b/cranelift/codegen/src/binemit/memorysink.rs @@ -55,12 +55,7 @@ impl<'a> MemoryCodeSink<'a> { Self { data, offset: 0, - info: CodeInfo { - code_size: 0, - jumptables_size: 0, - rodata_size: 0, - total_size: 0, - }, + info: CodeInfo { total_size: 0 }, relocs, traps, } @@ -140,16 +135,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> { self.traps.trap(ofs, srcloc, code); } - fn begin_jumptables(&mut self) { - self.info.code_size = self.offset(); - } - - fn begin_rodata(&mut self) { - self.info.jumptables_size = self.offset() - self.info.code_size; - } - fn end_codegen(&mut self) { - self.info.rodata_size = self.offset() - (self.info.jumptables_size + self.info.code_size); self.info.total_size = self.offset(); } diff --git a/cranelift/codegen/src/binemit/mod.rs b/cranelift/codegen/src/binemit/mod.rs index 9532e34538..157a123d7e 100644 --- a/cranelift/codegen/src/binemit/mod.rs +++ b/cranelift/codegen/src/binemit/mod.rs @@ -96,31 +96,10 @@ impl fmt::Display for Reloc { /// precedes the boundary between the sections. #[derive(PartialEq)] pub struct CodeInfo { - /// Number of bytes of machine code (the code starts at offset 0). - pub code_size: CodeOffset, - - /// Number of bytes of jumptables. - pub jumptables_size: CodeOffset, - - /// Number of bytes of rodata. - pub rodata_size: CodeOffset, - /// Number of bytes in total. pub total_size: CodeOffset, } -impl CodeInfo { - /// Offset of any relocatable jump tables, or equal to rodata if there are no jump tables. - pub fn jumptables(&self) -> CodeOffset { - self.code_size - } - - /// Offset of any copyable read-only data, or equal to total_size if there are no rodata. - pub fn rodata(&self) -> CodeOffset { - self.code_size + self.jumptables_size - } -} - /// Abstract interface for adding bytes to the code segment. /// /// A `CodeSink` will receive all of the machine code for a function. It also accepts relocations @@ -147,12 +126,6 @@ pub trait CodeSink { /// Add trap information for the current offset. fn trap(&mut self, _: TrapCode, _: SourceLoc); - /// Machine code output is complete, jump table data may follow. - fn begin_jumptables(&mut self); - - /// Jump table output is complete, raw read-only data may follow. - fn begin_rodata(&mut self); - /// Read-only data output is complete, we're done. fn end_codegen(&mut self); diff --git a/cranelift/codegen/src/isa/test_utils.rs b/cranelift/codegen/src/isa/test_utils.rs index c57a0a56cb..ed5eed09b4 100644 --- a/cranelift/codegen/src/isa/test_utils.rs +++ b/cranelift/codegen/src/isa/test_utils.rs @@ -68,10 +68,6 @@ impl CodeSink for TestCodeSink { fn trap(&mut self, _code: TrapCode, _srcloc: SourceLoc) {} - fn begin_jumptables(&mut self) {} - - fn begin_rodata(&mut self) {} - fn end_codegen(&mut self) {} fn add_call_site(&mut self, _opcode: Opcode, _srcloc: SourceLoc) {} diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 6871e8c470..298ee90cd1 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -1460,8 +1460,6 @@ impl MachBufferFinalized { sink.put1(*byte); } - sink.begin_jumptables(); - sink.begin_rodata(); sink.end_codegen(); } @@ -2091,8 +2089,6 @@ mod test { fn trap(&mut self, t: TrapCode, _: SourceLoc) { self.traps.push((self.offset, t)); } - fn begin_jumptables(&mut self) {} - fn begin_rodata(&mut self) {} fn end_codegen(&mut self) {} fn add_call_site(&mut self, op: Opcode, _: SourceLoc) { self.callsites.push((self.offset, op)); diff --git a/cranelift/codegen/src/machinst/mod.rs b/cranelift/codegen/src/machinst/mod.rs index 20a78b6c87..725ab7a0e4 100644 --- a/cranelift/codegen/src/machinst/mod.rs +++ b/cranelift/codegen/src/machinst/mod.rs @@ -367,12 +367,8 @@ pub struct MachCompileResult { impl MachCompileResult { /// Get a `CodeInfo` describing section sizes from this compilation result. pub fn code_info(&self) -> CodeInfo { - let code_size = self.buffer.total_size(); CodeInfo { - code_size, - jumptables_size: 0, - rodata_size: 0, - total_size: code_size, + total_size: self.buffer.total_size(), } } } diff --git a/cranelift/filetests/src/test_compile.rs b/cranelift/filetests/src/test_compile.rs index 0426e36710..e368c55d5b 100644 --- a/cranelift/filetests/src/test_compile.rs +++ b/cranelift/filetests/src/test_compile.rs @@ -93,7 +93,5 @@ impl binemit::CodeSink for SizeSink { ) { } fn trap(&mut self, _code: ir::TrapCode, _srcloc: ir::SourceLoc) {} - fn begin_jumptables(&mut self) {} - fn begin_rodata(&mut self) {} fn end_codegen(&mut self) {} } diff --git a/cranelift/src/compile.rs b/cranelift/src/compile.rs index bfce292f8f..c1993e8b65 100644 --- a/cranelift/src/compile.rs +++ b/cranelift/src/compile.rs @@ -91,8 +91,7 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) - print_all( isa, &mem, - code_info.code_size, - code_info.jumptables_size + code_info.rodata_size, + code_info.total_size, &relocs, &traps, &stack_maps, diff --git a/cranelift/src/disasm.rs b/cranelift/src/disasm.rs index 96972c6bc5..7a108c5d80 100644 --- a/cranelift/src/disasm.rs +++ b/cranelift/src/disasm.rs @@ -193,14 +193,12 @@ pub fn print_all( isa: &dyn TargetIsa, mem: &[u8], code_size: u32, - rodata_size: u32, relocs: &PrintRelocs, traps: &PrintTraps, stack_maps: &PrintStackMaps, ) -> Result<()> { print_bytes(&mem); print_disassembly(isa, &mem[0..code_size as usize])?; - print_readonly_data(&mem[code_size as usize..(code_size + rodata_size) as usize]); println!("\n{}\n{}\n{}", &relocs.text, &traps.text, &stack_maps.text); Ok(()) } @@ -218,25 +216,3 @@ pub fn print_bytes(mem: &[u8]) { } println!(); } - -pub fn print_readonly_data(mem: &[u8]) { - if mem.is_empty() { - return; - } - - println!("\nFollowed by {} bytes of read-only data:", mem.len()); - - for (i, byte) in mem.iter().enumerate() { - if i % 16 == 0 { - if i != 0 { - println!(); - } - print!("{:4}: ", i); - } - if i % 4 == 0 { - print!(" "); - } - print!("{:02x} ", byte); - } - println!(); -} diff --git a/cranelift/src/wasm.rs b/cranelift/src/wasm.rs index b8e43b83a0..bb3b93b098 100644 --- a/cranelift/src/wasm.rs +++ b/cranelift/src/wasm.rs @@ -255,7 +255,7 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) - for (def_index, func) in dummy_environ.info.function_bodies.iter() { context.func = func.clone(); - let mut saved_sizes = None; + let mut saved_size = None; let func_index = num_func_imports + def_index.index(); let mut mem = vec![]; let mut relocs = PrintRelocs::new(options.print); @@ -285,10 +285,7 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) - } if options.disasm { - saved_sizes = Some(( - code_info.code_size, - code_info.jumptables_size + code_info.rodata_size, - )); + saved_size = Some(code_info.total_size); } } @@ -325,16 +322,8 @@ fn handle_module(options: &Options, path: &Path, name: &str, fisa: FlagsOrIsa) - vprintln!(options.verbose, ""); } - if let Some((code_size, rodata_size)) = saved_sizes { - print_all( - isa, - &mem, - code_size, - rodata_size, - &relocs, - &traps, - &stack_maps, - )?; + if let Some(total_size) = saved_size { + print_all(isa, &mem, total_size, &relocs, &traps, &stack_maps)?; } context.clear();