Merge pull request #2674 from bjorn3/module_improvements
Make Module object safe
This commit is contained in:
@@ -596,15 +596,12 @@ impl Module for JITModule {
|
|||||||
ctx.import_global_value(ir::ExternalName::user(1, data.as_u32()))
|
ctx.import_global_value(ir::ExternalName::user(1, data.as_u32()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn define_function<TS>(
|
fn define_function(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: FuncId,
|
id: FuncId,
|
||||||
ctx: &mut cranelift_codegen::Context,
|
ctx: &mut cranelift_codegen::Context,
|
||||||
trap_sink: &mut TS,
|
trap_sink: &mut dyn TrapSink,
|
||||||
) -> ModuleResult<ModuleCompiledFunction>
|
) -> ModuleResult<ModuleCompiledFunction> {
|
||||||
where
|
|
||||||
TS: TrapSink,
|
|
||||||
{
|
|
||||||
info!("defining function {}: {}", id, ctx.func.display(self.isa()));
|
info!("defining function {}: {}", id, ctx.func.display(self.isa()));
|
||||||
let CodeInfo {
|
let CodeInfo {
|
||||||
total_size: code_size,
|
total_size: code_size,
|
||||||
|
|||||||
@@ -464,14 +464,12 @@ pub trait Module {
|
|||||||
/// Returns the size of the function's code and constant data.
|
/// Returns the size of the function's code and constant data.
|
||||||
///
|
///
|
||||||
/// Note: After calling this function the given `Context` will contain the compiled function.
|
/// Note: After calling this function the given `Context` will contain the compiled function.
|
||||||
fn define_function<TS>(
|
fn define_function(
|
||||||
&mut self,
|
&mut self,
|
||||||
func: FuncId,
|
func: FuncId,
|
||||||
ctx: &mut Context,
|
ctx: &mut Context,
|
||||||
trap_sink: &mut TS,
|
trap_sink: &mut dyn binemit::TrapSink,
|
||||||
) -> ModuleResult<ModuleCompiledFunction>
|
) -> ModuleResult<ModuleCompiledFunction>;
|
||||||
where
|
|
||||||
TS: binemit::TrapSink;
|
|
||||||
|
|
||||||
/// Define a function, taking the function body from the given `bytes`.
|
/// 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)
|
(**self).declare_data_in_data(data, ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn define_function<TS>(
|
fn define_function(
|
||||||
&mut self,
|
&mut self,
|
||||||
func: FuncId,
|
func: FuncId,
|
||||||
ctx: &mut Context,
|
ctx: &mut Context,
|
||||||
trap_sink: &mut TS,
|
trap_sink: &mut dyn binemit::TrapSink,
|
||||||
) -> ModuleResult<ModuleCompiledFunction>
|
) -> ModuleResult<ModuleCompiledFunction> {
|
||||||
where
|
|
||||||
TS: binemit::TrapSink,
|
|
||||||
{
|
|
||||||
(**self).define_function(func, ctx, trap_sink)
|
(**self).define_function(func, ctx, trap_sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,15 +243,12 @@ impl Module for ObjectModule {
|
|||||||
Ok(id)
|
Ok(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn define_function<TS>(
|
fn define_function(
|
||||||
&mut self,
|
&mut self,
|
||||||
func_id: FuncId,
|
func_id: FuncId,
|
||||||
ctx: &mut cranelift_codegen::Context,
|
ctx: &mut cranelift_codegen::Context,
|
||||||
trap_sink: &mut TS,
|
trap_sink: &mut dyn TrapSink,
|
||||||
) -> ModuleResult<ModuleCompiledFunction>
|
) -> ModuleResult<ModuleCompiledFunction> {
|
||||||
where
|
|
||||||
TS: TrapSink,
|
|
||||||
{
|
|
||||||
info!(
|
info!(
|
||||||
"defining function {}: {}",
|
"defining function {}: {}",
|
||||||
func_id,
|
func_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user