Merge pull request #2674 from bjorn3/module_improvements

Make Module object safe
This commit is contained in:
Pat Hickey
2021-02-23 09:20:26 -08:00
committed by GitHub
3 changed files with 12 additions and 23 deletions

View File

@@ -596,15 +596,12 @@ impl Module for JITModule {
ctx.import_global_value(ir::ExternalName::user(1, data.as_u32()))
}
fn define_function<TS>(
fn define_function(
&mut self,
id: FuncId,
ctx: &mut cranelift_codegen::Context,
trap_sink: &mut TS,
) -> ModuleResult<ModuleCompiledFunction>
where
TS: TrapSink,
{
trap_sink: &mut dyn TrapSink,
) -> ModuleResult<ModuleCompiledFunction> {
info!("defining function {}: {}", id, ctx.func.display(self.isa()));
let CodeInfo {
total_size: code_size,

View File

@@ -464,14 +464,12 @@ pub trait Module {
/// Returns the size of the function's code and constant data.
///
/// Note: After calling this function the given `Context` will contain the compiled function.
fn define_function<TS>(
fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
trap_sink: &mut TS,
) -> ModuleResult<ModuleCompiledFunction>
where
TS: binemit::TrapSink;
trap_sink: &mut dyn binemit::TrapSink,
) -> ModuleResult<ModuleCompiledFunction>;
/// Define a function, taking the function body from the given `bytes`.
///
@@ -559,15 +557,12 @@ impl<M: Module> Module for &mut M {
(**self).declare_data_in_data(data, ctx)
}
fn define_function<TS>(
fn define_function(
&mut self,
func: FuncId,
ctx: &mut Context,
trap_sink: &mut TS,
) -> ModuleResult<ModuleCompiledFunction>
where
TS: binemit::TrapSink,
{
trap_sink: &mut dyn binemit::TrapSink,
) -> ModuleResult<ModuleCompiledFunction> {
(**self).define_function(func, ctx, trap_sink)
}

View File

@@ -243,15 +243,12 @@ impl Module for ObjectModule {
Ok(id)
}
fn define_function<TS>(
fn define_function(
&mut self,
func_id: FuncId,
ctx: &mut cranelift_codegen::Context,
trap_sink: &mut TS,
) -> ModuleResult<ModuleCompiledFunction>
where
TS: TrapSink,
{
trap_sink: &mut dyn TrapSink,
) -> ModuleResult<ModuleCompiledFunction> {
info!(
"defining function {}: {}",
func_id,