From 7608749647d3fd4adbce405cdfdb1ebbca0ecb51 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 30 Sep 2020 13:58:13 +0200 Subject: [PATCH] Merge finalize_definitions into finish --- cranelift/module/src/backend.rs | 6 ------ cranelift/module/src/module.rs | 31 +++++++++--------------------- cranelift/object/src/backend.rs | 4 ---- cranelift/simplejit/src/backend.rs | 12 +++++------- 4 files changed, 14 insertions(+), 39 deletions(-) diff --git a/cranelift/module/src/backend.rs b/cranelift/module/src/backend.rs index e20416b920..74b2342e13 100644 --- a/cranelift/module/src/backend.rs +++ b/cranelift/module/src/backend.rs @@ -146,12 +146,6 @@ where contents: &ModuleContents, ); - /// "Publish" all finalized functions and data objects to their ultimate destinations. - /// - /// This method is not relevant for `Backend` implementations that do not provide - /// `Backend::FinalizedFunction` or `Backend::FinalizedData`. - fn publish(&mut self); - /// Consume this `Backend` and return a result. Some implementations may /// provide additional functionality through this result. fn finish( diff --git a/cranelift/module/src/module.rs b/cranelift/module/src/module.rs index 78a6ae542d..18e1dc7347 100644 --- a/cranelift/module/src/module.rs +++ b/cranelift/module/src/module.rs @@ -682,16 +682,15 @@ where ); } - /// Finalize all functions and data objects that are defined but not yet finalized. - /// All symbols referenced in their bodies that are declared as needing a definition - /// must be defined by this point. - /// - /// Use `get_finalized_function` and `get_finalized_data` to obtain the final - /// artifacts. - /// - /// This method is not relevant for `Backend` implementations that do not provide - /// `Backend::FinalizedFunction` or `Backend::FinalizedData`. - pub fn finalize_definitions(&mut self) { + /// Return the target isa + pub fn isa(&self) -> &dyn isa::TargetIsa { + self.backend.isa() + } + + /// Consume the module and return the resulting `Product`. Some `Backend` + /// implementations may provide additional functionality available after + /// a `Module` is complete. + pub fn finish(mut self) -> B::Product { for func in self.functions_to_finalize.drain(..) { let info = &self.contents.functions[func]; debug_assert!(info.decl.linkage.is_definable()); @@ -714,18 +713,6 @@ where &self.contents, ); } - self.backend.publish(); - } - - /// Return the target isa - pub fn isa(&self) -> &dyn isa::TargetIsa { - self.backend.isa() - } - - /// Consume the module and return the resulting `Product`. Some `Backend` - /// implementations may provide additional functionality available after - /// a `Module` is complete. - pub fn finish(self) -> B::Product { self.backend.finish(self.names, self.contents) } } diff --git a/cranelift/object/src/backend.rs b/cranelift/object/src/backend.rs index a2db3f99c7..15ba44be7d 100644 --- a/cranelift/object/src/backend.rs +++ b/cranelift/object/src/backend.rs @@ -437,10 +437,6 @@ impl Backend for ObjectBackend { // Nothing to do. } - fn publish(&mut self) { - // Nothing to do. - } - fn finish( mut self, _names: HashMap, diff --git a/cranelift/simplejit/src/backend.rs b/cranelift/simplejit/src/backend.rs index 3a999ef221..c78c283564 100644 --- a/cranelift/simplejit/src/backend.rs +++ b/cranelift/simplejit/src/backend.rs @@ -572,12 +572,6 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend { } } - fn publish(&mut self) { - // Now that we're done patching, prepare the memory for execution! - self.memory.readonly.set_readonly(); - self.memory.code.set_readable_and_executable(); - } - /// SimpleJIT emits code and data into memory as it processes them. This /// method performs no additional processing, but returns a handle which /// allows freeing the allocated memory. Otherwise said memory is leaked @@ -586,10 +580,14 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend { /// This method does not need to be called when access to the memory /// handle is not required. fn finish( - self, + mut self, names: HashMap, contents: ModuleContents, ) -> Self::Product { + // Now that we're done patching, prepare the memory for execution! + self.memory.readonly.set_readonly(); + self.memory.code.set_readable_and_executable(); + SimpleJITProduct { memory: self.memory, names,