diff --git a/cranelift/codegen/src/binemit/memorysink.rs b/cranelift/codegen/src/binemit/memorysink.rs index d40d5e7281..96a1ac4619 100644 --- a/cranelift/codegen/src/binemit/memorysink.rs +++ b/cranelift/codegen/src/binemit/memorysink.rs @@ -36,8 +36,6 @@ pub struct MemoryCodeSink<'a> { offset: isize, relocs: &'a mut dyn RelocSink, traps: &'a mut dyn TrapSink, - /// Information about the generated code and read-only data. - pub info: CodeInfo, } impl<'a> MemoryCodeSink<'a> { @@ -55,11 +53,17 @@ impl<'a> MemoryCodeSink<'a> { Self { data, offset: 0, - info: CodeInfo { total_size: 0 }, relocs, traps, } } + + /// Information about the generated code and read-only data. + pub fn info(&self) -> CodeInfo { + CodeInfo { + total_size: self.offset as CodeOffset, + } + } } /// A trait for receiving relocations for code that is emitted directly into memory. @@ -119,10 +123,6 @@ impl<'a> CodeSink for MemoryCodeSink<'a> { self.traps.trap(ofs, srcloc, code); } - fn end_codegen(&mut self) { - self.info.total_size = self.offset as CodeOffset; - } - fn add_call_site(&mut self, opcode: Opcode, loc: SourceLoc) { debug_assert!( opcode.is_call(), diff --git a/cranelift/codegen/src/binemit/mod.rs b/cranelift/codegen/src/binemit/mod.rs index ff124ec6fa..ee2ff47490 100644 --- a/cranelift/codegen/src/binemit/mod.rs +++ b/cranelift/codegen/src/binemit/mod.rs @@ -114,9 +114,6 @@ pub trait CodeSink { /// Add trap information for the current offset. fn trap(&mut self, _: TrapCode, _: SourceLoc); - /// Read-only data output is complete, we're done. - fn end_codegen(&mut self); - /// Add a call site for a call with the given opcode, returning at the current offset. fn add_call_site(&mut self, _: Opcode, _: SourceLoc) { // Default implementation doesn't need to do anything. diff --git a/cranelift/codegen/src/context.rs b/cranelift/codegen/src/context.rs index 67fc48d77c..d5adc868ec 100644 --- a/cranelift/codegen/src/context.rs +++ b/cranelift/codegen/src/context.rs @@ -200,7 +200,7 @@ impl Context { .as_ref() .expect("only using mach backend now"); result.buffer.emit(&mut sink); - let info = sink.info; + let info = sink.info(); // New backends do not emit StackMaps through the `CodeSink` because its interface // requires `Value`s; instead, the `StackMap` objects are directly accessible via // `result.buffer.stack_maps()`. diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 2f46f7110e..1c487ab1dc 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -1470,8 +1470,6 @@ impl MachBufferFinalized { } sink.put1(*byte); } - - sink.end_codegen(); } /// Get the stack map metadata for this code. @@ -2088,7 +2086,6 @@ mod test { fn trap(&mut self, t: TrapCode, _: SourceLoc) { self.traps.push((self.offset, t)); } - fn end_codegen(&mut self) {} fn add_call_site(&mut self, op: Opcode, _: SourceLoc) { self.callsites.push((self.offset, op)); } diff --git a/cranelift/filetests/src/test_compile.rs b/cranelift/filetests/src/test_compile.rs index ec8bbbb120..5c03e96bec 100644 --- a/cranelift/filetests/src/test_compile.rs +++ b/cranelift/filetests/src/test_compile.rs @@ -94,7 +94,6 @@ impl binemit::CodeSink for SizeSink { ) { } fn trap(&mut self, _code: ir::TrapCode, _srcloc: ir::SourceLoc) {} - fn end_codegen(&mut self) {} } fn check_precise_output(text: &str, context: &Context) -> Result<()> {