Merge finalize_definitions into finish
This commit is contained in:
@@ -146,12 +146,6 @@ where
|
||||
contents: &ModuleContents<Self>,
|
||||
);
|
||||
|
||||
/// "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(
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,10 +437,6 @@ impl Backend for ObjectBackend {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
fn publish(&mut self) {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
fn finish(
|
||||
mut self,
|
||||
_names: HashMap<String, FuncOrDataId>,
|
||||
|
||||
@@ -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<String, FuncOrDataId>,
|
||||
contents: ModuleContents<Self>,
|
||||
) -> 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,
|
||||
|
||||
Reference in New Issue
Block a user