Add TargetIsa::map_dwarf_register; fixes #1471

This exposes the functionality of `fde::map_reg` on the `TargetIsa` trait, avoiding compilation errors on architectures where register mapping is not yet supported. The change is conditially compiled under the `unwind` feature.
This commit is contained in:
Andrew Brown
2020-04-08 14:17:59 -07:00
parent c4e90f729c
commit 6fd0451bc3
7 changed files with 39 additions and 28 deletions

View File

@@ -5,7 +5,6 @@ use more_asserts::{assert_le, assert_lt};
use std::collections::{HashMap, HashSet};
use wasmtime_environ::entity::EntityRef;
use wasmtime_environ::ir::{StackSlots, ValueLabel, ValueLabelsRanges, ValueLoc};
use wasmtime_environ::isa::fde::map_reg;
use wasmtime_environ::isa::TargetIsa;
use wasmtime_environ::wasm::{get_vmctx_value_label, DefinedFuncIndex};
use wasmtime_environ::ModuleMemoryOffset;
@@ -79,7 +78,7 @@ fn translate_loc(
use gimli::write::Writer;
Ok(match loc {
ValueLoc::Reg(reg) => {
let machine_reg = map_reg(isa, reg)?.0 as u8;
let machine_reg = isa.map_dwarf_register(reg)? as u8;
Some(if machine_reg < 32 {
vec![gimli::constants::DW_OP_reg0.0 + machine_reg]
} else {
@@ -120,8 +119,8 @@ fn append_memory_deref(
// FIXME for imported memory
match vmctx_loc {
ValueLoc::Reg(vmctx_reg) => {
let reg = map_reg(isa, vmctx_reg)?;
writer.write_u8(gimli::constants::DW_OP_breg0.0 + reg.0 as u8)?;
let reg = isa.map_dwarf_register(vmctx_reg)? as u8;
writer.write_u8(gimli::constants::DW_OP_breg0.0 + reg)?;
let memory_offset = match frame_info.vmctx_memory_offset() {
Some(offset) => offset,
None => {