Add FuncEnvironment hooks to generate prologue and epilogue code.

In some cases, it is useful to do some work at entry to or exit from a
Cranelift function translated from WebAssembly. This PR adds two
optional methods to the `FuncEnvironment` trait to do just this,
analogous to the pre/post-hooks on operators that already exist.

This PR also includes a drive-by compilation fix due to the latest
nightly wherein `.is_empty()` on a `Range` ambiguously refers to either
the `Range` impl or the `ExactSizeIterator` impl and can't resolve.
This commit is contained in:
Chris Fallin
2020-11-24 16:22:29 -08:00
parent bf971efa42
commit 4300c2c075
3 changed files with 23 additions and 2 deletions

View File

@@ -104,7 +104,7 @@ impl UnwindInfoGenerator<Inst> for AArch64UnwindInfo {
// TODO epilogues
let prologue_size = if context.prologue.is_empty() {
let prologue_size = if context.prologue.len() == 0 {
0
} else {
context.insts_layout[context.prologue.end as usize - 1]