This commit is contained in:
bjorn3
2019-01-15 17:30:40 +01:00
committed by Dan Gohman
parent 80031cb2b4
commit eb032fd0f4

View File

@@ -517,8 +517,9 @@ where
ctx: &mut Context, ctx: &mut Context,
peek_compiled: impl FnOnce(u32, &Context, &isa::TargetIsa) -> T, peek_compiled: impl FnOnce(u32, &Context, &isa::TargetIsa) -> T,
) -> ModuleResult<T> { ) -> ModuleResult<T> {
let (compiled, peek_res) = { let code_size;
let code_size = ctx.compile(self.backend.isa()).map_err(|e| { let compiled = {
code_size = ctx.compile(self.backend.isa()).map_err(|e| {
info!( info!(
"defining function {}: {}", "defining function {}: {}",
func, func,
@@ -535,23 +536,18 @@ where
return Err(ModuleError::InvalidImportDefinition(info.decl.name.clone())); return Err(ModuleError::InvalidImportDefinition(info.decl.name.clone()));
} }
let peek_res = peek_compiled(code_size, &ctx, self.backend.isa()); Some(self.backend.define_function(
&info.decl.name,
( ctx,
self.backend.define_function( &ModuleNamespace::<B> {
&info.decl.name, contents: &self.contents,
ctx, },
&ModuleNamespace::<B> { code_size,
contents: &self.contents, )?)
},
code_size,
)?,
peek_res,
)
}; };
self.contents.functions[func].compiled = Some(compiled); self.contents.functions[func].compiled = compiled;
self.functions_to_finalize.push(func); self.functions_to_finalize.push(func);
Ok(peek_res) Ok(peek_compiled(code_size, &ctx, self.backend.isa()))
} }
/// Define a function, producing the data contents from the given `DataContext`. /// Define a function, producing the data contents from the given `DataContext`.