Merge pull request #1214 from froydnj/trap-exposure
cranelift-module: expose trap information when defining functions
This commit is contained in:
@@ -17,6 +17,7 @@ use object::write::{
|
||||
use object::{RelocationEncoding, RelocationKind, SymbolFlags, SymbolKind, SymbolScope};
|
||||
use std::collections::HashMap;
|
||||
use std::mem;
|
||||
use std::ops::IndexMut;
|
||||
use target_lexicon::{BinaryFormat, PointerWidth};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -188,7 +189,7 @@ impl Backend for ObjectBackend {
|
||||
ctx: &cranelift_codegen::Context,
|
||||
_namespace: &ModuleNamespace<Self>,
|
||||
code_size: u32,
|
||||
) -> ModuleResult<ObjectCompiledFunction> {
|
||||
) -> ModuleResult<(ObjectCompiledFunction, &[TrapSite])> {
|
||||
let mut code: Vec<u8> = vec![0; code_size as usize];
|
||||
let mut reloc_sink = ObjectRelocSink::new(self.object.format());
|
||||
let mut trap_sink = ObjectTrapSink::default();
|
||||
@@ -229,8 +230,9 @@ impl Backend for ObjectBackend {
|
||||
relocs: reloc_sink.relocs,
|
||||
});
|
||||
}
|
||||
self.traps[func_id] = trap_sink.sites;
|
||||
Ok(ObjectCompiledFunction)
|
||||
let trapref = self.traps.index_mut(func_id);
|
||||
*trapref = trap_sink.sites;
|
||||
Ok((ObjectCompiledFunction, trapref))
|
||||
}
|
||||
|
||||
fn define_function_bytes(
|
||||
@@ -240,14 +242,15 @@ impl Backend for ObjectBackend {
|
||||
bytes: &[u8],
|
||||
_namespace: &ModuleNamespace<Self>,
|
||||
traps: Vec<TrapSite>,
|
||||
) -> ModuleResult<ObjectCompiledFunction> {
|
||||
) -> ModuleResult<(ObjectCompiledFunction, &[TrapSite])> {
|
||||
let symbol = self.functions[func_id].unwrap();
|
||||
let section = self.object.section_id(StandardSection::Text);
|
||||
let _offset = self
|
||||
.object
|
||||
.add_symbol_data(symbol, section, bytes, self.function_alignment);
|
||||
self.traps[func_id] = traps;
|
||||
Ok(ObjectCompiledFunction)
|
||||
let trapref = self.traps.index_mut(func_id);
|
||||
*trapref = traps;
|
||||
Ok((ObjectCompiledFunction, trapref))
|
||||
}
|
||||
|
||||
fn define_data(
|
||||
|
||||
Reference in New Issue
Block a user