Move ModuleDeclarations to backends

This commit is contained in:
bjorn3
2020-09-30 18:33:29 +02:00
parent 7a6e909efe
commit b44c5bb2be
4 changed files with 106 additions and 107 deletions

View File

@@ -44,28 +44,34 @@ where
/// Return the `TargetIsa` to compile for. /// Return the `TargetIsa` to compile for.
fn isa(&self) -> &dyn TargetIsa; fn isa(&self) -> &dyn TargetIsa;
/// Get all declarations in this module.
fn declarations(&self) -> &ModuleDeclarations;
/// Declare a function. /// Declare a function.
fn declare_function(&mut self, id: FuncId, name: &str, linkage: Linkage); fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &ir::Signature,
) -> ModuleResult<FuncId>;
/// Declare a data object. /// Declare a data object.
fn declare_data( fn declare_data(
&mut self, &mut self,
id: DataId,
name: &str, name: &str,
linkage: Linkage, linkage: Linkage,
writable: bool, writable: bool,
tls: bool, tls: bool,
align: Option<u8>, align: Option<u8>,
); ) -> ModuleResult<DataId>;
/// Define a function, producing the function body from the given `Context`. /// Define a function, producing the function body from the given `Context`.
/// ///
/// Functions must be declared before being defined. /// Functions must be declared before being defined.
fn define_function<TS>( fn define_function<TS>(
&mut self, &mut self,
id: FuncId, func: FuncId,
ctx: &mut Context, ctx: &mut Context,
declarations: &ModuleDeclarations,
trap_sink: &mut TS, trap_sink: &mut TS,
) -> ModuleResult<ModuleCompiledFunction> ) -> ModuleResult<ModuleCompiledFunction>
where where
@@ -78,7 +84,6 @@ where
&mut self, &mut self,
id: FuncId, id: FuncId,
bytes: &[u8], bytes: &[u8],
declarations: &ModuleDeclarations,
) -> ModuleResult<ModuleCompiledFunction>; ) -> ModuleResult<ModuleCompiledFunction>;
/// Define a zero-initialized data object of the given size. /// Define a zero-initialized data object of the given size.
@@ -88,12 +93,11 @@ where
&mut self, &mut self,
id: DataId, id: DataId,
data_ctx: &DataContext, data_ctx: &DataContext,
declarations: &ModuleDeclarations,
) -> ModuleResult<()>; ) -> ModuleResult<()>;
/// Consume this `Backend` and return a result. Some implementations may /// Consume this `Backend` and return a result. Some implementations may
/// provide additional functionality through this result. /// provide additional functionality through this result.
fn finish(self, declarations: ModuleDeclarations) -> Self::Product; fn finish(self) -> Self::Product;
} }
/// Default names for `ir::LibCall`s. A function by this name is imported into the object as /// Default names for `ir::LibCall`s. A function by this name is imported into the object as

View File

