Skip to content

Commit de4af90

Browse files
authored
machinst x64: New backend unwind (#2266)
Addresses unwind for experimental x64 backend. The preliminary code enables backtrace on SystemV call convension.
1 parent 2702942 commit de4af90

File tree

25 files changed

+554
-29
lines changed

25 files changed

+554
-29
lines changed

cranelift/codegen/src/context.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ impl Context {
253253
&self,
254254
isa: &dyn TargetIsa,
255255
) -> CodegenResult<Option<crate::isa::unwind::UnwindInfo>> {
256+
if self.mach_compile_result.is_some() {
257+
return Ok(self
258+
.mach_compile_result
259+
.as_ref()
260+
.unwrap()
261+
.unwind_info
262+
.clone());
263+
}
256264
isa.create_unwind_info(&self.func)
257265
}
258266

cranelift/codegen/src/isa/aarch64/inst/emit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ impl MachInstEmitInfo for EmitInfo {
481481
impl MachInstEmit for Inst {
482482
type State = EmitState;
483483
type Info = EmitInfo;
484+
type UnwindInfo = super::unwind::AArch64UnwindInfo;
484485

485486
fn emit(&self, sink: &mut MachBuffer<Inst>, emit_info: &Self::Info, state: &mut EmitState) {
486487
// N.B.: we *must* not exceed the "worst-case size" used to compute

cranelift/codegen/src/isa/aarch64/inst/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub mod args;
2929
pub use self::args::*;
3030
pub mod emit;
3131
pub use self::emit::*;
32+
pub mod unwind;
3233

3334
#[cfg(test)]
3435
mod emit_tests;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use super::*;
2+
use crate::isa::unwind::UnwindInfo;
3+
use crate::result::CodegenResult;
4+
5+
pub struct AArch64UnwindInfo;
6+
7+
impl UnwindInfoGenerator<Inst> for AArch64UnwindInfo {
8+
fn create_unwind_info(
9+
_context: UnwindInfoContext<Inst>,
10+
_kind: UnwindInfoKind,
11+
) -> CodegenResult<Option<UnwindInfo>> {
12+
// TODO
13+
Ok(None)
14+
}
15+
}

cranelift/codegen/src/isa/aarch64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ impl MachBackend for AArch64Backend {
7777
buffer,
7878
frame_size,
7979
disasm,
80+
unwind_info: None,
8081
})
8182
}
8283

cranelift/codegen/src/isa/arm32/inst/emit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ impl MachInstEmitInfo for EmitInfo {
274274
impl MachInstEmit for Inst {
275275
type Info = EmitInfo;
276276
type State = EmitState;
277+
type UnwindInfo = super::unwind::Arm32UnwindInfo;
277278

278279
fn emit(&self, sink: &mut MachBuffer<Inst>, emit_info: &Self::Info, state: &mut EmitState) {
279280
let start_off = sink.cur_offset();

cranelift/codegen/src/isa/arm32/inst/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod emit;
2222
pub use self::emit::*;
2323
mod regs;
2424
pub use self::regs::*;
25+
pub mod unwind;
2526

2627
#[cfg(test)]
2728
mod emit_tests;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use super::*;
2+
use crate::isa::unwind::UnwindInfo;
3+
use crate::result::CodegenResult;
4+
5+
pub struct Arm32UnwindInfo;
6+
7+
impl UnwindInfoGenerator<Inst> for Arm32UnwindInfo {
8+
fn create_unwind_info(
9+
_context: UnwindInfoContext<Inst>,
10+
_kind: UnwindInfoKind,
11+
) -> CodegenResult<Option<UnwindInfo>> {
12+
// TODO
13+
Ok(None)
14+
}
15+
}

cranelift/codegen/src/isa/arm32/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ impl MachBackend for Arm32Backend {
7373
buffer,
7474
frame_size,
7575
disasm,
76+
unwind_info: None,
7677
})
7778
}
7879

cranelift/codegen/src/isa/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ mod arm32;
8787
#[cfg(feature = "arm64")]
8888
pub(crate) mod aarch64;
8989

90-
#[cfg(feature = "unwind")]
9190
pub mod unwind;
9291

9392
mod call_conv;

0 commit comments

Comments
 (0)