diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-04-09 14:05:27 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-04-09 14:40:23 +0000 |
| commit | 9495eb517e5a2b76fcdb514eeec5aa4d8fd16320 (patch) | |
| tree | 83c357b1df02fc2e8e5a0a7fa8b0670100a2e768 /src | |
| parent | ab514c95967a7c5d732aa1e3800afc4d9cb252f9 (diff) | |
| download | rust-9495eb517e5a2b76fcdb514eeec5aa4d8fd16320.tar.gz rust-9495eb517e5a2b76fcdb514eeec5aa4d8fd16320.zip | |
Pass Module to UnwindContext
Once writing the LSDA, it will need access to the Module to get a reference to the personality function and to define a data object for the LSDA. Part of rust-lang/rustc_codegen_cranelift#1567
Diffstat (limited to 'src')
| -rw-r--r-- | src/debuginfo/unwind.rs | 20 | ||||
| -rw-r--r-- | src/unwind_module.rs | 8 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 362333d35a4..74b82a7139a 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -1,7 +1,6 @@ //! Unwind info generation (`.eh_frame`) use cranelift_codegen::ir::Endianness; -use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::isa::unwind::UnwindInfo; use cranelift_object::ObjectProduct; use gimli::RunTimeEndian; @@ -18,14 +17,14 @@ pub(crate) struct UnwindContext { } impl UnwindContext { - pub(crate) fn new(isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self { - let endian = match isa.endianness() { + pub(crate) fn new(module: &mut dyn Module, pic_eh_frame: bool) -> Self { + let endian = match module.isa().endianness() { Endianness::Little => RunTimeEndian::Little, Endianness::Big => RunTimeEndian::Big, }; let mut frame_table = FrameTable::default(); - let cie_id = if let Some(mut cie) = isa.create_systemv_cie() { + let cie_id = if let Some(mut cie) = module.isa().create_systemv_cie() { if pic_eh_frame { cie.fde_address_encoding = gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0); @@ -38,8 +37,15 @@ impl UnwindContext { UnwindContext { endian, frame_table, cie_id } } - pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) { - if let target_lexicon::OperatingSystem::MacOSX { .. } = isa.triple().operating_system { + pub(crate) fn add_function( + &mut self, + module: &mut dyn Module, + func_id: FuncId, + context: &Context, + ) { + if let target_lexicon::OperatingSystem::MacOSX { .. } = + module.isa().triple().operating_system + { // The object crate doesn't currently support DW_GNU_EH_PE_absptr, which macOS // requires for unwinding tables. In addition on arm64 it currently doesn't // support 32bit relocations as we currently use for the unwinding table. @@ -48,7 +54,7 @@ impl UnwindContext { } let unwind_info = if let Some(unwind_info) = - context.compiled_code().unwrap().create_unwind_info(isa).unwrap() + context.compiled_code().unwrap().create_unwind_info(module.isa()).unwrap() { unwind_info } else { diff --git a/src/unwind_module.rs b/src/unwind_module.rs index b950aaa29ce..f963dc79fbb 100644 --- a/src/unwind_module.rs +++ b/src/unwind_module.rs @@ -17,8 +17,8 @@ pub(crate) struct UnwindModule<T> { } impl<T: Module> UnwindModule<T> { - pub(crate) fn new(module: T, pic_eh_frame: bool) -> Self { - let unwind_context = UnwindContext::new(module.isa(), pic_eh_frame); + pub(crate) fn new(mut module: T, pic_eh_frame: bool) -> Self { + let unwind_context = UnwindContext::new(&mut module, pic_eh_frame); UnwindModule { module, unwind_context } } } @@ -37,7 +37,7 @@ impl UnwindModule<cranelift_jit::JITModule> { self.module.finalize_definitions().unwrap(); let prev_unwind_context = std::mem::replace( &mut self.unwind_context, - UnwindContext::new(self.module.isa(), false), + UnwindContext::new(&mut self.module, false), ); unsafe { prev_unwind_context.register_jit(&self.module) }; } @@ -94,7 +94,7 @@ impl<T: Module> Module for UnwindModule<T> { ctrl_plane: &mut ControlPlane, ) -> ModuleResult<()> { self.module.define_function_with_control_plane(func, ctx, ctrl_plane)?; - self.unwind_context.add_function(func, ctx, self.module.isa()); + self.unwind_context.add_function(&mut self.module, func, ctx); Ok(()) } |
