Skip to content

Commit 9495eb5

Browse files
committed
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
1 parent ab514c9 commit 9495eb5

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎src/debuginfo/unwind.rs‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Unwind info generation (`.eh_frame`)
22
33
use cranelift_codegen::ir::Endianness;
4-
use cranelift_codegen::isa::TargetIsa;
54
use cranelift_codegen::isa::unwind::UnwindInfo;
65
use cranelift_object::ObjectProduct;
76
use gimli::RunTimeEndian;
@@ -18,14 +17,14 @@ pub(crate) struct UnwindContext {
1817
}
1918

2019
implUnwindContext{
21-
pub(crate)fnnew(isa:&dynTargetIsa,pic_eh_frame:bool) -> Self{
22-
let endian = match isa.endianness(){
20+
pub(crate)fnnew(module:&mutdynModule,pic_eh_frame:bool) -> Self{
21+
let endian = matchmodule.isa().endianness(){
2322
Endianness::Little => RunTimeEndian::Little,
2423
Endianness::Big => RunTimeEndian::Big,
2524
};
2625
letmut frame_table = FrameTable::default();
2726

28-
let cie_id = ifletSome(mut cie) = isa.create_systemv_cie(){
27+
let cie_id = ifletSome(mut cie) = module.isa().create_systemv_cie(){
2928
if pic_eh_frame {
3029
cie.fde_address_encoding =
3130
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
@@ -38,8 +37,15 @@ impl UnwindContext {
3837
UnwindContext{ endian, frame_table, cie_id }
3938
}
4039

41-
pub(crate)fnadd_function(&mutself,func_id:FuncId,context:&Context,isa:&dynTargetIsa){
42-
iflet target_lexicon::OperatingSystem::MacOSX{ .. } = isa.triple().operating_system{
40+
pub(crate)fnadd_function(
41+
&mutself,
42+
module:&mutdynModule,
43+
func_id:FuncId,
44+
context:&Context,
45+
){
46+
iflet target_lexicon::OperatingSystem::MacOSX{ .. } =
47+
module.isa().triple().operating_system
48+
{
4349
// The object crate doesn't currently support DW_GNU_EH_PE_absptr, which macOS
4450
// requires for unwinding tables. In addition on arm64 it currently doesn't
4551
// support 32bit relocations as we currently use for the unwinding table.
@@ -48,7 +54,7 @@ impl UnwindContext {
4854
}
4955

5056
let unwind_info = ifletSome(unwind_info) =
51-
context.compiled_code().unwrap().create_unwind_info(isa).unwrap()
57+
context.compiled_code().unwrap().create_unwind_info(module.isa()).unwrap()
5258
{
5359
unwind_info
5460
}else{

‎src/unwind_module.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub(crate) struct UnwindModule<T> {
1717
}
1818

1919
impl<T:Module>UnwindModule<T>{
20-
pub(crate)fnnew(module:T,pic_eh_frame:bool) -> Self{
21-
let unwind_context = UnwindContext::new(module.isa(), pic_eh_frame);
20+
pub(crate)fnnew(mutmodule:T,pic_eh_frame:bool) -> Self{
21+
let unwind_context = UnwindContext::new(&mutmodule, pic_eh_frame);
2222
UnwindModule{ module, unwind_context }
2323
}
2424
}
@@ -37,7 +37,7 @@ impl UnwindModule<cranelift_jit::JITModule> {
3737
self.module.finalize_definitions().unwrap();
3838
let prev_unwind_context = std::mem::replace(
3939
&mutself.unwind_context,
40-
UnwindContext::new(self.module.isa(),false),
40+
UnwindContext::new(&mutself.module,false),
4141
);
4242
unsafe{ prev_unwind_context.register_jit(&self.module)};
4343
}
@@ -94,7 +94,7 @@ impl<T: Module> Module for UnwindModule<T> {
9494
ctrl_plane:&mutControlPlane,
9595
) -> ModuleResult<()>{
9696
self.module.define_function_with_control_plane(func, ctx, ctrl_plane)?;
97-
self.unwind_context.add_function(func, ctx,self.module.isa());
97+
self.unwind_context.add_function(&mutself.module, func, ctx);
9898
Ok(())
9999
}
100100

0 commit comments

Comments
 (0)