@@ -327,7 +327,6 @@ pub struct Module<B>
where where
B: Backend, B: Backend,
{ {
declarations: ModuleDeclarations,
backend: B, backend: B,
} }
@@ -344,11 +343,6 @@ where
/// Create a new `Module`. /// Create a new `Module`.
pub fn new(backend_builder: B::Builder) -> Self { pub fn new(backend_builder: B::Builder) -> Self {
Self { Self {
declarations: ModuleDeclarations {
names: HashMap::new(),
functions: PrimaryMap::new(),
data_objects: PrimaryMap::new(),
},
backend: B::new(backend_builder), backend: B::new(backend_builder),
} }
} }
@@ -356,7 +350,7 @@ where
/// Get the module identifier for a given name, if that name /// Get the module identifier for a given name, if that name
/// has been declared. /// has been declared.
pub fn get_name(&self, name: &str) -> Option<FuncOrDataId> { pub fn get_name(&self, name: &str) -> Option<FuncOrDataId> {
self.declarations.names.get(name).cloned() self.backend.declarations().get_name(name)
} }
/// Return the target information needed by frontends to produce Cranelift IR /// Return the target information needed by frontends to produce Cranelift IR
@@ -406,16 +400,7 @@ where
linkage: Linkage, linkage: Linkage,
signature: &ir::Signature, signature: &ir::Signature,
) -> ModuleResult<FuncId> { ) -> ModuleResult<FuncId> {
let (id, decl) = self self.backend.declare_function(name, linkage, signature)
.declarations
.declare_function(name, linkage, signature)?;
self.backend.declare_function(id, name, decl.linkage);
Ok(id)
}
/// An iterator over functions that have been declared in this module.
pub fn declared_functions(&self) -> core::slice::Iter<'_, FunctionDeclaration> {
self.declarations.functions.values()
} }
/// Declare a data object in this module. /// Declare a data object in this module.
@@ -427,12 +412,8 @@ where
tls: bool, tls: bool,
align: Option<u8>, // An alignment bigger than 128 is unlikely align: Option<u8>, // An alignment bigger than 128 is unlikely
) -> ModuleResult<DataId> { ) -> ModuleResult<DataId> {
let (id, decl) = self
.declarations
.declare_data(name, linkage, writable, tls, align)?;
self.backend self.backend
.declare_data(id, name, decl.linkage, decl.writable, decl.tls, decl.align); .declare_data(name, linkage, writable, tls, align)
Ok(id)
} }
/// Use this when you're building the IR of a function to reference a function. /// Use this when you're building the IR of a function to reference a function.
@@ -440,7 +421,7 @@ where
/// TODO: Coalesce redundant decls and signatures. /// TODO: Coalesce redundant decls and signatures.
/// TODO: Look into ways to reduce the risk of using a FuncRef in the wrong function. /// TODO: Look into ways to reduce the risk of using a FuncRef in the wrong function.
pub fn declare_func_in_func(&self, func: FuncId, in_func: &mut ir::Function) -> ir::FuncRef { pub fn declare_func_in_func(&self, func: FuncId, in_func: &mut ir::Function) -> ir::FuncRef {
let decl = &self.declarations.functions[func]; let decl = &self.backend.declarations().functions[func];
let signature = in_func.import_signature(decl.signature.clone()); let signature = in_func.import_signature(decl.signature.clone());
let colocated = decl.linkage.is_final(); let colocated = decl.linkage.is_final();
in_func.import_function(ir::ExtFuncData { in_func.import_function(ir::ExtFuncData {
@@ -454,7 +435,7 @@ where
/// ///
/// TODO: Same as above. /// TODO: Same as above.
pub fn declare_data_in_func(&self, data: DataId, func: &mut ir::Function) -> ir::GlobalValue { pub fn declare_data_in_func(&self, data: DataId, func: &mut ir::Function) -> ir::GlobalValue {
let decl = &self.declarations.data_objects[data]; let decl = &self.backend.declarations().data_objects[data];
let colocated = decl.linkage.is_final(); let colocated = decl.linkage.is_final();
func.create_global_value(ir::GlobalValueData::Symbol { func.create_global_value(ir::GlobalValueData::Symbol {
name: ir::ExternalName::user(1, data.as_u32()), name: ir::ExternalName::user(1, data.as_u32()),
@@ -488,8 +469,7 @@ where
where where
TS: binemit::TrapSink, TS: binemit::TrapSink,
{ {
self.backend self.backend.define_function(func, ctx, trap_sink)
.define_function(func, ctx, &self.declarations, trap_sink)
} }
/// Define a function, taking the function body from the given `bytes`. /// Define a function, taking the function body from the given `bytes`.
@@ -504,13 +484,12 @@ where
func: FuncId, func: FuncId,
bytes: &[u8], bytes: &[u8],
) -> ModuleResult<ModuleCompiledFunction> { ) -> ModuleResult<ModuleCompiledFunction> {
self.backend self.backend.define_function_bytes(func, bytes)
.define_function_bytes(func, bytes, &self.declarations)
} }
/// Define a data object, producing the data contents from the given `DataContext`. /// Define a data object, producing the data contents from the given `DataContext`.
pub fn define_data(&mut self, data: DataId, data_ctx: &DataContext) -> ModuleResult<()> { pub fn define_data(&mut self, data: DataId, data_ctx: &DataContext) -> ModuleResult<()> {
self.backend.define_data(data, data_ctx, &self.declarations) self.backend.define_data(data, data_ctx)
} }
/// Return the target isa /// Return the target isa
@@ -522,6 +501,6 @@ where
/// implementations may provide additional functionality available after /// implementations may provide additional functionality available after
/// a `Module` is complete. /// a `Module` is complete.
pub fn finish(self) -> B::Product { pub fn finish(self) -> B::Product {
self.backend.finish(self.declarations) self.backend.finish()
} }
} }

View File

@@ -114,6 +114,7 @@ impl ObjectBuilder {
pub struct ObjectBackend { pub struct ObjectBackend {
isa: Box<dyn TargetIsa>, isa: Box<dyn TargetIsa>,
object: Object, object: Object,
declarations: ModuleDeclarations,
functions: SecondaryMap<FuncId, Option<(SymbolId, bool)>>, functions: SecondaryMap<FuncId, Option<(SymbolId, bool)>>,
data_objects: SecondaryMap<DataId, Option<(SymbolId, bool)>>, data_objects: SecondaryMap<DataId, Option<(SymbolId, bool)>>,
relocs: Vec<SymbolRelocs>, relocs: Vec<SymbolRelocs>,
@@ -135,6 +136,7 @@ impl Backend for ObjectBackend {
Self { Self {
isa: builder.isa, isa: builder.isa,
object, object,
declarations: ModuleDeclarations::default(),
functions: SecondaryMap::new(), functions: SecondaryMap::new(),
data_objects: SecondaryMap::new(), data_objects: SecondaryMap::new(),
relocs: Vec::new(), relocs: Vec::new(),
@@ -149,8 +151,21 @@ impl Backend for ObjectBackend {
&*self.isa &*self.isa
} }
fn declare_function(&mut self, id: FuncId, name: &str, linkage: Linkage) { fn declarations(&self) -> &ModuleDeclarations {
let (scope, weak) = translate_linkage(linkage); &self.declarations
}
fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &ir::Signature,
) -> ModuleResult<FuncId> {
let (id, decl) = self
.declarations
.declare_function(name, linkage, signature)?;
let (scope, weak) = translate_linkage(decl.linkage);
if let Some((function, _defined)) = self.functions[id] { if let Some((function, _defined)) = self.functions[id] {
let symbol = self.object.symbol_mut(function); let symbol = self.object.symbol_mut(function);
@@ -169,23 +184,28 @@ impl Backend for ObjectBackend {
}); });
self.functions[id] = Some((symbol_id, false)); self.functions[id] = Some((symbol_id, false));
} }
Ok(id)
} }
fn declare_data( fn declare_data(
&mut self, &mut self,
id: DataId,
name: &str, name: &str,
linkage: Linkage, linkage: Linkage,
_writable: bool, writable: bool,
tls: bool, tls: bool,
_align: Option<u8>, align: Option<u8>,
) { ) -> ModuleResult<DataId> {
let kind = if tls { let (id, decl) = self
.declarations
.declare_data(name, linkage, writable, tls, align)?;
let kind = if decl.tls {
SymbolKind::Tls SymbolKind::Tls
} else { } else {
SymbolKind::Data SymbolKind::Data
}; };
let (scope, weak) = translate_linkage(linkage); let (scope, weak) = translate_linkage(decl.linkage);
if let Some((data, _defined)) = self.data_objects[id] { if let Some((data, _defined)) = self.data_objects[id] {
let symbol = self.object.symbol_mut(data); let symbol = self.object.symbol_mut(data);
@@ -205,13 +225,14 @@ impl Backend for ObjectBackend {
}); });
self.data_objects[id] = Some((symbol_id, false)); self.data_objects[id] = Some((symbol_id, false));
} }
Ok(id)
} }
fn define_function<TS>( fn define_function<TS>(
&mut self, &mut self,
func_id: FuncId, func_id: FuncId,
ctx: &mut cranelift_codegen::Context, ctx: &mut cranelift_codegen::Context,
declarations: &ModuleDeclarations,
trap_sink: &mut TS, trap_sink: &mut TS,
) -> ModuleResult<ModuleCompiledFunction> ) -> ModuleResult<ModuleCompiledFunction>
where where
@@ -227,7 +248,7 @@ impl Backend for ObjectBackend {
.. ..
} = ctx.compile(self.isa())?; } = ctx.compile(self.isa())?;
let decl = declarations.get_function_decl(func_id); let decl = self.declarations.get_function_decl(func_id);
if !decl.linkage.is_definable() { if !decl.linkage.is_definable() {
return Err(ModuleError::InvalidImportDefinition(decl.name.clone())); return Err(ModuleError::InvalidImportDefinition(decl.name.clone()));
} }
@@ -286,11 +307,10 @@ impl Backend for ObjectBackend {
&mut self, &mut self,
func_id: FuncId, func_id: FuncId,
bytes: &[u8], bytes: &[u8],
declarations: &ModuleDeclarations,
) -> ModuleResult<ModuleCompiledFunction> { ) -> ModuleResult<ModuleCompiledFunction> {
info!("defining function {} with bytes", func_id); info!("defining function {} with bytes", func_id);
let decl = declarations.get_function_decl(func_id); let decl = self.declarations.get_function_decl(func_id);
if !decl.linkage.is_definable() { if !decl.linkage.is_definable() {
return Err(ModuleError::InvalidImportDefinition(decl.name.clone())); return Err(ModuleError::InvalidImportDefinition(decl.name.clone()));
} }
@@ -326,13 +346,8 @@ impl Backend for ObjectBackend {
Ok(ModuleCompiledFunction { size: total_size }) Ok(ModuleCompiledFunction { size: total_size })
} }
fn define_data( fn define_data(&mut self, data_id: DataId, data_ctx: &DataContext) -> ModuleResult<()> {
&mut self, let decl = self.declarations.get_data_decl(data_id);
data_id: DataId,
data_ctx: &DataContext,
declarations: &ModuleDeclarations,
) -> ModuleResult<()> {
let decl = declarations.get_data_decl(data_id);
if !decl.linkage.is_definable() { if !decl.linkage.is_definable() {
return Err(ModuleError::InvalidImportDefinition(decl.name.clone())); return Err(ModuleError::InvalidImportDefinition(decl.name.clone()));
} }
@@ -438,7 +453,7 @@ impl Backend for ObjectBackend {
Ok(()) Ok(())
} }
fn finish(mut self, declarations: ModuleDeclarations) -> ObjectProduct { fn finish(mut self) -> ObjectProduct {
let symbol_relocs = mem::take(&mut self.relocs); let symbol_relocs = mem::take(&mut self.relocs);
for symbol in symbol_relocs { for symbol in symbol_relocs {
for &RelocRecord { for &RelocRecord {
@@ -450,7 +465,7 @@ impl Backend for ObjectBackend {
addend, addend,
} in &symbol.relocs } in &symbol.relocs
{ {
let target_symbol = self.get_symbol(&declarations, name); let target_symbol = self.get_symbol(name);
self.object self.object
.add_relocation( .add_relocation(
symbol.section, symbol.section,
@@ -487,18 +502,14 @@ impl Backend for ObjectBackend {
impl ObjectBackend { impl ObjectBackend {
// This should only be called during finish because it creates // This should only be called during finish because it creates
// symbols for missing libcalls. // symbols for missing libcalls.
fn get_symbol( fn get_symbol(&mut self, name: &ir::ExternalName) -> SymbolId {
&mut self,
declarations: &ModuleDeclarations,
name: &ir::ExternalName,
) -> SymbolId {
match *name { match *name {
ir::ExternalName::User { .. } => { ir::ExternalName::User { .. } => {
if declarations.is_function(name) { if self.declarations.is_function(name) {
let id = declarations.get_function_id(name); let id = self.declarations.get_function_id(name);
self.functions[id].unwrap().0 self.functions[id].unwrap().0
} else { } else {
let id = declarations.get_data_id(name); let id = self.declarations.get_data_id(name);
self.data_objects[id].unwrap().0 self.data_objects[id].unwrap().0
} }
} }

View File

@@ -127,6 +127,7 @@ pub struct SimpleJITBackend {
symbols: HashMap<String, *const u8>, symbols: HashMap<String, *const u8>,
libcall_names: Box<dyn Fn(ir::LibCall) -> String>, libcall_names: Box<dyn Fn(ir::LibCall) -> String>,
memory: SimpleJITMemoryHandle, memory: SimpleJITMemoryHandle,
declarations: ModuleDeclarations,
functions: SecondaryMap<FuncId, Option<SimpleJITCompiledFunction>>, functions: SecondaryMap<FuncId, Option<SimpleJITCompiledFunction>>,
data_objects: SecondaryMap<DataId, Option<SimpleJITCompiledData>>, data_objects: SecondaryMap<DataId, Option<SimpleJITCompiledData>>,
functions_to_finalize: Vec<FuncId>, functions_to_finalize: Vec<FuncId>,
@@ -224,24 +225,20 @@ impl SimpleJITBackend {
} }
} }
fn get_definition( fn get_definition(&self, name: &ir::ExternalName) -> *const u8 {
&self,
declarations: &ModuleDeclarations,
name: &ir::ExternalName,
) -> *const u8 {
match *name { match *name {
ir::ExternalName::User { .. } => { ir::ExternalName::User { .. } => {
if declarations.is_function(name) { if self.declarations.is_function(name) {
let func_id = declarations.get_function_id(name); let func_id = self.declarations.get_function_id(name);
match &self.functions[func_id] { match &self.functions[func_id] {
Some(compiled) => compiled.code, Some(compiled) => compiled.code,
None => self.lookup_symbol(&declarations.get_function_decl(func_id).name), None => self.lookup_symbol(&self.declarations.get_function_decl(func_id).name),
} }
} else { } else {
let data_id = declarations.get_data_id(name); let data_id = self.declarations.get_data_id(name);
match &self.data_objects[data_id] { match &self.data_objects[data_id] {
Some(compiled) => compiled.storage, Some(compiled) => compiled.storage,
None => self.lookup_symbol(&declarations.get_data_decl(data_id).name), None => self.lookup_symbol(&self.declarations.get_data_decl(data_id).name),
} }
} }
} }
@@ -270,7 +267,7 @@ impl SimpleJITBackend {
} }
} }
fn finalize_function(&mut self, id: FuncId, declarations: &ModuleDeclarations) { fn finalize_function(&mut self, id: FuncId) {
use std::ptr::write_unaligned; use std::ptr::write_unaligned;
let func = self.functions[id] let func = self.functions[id]
@@ -287,7 +284,7 @@ impl SimpleJITBackend {
let ptr = func.code; let ptr = func.code;
debug_assert!((offset as usize) < func.size); debug_assert!((offset as usize) < func.size);
let at = unsafe { ptr.offset(offset as isize) }; let at = unsafe { ptr.offset(offset as isize) };
let base = self.get_definition(declarations, name); let base = self.get_definition(name);
// TODO: Handle overflow. // TODO: Handle overflow.
let what = unsafe { base.offset(addend as isize) }; let what = unsafe { base.offset(addend as isize) };
match reloc { match reloc {
@@ -318,7 +315,7 @@ impl SimpleJITBackend {
} }
} }
fn finalize_data(&mut self, id: DataId, declarations: &ModuleDeclarations) { fn finalize_data(&mut self, id: DataId) {
use std::ptr::write_unaligned; use std::ptr::write_unaligned;
let data = self.data_objects[id] let data = self.data_objects[id]
@@ -335,7 +332,7 @@ impl SimpleJITBackend {
let ptr = data.storage; let ptr = data.storage;
debug_assert!((offset as usize) < data.size); debug_assert!((offset as usize) < data.size);
let at = unsafe { ptr.offset(offset as isize) }; let at = unsafe { ptr.offset(offset as isize) };
let base = self.get_definition(declarations, name); let base = self.get_definition(name);
// TODO: Handle overflow. // TODO: Handle overflow.
let what = unsafe { base.offset(addend as isize) }; let what = unsafe { base.offset(addend as isize) };
match reloc { match reloc {
@@ -384,6 +381,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
symbols: builder.symbols, symbols: builder.symbols,
libcall_names: builder.libcall_names, libcall_names: builder.libcall_names,
memory, memory,
declarations: ModuleDeclarations::default(),
functions: SecondaryMap::new(), functions: SecondaryMap::new(),
data_objects: SecondaryMap::new(), data_objects: SecondaryMap::new(),
functions_to_finalize: Vec::new(), functions_to_finalize: Vec::new(),
@@ -395,28 +393,41 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
&*self.isa &*self.isa
} }
fn declare_function(&mut self, _id: FuncId, _name: &str, _linkage: Linkage) { fn declarations(&self) -> &ModuleDeclarations {
// Nothing to do. &self.declarations
}
fn declare_function(
&mut self,
name: &str,
linkage: Linkage,
signature: &ir::Signature,
) -> ModuleResult<FuncId> {
let (id, _decl) = self
.declarations
.declare_function(name, linkage, signature)?;
Ok(id)
} }
fn declare_data( fn declare_data(
&mut self, &mut self,
_id: DataId, name: &str,
_name: &str, linkage: Linkage,
_linkage: Linkage, writable: bool,
_writable: bool,
tls: bool, tls: bool,
_align: Option<u8>, align: Option<u8>,
) { ) -> ModuleResult<DataId> {
assert!(!tls, "SimpleJIT doesn't yet support TLS"); assert!(!tls, "SimpleJIT doesn't yet support TLS");
// Nothing to do. let (id, _decl) = self
.declarations
.declare_data(name, linkage, writable, tls, align)?;
Ok(id)
} }
fn define_function<TS>( fn define_function<TS>(
&mut self, &mut self,
id: FuncId, id: FuncId,
ctx: &mut cranelift_codegen::Context, ctx: &mut cranelift_codegen::Context,
declarations: &ModuleDeclarations,
trap_sink: &mut TS, trap_sink: &mut TS,
) -> ModuleResult<ModuleCompiledFunction> ) -> ModuleResult<ModuleCompiledFunction>
where where
@@ -428,7 +439,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
.. ..
} = ctx.compile(self.isa())?; } = ctx.compile(self.isa())?;
let decl = declarations.get_function_decl(id); let decl = self.declarations.get_function_decl(id);
if !decl.linkage.is_definable() { if !decl.linkage.is_definable() {
return Err(ModuleError::InvalidImportDefinition(decl.name.clone())); return Err(ModuleError::InvalidImportDefinition(decl.name.clone()));
} }
@@ -472,9 +483,8 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
&mut self, &mut self,
id: FuncId, id: FuncId,
bytes: &[u8], bytes: &[u8],
declarations: &ModuleDeclarations,
) -> ModuleResult<ModuleCompiledFunction> { ) -> ModuleResult<ModuleCompiledFunction> {
let decl = declarations.get_function_decl(id); let decl = self.declarations.get_function_decl(id);
if !decl.linkage.is_definable() { if !decl.linkage.is_definable() {
return Err(ModuleError::InvalidImportDefinition(decl.name.clone())); return Err(ModuleError::InvalidImportDefinition(decl.name.clone()));
} }
@@ -511,13 +521,8 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
Ok(ModuleCompiledFunction { size: total_size }) Ok(ModuleCompiledFunction { size: total_size })
} }
fn define_data( fn define_data(&mut self, id: DataId, data: &DataContext) -> ModuleResult<()> {
&mut self, let decl = self.declarations.get_data_decl(id);
id: DataId,
data: &DataContext,
declarations: &ModuleDeclarations,
) -> ModuleResult<()> {
let decl = declarations.get_data_decl(id);
if !decl.linkage.is_definable() { if !decl.linkage.is_definable() {
return Err(ModuleError::InvalidImportDefinition(decl.name.clone())); return Err(ModuleError::InvalidImportDefinition(decl.name.clone()));
} }
@@ -604,16 +609,16 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
/// ///
/// This method does not need to be called when access to the memory /// This method does not need to be called when access to the memory
/// handle is not required. /// handle is not required.
fn finish(mut self, declarations: ModuleDeclarations) -> Self::Product { fn finish(mut self) -> Self::Product {
for func in std::mem::take(&mut self.functions_to_finalize) { for func in std::mem::take(&mut self.functions_to_finalize) {
let decl = declarations.get_function_decl(func); let decl = self.declarations.get_function_decl(func);
debug_assert!(decl.linkage.is_definable()); debug_assert!(decl.linkage.is_definable());
self.finalize_function(func, &declarations); self.finalize_function(func);
} }
for data in std::mem::take(&mut self.data_objects_to_finalize) { for data in std::mem::take(&mut self.data_objects_to_finalize) {
let decl = declarations.get_data_decl(data); let decl = self.declarations.get_data_decl(data);
debug_assert!(decl.linkage.is_definable()); debug_assert!(decl.linkage.is_definable());
self.finalize_data(data, &declarations); self.finalize_data(data);
} }
// Now that we're done patching, prepare the memory for execution! // Now that we're done patching, prepare the memory for execution!
@@ -622,7 +627,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
SimpleJITProduct { SimpleJITProduct {
memory: self.memory, memory: self.memory,
declarations, declarations: self.declarations,
functions: self.functions, functions: self.functions,
data_objects: self.data_objects, data_objects: self.data_objects,
} }