mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-31 15:22:03 +00:00
Function relocations are now working
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
use cranelift_codegen::binemit;
|
||||
use cranelift_codegen::ir::{self, ExternalName, SourceLoc, TrapCode};
|
||||
|
||||
pub use cranelift_codegen::binemit::Reloc;
|
||||
use cranelift_wasm::FuncIndex;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Relocation {
|
||||
/// The relocation code.
|
||||
@@ -92,6 +95,90 @@ impl RelocSink {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Implementation of a relocation sink that just saves all the information for later
|
||||
// pub struct RelocSink {
|
||||
// /// Relocations recorded for the function.
|
||||
// pub func_relocs: Vec<Relocation>,
|
||||
// }
|
||||
|
||||
// impl binemit::RelocSink for RelocSink {
|
||||
// fn reloc_ebb(
|
||||
// &mut self,
|
||||
// _offset: binemit::CodeOffset,
|
||||
// _reloc: binemit::Reloc,
|
||||
// _ebb_offset: binemit::CodeOffset,
|
||||
// ) {
|
||||
// // This should use the `offsets` field of `ir::Function`.
|
||||
// panic!("ebb headers not yet implemented");
|
||||
// }
|
||||
// fn reloc_external(
|
||||
// &mut self,
|
||||
// offset: binemit::CodeOffset,
|
||||
// reloc: binemit::Reloc,
|
||||
// name: &ExternalName,
|
||||
// addend: binemit::Addend,
|
||||
// ) {
|
||||
// let reloc_target = if let ExternalName::User { namespace, index } = *name {
|
||||
// debug_assert!(namespace == 0);
|
||||
// RelocationTarget::UserFunc(FuncIndex::new(index as usize))
|
||||
// } else if *name == ExternalName::testcase("grow_memory") {
|
||||
// RelocationTarget::GrowMemory
|
||||
// } else if *name == ExternalName::testcase("current_memory") {
|
||||
// RelocationTarget::CurrentMemory
|
||||
// } else {
|
||||
// panic!("unrecognized external name")
|
||||
// };
|
||||
// self.func_relocs.push(Relocation {
|
||||
// reloc,
|
||||
// reloc_target,
|
||||
// offset,
|
||||
// addend,
|
||||
// });
|
||||
// }
|
||||
// fn reloc_jt(
|
||||
// &mut self,
|
||||
// _offset: binemit::CodeOffset,
|
||||
// _reloc: binemit::Reloc,
|
||||
// _jt: ir::JumpTable,
|
||||
// ) {
|
||||
// panic!("jump tables not yet implemented");
|
||||
// }
|
||||
// }
|
||||
|
||||
// impl RelocSink {
|
||||
// pub fn new() -> Self {
|
||||
// Self {
|
||||
// func_relocs: Vec::new(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// A record of a relocation to perform.
|
||||
// #[derive(Debug, Clone)]
|
||||
// pub struct Relocation {
|
||||
// /// The relocation code.
|
||||
// pub reloc: binemit::Reloc,
|
||||
// /// Relocation target.
|
||||
// pub reloc_target: RelocationTarget,
|
||||
// /// The offset where to apply the relocation.
|
||||
// pub offset: binemit::CodeOffset,
|
||||
// /// The addend to add to the relocation value.
|
||||
// pub addend: binemit::Addend,
|
||||
// }
|
||||
|
||||
// /// Destination function. Can be either user function or some special one, like grow_memory.
|
||||
// #[derive(Debug, Copy, Clone)]
|
||||
// pub enum RelocationTarget {
|
||||
// /// The user function index.
|
||||
// UserFunc(FuncIndex),
|
||||
// /// Function for growing the default memory by the specified amount of pages.
|
||||
// GrowMemory,
|
||||
// /// Function for query current size of the default linear memory.
|
||||
// CurrentMemory,
|
||||
// }
|
||||
|
||||
|
||||
pub struct TrapData {
|
||||
pub offset: usize,
|
||||
pub code: TrapCode,
|
||||
|
Reference in New Issue
Block a user