Rename "Stackmap" to "StackMap"

And "stackmap" to "stack_map".

This commit is purely mechanical.
This commit is contained in:
Nick Fitzgerald
2020-08-06 16:41:59 -07:00
parent b5a6daedc4
commit 05bf9ea3f3
44 changed files with 218 additions and 211 deletions

View File

@@ -3334,7 +3334,7 @@ pub(crate) fn define<'shared>(
recipes.add_recipe( recipes.add_recipe(
EncodingRecipeBuilder::new("safepoint", &formats.multiary, 0).emit( EncodingRecipeBuilder::new("safepoint", &formats.multiary, 0).emit(
r#" r#"
sink.add_stackmap(args, func, isa); sink.add_stack_map(args, func, isa);
"#, "#,
), ),
); );

20
cranelift/codegen/meta/src/shared/instructions.rs Normal file → Executable file
View File

@@ -2071,7 +2071,7 @@ pub(crate) fn define(
); );
let N = let N =
&Operand::new("args", &entities.varargs).with_doc("Variable number of args for Stackmap"); &Operand::new("args", &entities.varargs).with_doc("Variable number of args for StackMap");
ig.push( ig.push(
Inst::new( Inst::new(
@@ -3926,9 +3926,9 @@ pub(crate) fn define(
Inst::new( Inst::new(
"snarrow", "snarrow",
r#" r#"
Combine `x` and `y` into a vector with twice the lanes but half the integer width while Combine `x` and `y` into a vector with twice the lanes but half the integer width while
saturating overflowing values to the signed maximum and minimum. saturating overflowing values to the signed maximum and minimum.
The lanes will be concatenated after narrowing. For example, when `x` and `y` are `i32x4` The lanes will be concatenated after narrowing. For example, when `x` and `y` are `i32x4`
and `x = [x3, x2, x1, x0]` and `y = [y3, y2, y1, y0]`, then after narrowing the value and `x = [x3, x2, x1, x0]` and `y = [y3, y2, y1, y0]`, then after narrowing the value
returned is an `i16x8`: `a = [y3', y2', y1', y0', x3', x2', x1', x0']`. returned is an `i16x8`: `a = [y3', y2', y1', y0', x3', x2', x1', x0']`.
@@ -3943,12 +3943,12 @@ pub(crate) fn define(
Inst::new( Inst::new(
"unarrow", "unarrow",
r#" r#"
Combine `x` and `y` into a vector with twice the lanes but half the integer width while Combine `x` and `y` into a vector with twice the lanes but half the integer width while
saturating overflowing values to the unsigned maximum and minimum. saturating overflowing values to the unsigned maximum and minimum.
Note that all input lanes are considered signed: any negative lanes will overflow and be Note that all input lanes are considered signed: any negative lanes will overflow and be
replaced with the unsigned minimum, `0x00`. replaced with the unsigned minimum, `0x00`.
The lanes will be concatenated after narrowing. For example, when `x` and `y` are `i32x4` The lanes will be concatenated after narrowing. For example, when `x` and `y` are `i32x4`
and `x = [x3, x2, x1, x0]` and `y = [y3, y2, y1, y0]`, then after narrowing the value and `x = [x3, x2, x1, x0]` and `y = [y3, y2, y1, y0]`, then after narrowing the value
returned is an `i16x8`: `a = [y3', y2', y1', y0', x3', x2', x1', x0']`. returned is an `i16x8`: `a = [y3', y2', y1', y0', x3', x2', x1', x0']`.
@@ -3977,7 +3977,7 @@ pub(crate) fn define(
"swiden_low", "swiden_low",
r#" r#"
Widen the low lanes of `x` using signed extension. Widen the low lanes of `x` using signed extension.
This will double the lane width and halve the number of lanes. This will double the lane width and halve the number of lanes.
"#, "#,
&formats.unary, &formats.unary,
@@ -3991,7 +3991,7 @@ pub(crate) fn define(
"swiden_high", "swiden_high",
r#" r#"
Widen the high lanes of `x` using signed extension. Widen the high lanes of `x` using signed extension.
This will double the lane width and halve the number of lanes. This will double the lane width and halve the number of lanes.
"#, "#,
&formats.unary, &formats.unary,
@@ -4005,7 +4005,7 @@ pub(crate) fn define(
"uwiden_low", "uwiden_low",
r#" r#"
Widen the low lanes of `x` using unsigned extension. Widen the low lanes of `x` using unsigned extension.
This will double the lane width and halve the number of lanes. This will double the lane width and halve the number of lanes.
"#, "#,
&formats.unary, &formats.unary,
@@ -4019,7 +4019,7 @@ pub(crate) fn define(
"uwiden_high", "uwiden_high",
r#" r#"
Widen the high lanes of `x` using unsigned extension. Widen the high lanes of `x` using unsigned extension.
This will double the lane width and halve the number of lanes. This will double the lane width and halve the number of lanes.
"#, "#,
&formats.unary, &formats.unary,

View File

@@ -157,7 +157,7 @@ pub(crate) fn define() -> SettingGroup {
r#" r#"
Enable safepoint instruction insertions. Enable safepoint instruction insertions.
This will allow the emit_stackmaps() function to insert the safepoint This will allow the emit_stack_maps() function to insert the safepoint
instruction on top of calls and interrupt traps in order to display the instruction on top of calls and interrupt traps in order to display the
live reference values at that point in the program. live reference values at that point in the program.
"#, "#,

View File

@@ -14,7 +14,7 @@
//! relocations to a `RelocSink` trait object. Relocations are less frequent than the //! relocations to a `RelocSink` trait object. Relocations are less frequent than the
//! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe. //! `CodeSink::put*` methods, so the performance impact of the virtual callbacks is less severe.
use super::{Addend, CodeInfo, CodeOffset, CodeSink, Reloc}; use super::{Addend, CodeInfo, CodeOffset, CodeSink, Reloc};
use crate::binemit::stackmap::Stackmap; use crate::binemit::stack_map::StackMap;
use crate::ir::entities::Value; use crate::ir::entities::Value;
use crate::ir::{ConstantOffset, ExternalName, Function, JumpTable, Opcode, SourceLoc, TrapCode}; use crate::ir::{ConstantOffset, ExternalName, Function, JumpTable, Opcode, SourceLoc, TrapCode};
use crate::isa::TargetIsa; use crate::isa::TargetIsa;
@@ -38,7 +38,7 @@ pub struct MemoryCodeSink<'a> {
offset: isize, offset: isize,
relocs: &'a mut dyn RelocSink, relocs: &'a mut dyn RelocSink,
traps: &'a mut dyn TrapSink, traps: &'a mut dyn TrapSink,
stackmaps: &'a mut dyn StackmapSink, stack_maps: &'a mut dyn StackMapSink,
/// Information about the generated code and read-only data. /// Information about the generated code and read-only data.
pub info: CodeInfo, pub info: CodeInfo,
} }
@@ -54,7 +54,7 @@ impl<'a> MemoryCodeSink<'a> {
data: *mut u8, data: *mut u8,
relocs: &'a mut dyn RelocSink, relocs: &'a mut dyn RelocSink,
traps: &'a mut dyn TrapSink, traps: &'a mut dyn TrapSink,
stackmaps: &'a mut dyn StackmapSink, stack_maps: &'a mut dyn StackMapSink,
) -> Self { ) -> Self {
Self { Self {
data, data,
@@ -67,7 +67,7 @@ impl<'a> MemoryCodeSink<'a> {
}, },
relocs, relocs,
traps, traps,
stackmaps, stack_maps,
} }
} }
} }
@@ -182,10 +182,10 @@ impl<'a> CodeSink for MemoryCodeSink<'a> {
self.info.total_size = self.offset(); self.info.total_size = self.offset();
} }
fn add_stackmap(&mut self, val_list: &[Value], func: &Function, isa: &dyn TargetIsa) { fn add_stack_map(&mut self, val_list: &[Value], func: &Function, isa: &dyn TargetIsa) {
let ofs = self.offset(); let ofs = self.offset();
let stackmap = Stackmap::from_values(&val_list, func, isa); let stack_map = StackMap::from_values(&val_list, func, isa);
self.stackmaps.add_stackmap(ofs, stackmap); self.stack_maps.add_stack_map(ofs, stack_map);
} }
fn add_call_site(&mut self, opcode: Opcode, loc: SourceLoc) { fn add_call_site(&mut self, opcode: Opcode, loc: SourceLoc) {
@@ -227,15 +227,15 @@ impl TrapSink for NullTrapSink {
fn trap(&mut self, _offset: CodeOffset, _srcloc: SourceLoc, _code: TrapCode) {} fn trap(&mut self, _offset: CodeOffset, _srcloc: SourceLoc, _code: TrapCode) {}
} }
/// A trait for emitting stackmaps. /// A trait for emitting stack maps.
pub trait StackmapSink { pub trait StackMapSink {
/// Output a bitmap of the stack representing the live reference variables at this code offset. /// Output a bitmap of the stack representing the live reference variables at this code offset.
fn add_stackmap(&mut self, _: CodeOffset, _: Stackmap); fn add_stack_map(&mut self, _: CodeOffset, _: StackMap);
} }
/// Placeholder StackmapSink that does nothing. /// Placeholder StackMapSink that does nothing.
pub struct NullStackmapSink {} pub struct NullStackMapSink {}
impl StackmapSink for NullStackmapSink { impl StackMapSink for NullStackMapSink {
fn add_stackmap(&mut self, _: CodeOffset, _: Stackmap) {} fn add_stack_map(&mut self, _: CodeOffset, _: StackMap) {}
} }

View File

@@ -6,15 +6,15 @@
mod memorysink; mod memorysink;
mod relaxation; mod relaxation;
mod shrink; mod shrink;
mod stackmap; mod stack_map;
pub use self::memorysink::{ pub use self::memorysink::{
MemoryCodeSink, NullRelocSink, NullStackmapSink, NullTrapSink, RelocSink, StackmapSink, MemoryCodeSink, NullRelocSink, NullStackMapSink, NullTrapSink, RelocSink, StackMapSink,
TrapSink, TrapSink,
}; };
pub use self::relaxation::relax_branches; pub use self::relaxation::relax_branches;
pub use self::shrink::shrink_instructions; pub use self::shrink::shrink_instructions;
pub use self::stackmap::Stackmap; pub use self::stack_map::StackMap;
use crate::ir::entities::Value; use crate::ir::entities::Value;
use crate::ir::{ use crate::ir::{
ConstantOffset, ExternalName, Function, Inst, JumpTable, Opcode, SourceLoc, TrapCode, ConstantOffset, ExternalName, Function, Inst, JumpTable, Opcode, SourceLoc, TrapCode,
@@ -164,8 +164,8 @@ pub trait CodeSink {
/// Read-only data output is complete, we're done. /// Read-only data output is complete, we're done.
fn end_codegen(&mut self); fn end_codegen(&mut self);
/// Add a stackmap at the current code offset. /// Add a stack map at the current code offset.
fn add_stackmap(&mut self, _: &[Value], _: &Function, _: &dyn TargetIsa); fn add_stack_map(&mut self, _: &[Value], _: &Function, _: &dyn TargetIsa);
/// Add a call site for a call with the given opcode, returning at the current offset. /// Add a call site for a call with the given opcode, returning at the current offset.
fn add_call_site(&mut self, _: Opcode, _: SourceLoc) { fn add_call_site(&mut self, _: Opcode, _: SourceLoc) {

View File

@@ -59,7 +59,7 @@ const NUM_BITS: usize = core::mem::size_of::<Num>() * 8;
/// | ... | /// | ... |
/// ``` /// ```
/// ///
/// An individual `Stackmap` is associated with just one instruction pointer /// An individual `StackMap` is associated with just one instruction pointer
/// within the function, contains the size of the stack frame, and represents /// within the function, contains the size of the stack frame, and represents
/// the stack frame as a bitmap. There is one bit per word in the stack frame, /// the stack frame as a bitmap. There is one bit per word in the stack frame,
/// and if the bit is set, then the word contains a live GC reference. /// and if the bit is set, then the word contains a live GC reference.
@@ -70,13 +70,14 @@ const NUM_BITS: usize = core::mem::size_of::<Num>() * 8;
/// callee's stack map. /// callee's stack map.
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "enable-serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Stackmap { pub struct StackMap {
bitmap: Vec<BitSet<Num>>, bitmap: Vec<BitSet<Num>>,
mapped_words: u32, mapped_words: u32,
} }
impl Stackmap { impl StackMap {
/// Create a stackmap based on where references are located on a function's stack. /// Create a `StackMap` based on where references are located on a
/// function's stack.
pub fn from_values( pub fn from_values(
args: &[ir::entities::Value], args: &[ir::entities::Value],
func: &ir::Function, func: &ir::Function,
@@ -101,7 +102,7 @@ impl Stackmap {
let stack = &func.stack_slots; let stack = &func.stack_slots;
let info = func.stack_slots.layout_info.unwrap(); let info = func.stack_slots.layout_info.unwrap();
// Refer to the doc comment for `Stackmap` above to understand the // Refer to the doc comment for `StackMap` above to understand the
// bitmap representation used here. // bitmap representation used here.
let map_size = (info.frame_size + info.inbound_args_size) as usize; let map_size = (info.frame_size + info.inbound_args_size) as usize;
let word_size = isa.pointer_bytes() as usize; let word_size = isa.pointer_bytes() as usize;
@@ -171,9 +172,9 @@ mod tests {
use super::*; use super::*;
#[test] #[test]
fn stackmaps() { fn stack_maps() {
let vec: Vec<bool> = Vec::new(); let vec: Vec<bool> = Vec::new();
assert!(Stackmap::from_slice(&vec).bitmap.is_empty()); assert!(StackMap::from_slice(&vec).bitmap.is_empty());
let mut vec: [bool; NUM_BITS] = Default::default(); let mut vec: [bool; NUM_BITS] = Default::default();
let set_true_idx = [5, 7, 24, 31]; let set_true_idx = [5, 7, 24, 31];
@@ -185,12 +186,12 @@ mod tests {
let mut vec = vec.to_vec(); let mut vec = vec.to_vec();
assert_eq!( assert_eq!(
vec![BitSet::<Num>(2164261024)], vec![BitSet::<Num>(2164261024)],
Stackmap::from_slice(&vec).bitmap StackMap::from_slice(&vec).bitmap
); );
vec.push(false); vec.push(false);
vec.push(true); vec.push(true);
let res = Stackmap::from_slice(&vec); let res = StackMap::from_slice(&vec);
assert_eq!( assert_eq!(
vec![BitSet::<Num>(2164261024), BitSet::<Num>(2)], vec![BitSet::<Num>(2164261024), BitSet::<Num>(2)],
res.bitmap res.bitmap

View File

@@ -10,7 +10,7 @@
//! single ISA instance. //! single ISA instance.
use crate::binemit::{ use crate::binemit::{
relax_branches, shrink_instructions, CodeInfo, MemoryCodeSink, RelocSink, StackmapSink, relax_branches, shrink_instructions, CodeInfo, MemoryCodeSink, RelocSink, StackMapSink,
TrapSink, TrapSink,
}; };
use crate::dce::do_dce; use crate::dce::do_dce;
@@ -127,13 +127,19 @@ impl Context {
mem: &mut Vec<u8>, mem: &mut Vec<u8>,
relocs: &mut dyn RelocSink, relocs: &mut dyn RelocSink,
traps: &mut dyn TrapSink, traps: &mut dyn TrapSink,
stackmaps: &mut dyn StackmapSink, stack_maps: &mut dyn StackMapSink,
) -> CodegenResult<CodeInfo> { ) -> CodegenResult<CodeInfo> {
let info = self.compile(isa)?; let info = self.compile(isa)?;
let old_len = mem.len(); let old_len = mem.len();
mem.resize(old_len + info.total_size as usize, 0); mem.resize(old_len + info.total_size as usize, 0);
let new_info = unsafe { let new_info = unsafe {
self.emit_to_memory(isa, mem.as_mut_ptr().add(old_len), relocs, traps, stackmaps) self.emit_to_memory(
isa,
mem.as_mut_ptr().add(old_len),
relocs,
traps,
stack_maps,
)
}; };
debug_assert!(new_info == info); debug_assert!(new_info == info);
Ok(info) Ok(info)
@@ -222,10 +228,10 @@ impl Context {
mem: *mut u8, mem: *mut u8,
relocs: &mut dyn RelocSink, relocs: &mut dyn RelocSink,
traps: &mut dyn TrapSink, traps: &mut dyn TrapSink,
stackmaps: &mut dyn StackmapSink, stack_maps: &mut dyn StackMapSink,
) -> CodeInfo { ) -> CodeInfo {
let _tt = timing::binemit(); let _tt = timing::binemit();
let mut sink = MemoryCodeSink::new(mem, relocs, traps, stackmaps); let mut sink = MemoryCodeSink::new(mem, relocs, traps, stack_maps);
if let Some(ref result) = &self.mach_compile_result { if let Some(ref result) = &self.mach_compile_result {
result.buffer.emit(&mut sink); result.buffer.emit(&mut sink);
} else { } else {

View File

@@ -63,7 +63,7 @@ pub fn is_constant_64bit(func: &Function, inst: Inst) -> Option<u64> {
} }
/// Is the given instruction a safepoint (i.e., potentially causes a GC, depending on the /// Is the given instruction a safepoint (i.e., potentially causes a GC, depending on the
/// embedding, and so requires reftyped values to be enumerated with a stackmap)? /// embedding, and so requires reftyped values to be enumerated with a stack map)?
pub fn is_safepoint(func: &Function, inst: Inst) -> bool { pub fn is_safepoint(func: &Function, inst: Inst) -> bool {
let op = func.dfg[inst].opcode(); let op = func.dfg[inst].opcode();
op.is_resumable_trap() || op.is_call() op.is_resumable_trap() || op.is_call()

View File

@@ -90,7 +90,7 @@
//! - Return v1 in memory at `[P+8]`. //! - Return v1 in memory at `[P+8]`.
//! - Return v0 in memory at `[P+16]`. //! - Return v0 in memory at `[P+16]`.
use crate::binemit::Stackmap; use crate::binemit::StackMap;
use crate::ir; use crate::ir;
use crate::ir::types; use crate::ir::types;
use crate::ir::types::*; use crate::ir::types::*;
@@ -1074,10 +1074,10 @@ impl ABIBody for AArch64ABIBody {
store_stack(MemArg::NominalSPOffset(sp_off, ty), from_reg, ty) store_stack(MemArg::NominalSPOffset(sp_off, ty), from_reg, ty)
} }
fn spillslots_to_stackmap(&self, slots: &[SpillSlot], state: &EmitState) -> Stackmap { fn spillslots_to_stack_map(&self, slots: &[SpillSlot], state: &EmitState) -> StackMap {
assert!(state.virtual_sp_offset >= 0); assert!(state.virtual_sp_offset >= 0);
trace!( trace!(
"spillslots_to_stackmap: slots = {:?}, state = {:?}", "spillslots_to_stack_map: slots = {:?}, state = {:?}",
slots, slots,
state state
); );
@@ -1094,7 +1094,7 @@ impl ABIBody for AArch64ABIBody {
bits[first_spillslot_word + slot] = true; bits[first_spillslot_word + slot] = true;
} }
Stackmap::from_slice(&bits[..]) StackMap::from_slice(&bits[..])
} }
fn gen_prologue(&mut self) -> Vec<Inst> { fn gen_prologue(&mut self) -> Vec<Inst> {

View File

@@ -1,6 +1,6 @@
//! AArch64 ISA: binary code emission. //! AArch64 ISA: binary code emission.
use crate::binemit::{CodeOffset, Reloc, Stackmap}; use crate::binemit::{CodeOffset, Reloc, StackMap};
use crate::ir::constant::ConstantData; use crate::ir::constant::ConstantData;
use crate::ir::types::*; use crate::ir::types::*;
use crate::ir::TrapCode; use crate::ir::TrapCode;
@@ -429,8 +429,8 @@ pub struct EmitState {
pub(crate) virtual_sp_offset: i64, pub(crate) virtual_sp_offset: i64,
/// Offset of FP from nominal-SP. /// Offset of FP from nominal-SP.
pub(crate) nominal_sp_to_fp: i64, pub(crate) nominal_sp_to_fp: i64,
/// Safepoint stackmap for upcoming instruction, as provided to `pre_safepoint()`. /// Safepoint stack map for upcoming instruction, as provided to `pre_safepoint()`.
stackmap: Option<Stackmap>, stack_map: Option<StackMap>,
} }
impl MachInstEmitState<Inst> for EmitState { impl MachInstEmitState<Inst> for EmitState {
@@ -438,22 +438,22 @@ impl MachInstEmitState<Inst> for EmitState {
EmitState { EmitState {
virtual_sp_offset: 0, virtual_sp_offset: 0,
nominal_sp_to_fp: abi.frame_size() as i64, nominal_sp_to_fp: abi.frame_size() as i64,
stackmap: None, stack_map: None,
} }
} }
fn pre_safepoint(&mut self, stackmap: Stackmap) { fn pre_safepoint(&mut self, stack_map: StackMap) {
self.stackmap = Some(stackmap); self.stack_map = Some(stack_map);
} }
} }
impl EmitState { impl EmitState {
fn take_stackmap(&mut self) -> Option<Stackmap> { fn take_stack_map(&mut self) -> Option<StackMap> {
self.stackmap.take() self.stack_map.take()
} }
fn clear_post_insn(&mut self) { fn clear_post_insn(&mut self) {
self.stackmap = None; self.stack_map = None;
} }
} }
@@ -1854,8 +1854,8 @@ impl MachInstEmit for Inst {
// Noop; this is just a placeholder for epilogues. // Noop; this is just a placeholder for epilogues.
} }
&Inst::Call { ref info } => { &Inst::Call { ref info } => {
if let Some(s) = state.take_stackmap() { if let Some(s) = state.take_stack_map() {
sink.add_stackmap(StackmapExtent::UpcomingBytes(4), s); sink.add_stack_map(StackMapExtent::UpcomingBytes(4), s);
} }
sink.add_reloc(info.loc, Reloc::Arm64Call, &info.dest, 0); sink.add_reloc(info.loc, Reloc::Arm64Call, &info.dest, 0);
sink.put4(enc_jump26(0b100101, 0)); sink.put4(enc_jump26(0b100101, 0));
@@ -1864,8 +1864,8 @@ impl MachInstEmit for Inst {
} }
} }
&Inst::CallInd { ref info } => { &Inst::CallInd { ref info } => {
if let Some(s) = state.take_stackmap() { if let Some(s) = state.take_stack_map() {
sink.add_stackmap(StackmapExtent::UpcomingBytes(4), s); sink.add_stack_map(StackMapExtent::UpcomingBytes(4), s);
} }
sink.put4(0b1101011_0001_11111_000000_00000_00000 | (machreg_to_gpr(info.rn) << 5)); sink.put4(0b1101011_0001_11111_000000_00000_00000 | (machreg_to_gpr(info.rn) << 5));
if info.opcode.is_call() { if info.opcode.is_call() {
@@ -1922,8 +1922,8 @@ impl MachInstEmit for Inst {
&Inst::Udf { trap_info } => { &Inst::Udf { trap_info } => {
let (srcloc, code) = trap_info; let (srcloc, code) = trap_info;
sink.add_trap(srcloc, code); sink.add_trap(srcloc, code);
if let Some(s) = state.take_stackmap() { if let Some(s) = state.take_stack_map() {
sink.add_stackmap(StackmapExtent::UpcomingBytes(4), s); sink.add_stack_map(StackMapExtent::UpcomingBytes(4), s);
} }
sink.put4(0xd4a00000); sink.put4(0xd4a00000);
} }

View File

@@ -82,7 +82,7 @@ impl CodeSink for TestCodeSink {
fn end_codegen(&mut self) {} fn end_codegen(&mut self) {}
fn add_stackmap(&mut self, _val_list: &[Value], _func: &Function, _isa: &dyn TargetIsa) {} fn add_stack_map(&mut self, _val_list: &[Value], _func: &Function, _isa: &dyn TargetIsa) {}
fn add_call_site(&mut self, _opcode: Opcode, _srcloc: SourceLoc) {} fn add_call_site(&mut self, _opcode: Opcode, _srcloc: SourceLoc) {}
} }

View File

@@ -1,6 +1,6 @@
//! Implementation of the standard x64 ABI. //! Implementation of the standard x64 ABI.
use crate::binemit::Stackmap; use crate::binemit::StackMap;
use crate::ir::{self, types, ArgumentExtension, StackSlot, Type}; use crate::ir::{self, types, ArgumentExtension, StackSlot, Type};
use crate::isa::{x64::inst::*, CallConv}; use crate::isa::{x64::inst::*, CallConv};
use crate::machinst::*; use crate::machinst::*;
@@ -492,10 +492,10 @@ impl ABIBody for X64ABIBody {
) )
} }
fn spillslots_to_stackmap(&self, slots: &[SpillSlot], state: &EmitState) -> Stackmap { fn spillslots_to_stack_map(&self, slots: &[SpillSlot], state: &EmitState) -> StackMap {
assert!(state.virtual_sp_offset >= 0); assert!(state.virtual_sp_offset >= 0);
trace!( trace!(
"spillslots_to_stackmap: slots = {:?}, state = {:?}", "spillslots_to_stack_map: slots = {:?}, state = {:?}",
slots, slots,
state state
); );
@@ -511,7 +511,7 @@ impl ABIBody for X64ABIBody {
bits[first_spillslot_word + slot] = true; bits[first_spillslot_word + slot] = true;
} }
Stackmap::from_slice(&bits[..]) StackMap::from_slice(&bits[..])
} }
fn gen_prologue(&mut self) -> Vec<Inst> { fn gen_prologue(&mut self) -> Vec<Inst> {

View File

@@ -1349,8 +1349,8 @@ pub(crate) fn emit(
Inst::CallKnown { Inst::CallKnown {
dest, loc, opcode, .. dest, loc, opcode, ..
} => { } => {
if let Some(s) = state.take_stackmap() { if let Some(s) = state.take_stack_map() {
sink.add_stackmap(StackmapExtent::UpcomingBytes(5), s); sink.add_stack_map(StackMapExtent::UpcomingBytes(5), s);
} }
sink.put1(0xE8); sink.put1(0xE8);
// The addend adjusts for the difference between the end of the instruction and the // The addend adjusts for the difference between the end of the instruction and the
@@ -1393,8 +1393,8 @@ pub(crate) fn emit(
); );
} }
} }
if let Some(s) = state.take_stackmap() { if let Some(s) = state.take_stack_map() {
sink.add_stackmap(StackmapExtent::StartedAtOffset(start_offset), s); sink.add_stack_map(StackMapExtent::StartedAtOffset(start_offset), s);
} }
if opcode.is_call() { if opcode.is_call() {
sink.add_call_site(*loc, *opcode); sink.add_call_site(*loc, *opcode);
@@ -2428,8 +2428,8 @@ pub(crate) fn emit(
Inst::Ud2 { trap_info } => { Inst::Ud2 { trap_info } => {
sink.add_trap(trap_info.0, trap_info.1); sink.add_trap(trap_info.0, trap_info.1);
if let Some(s) = state.take_stackmap() { if let Some(s) = state.take_stack_map() {
sink.add_stackmap(StackmapExtent::UpcomingBytes(2), s); sink.add_stack_map(StackMapExtent::UpcomingBytes(2), s);
} }
sink.put1(0x0f); sink.put1(0x0f);
sink.put1(0x0b); sink.put1(0x0b);

View File

@@ -4,7 +4,7 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
use crate::binemit::{CodeOffset, Stackmap}; use crate::binemit::{CodeOffset, StackMap};
use crate::ir::{types, ExternalName, Opcode, SourceLoc, TrapCode, Type}; use crate::ir::{types, ExternalName, Opcode, SourceLoc, TrapCode, Type};
use crate::machinst::*; use crate::machinst::*;
use crate::{settings, settings::Flags, CodegenError, CodegenResult}; use crate::{settings, settings::Flags, CodegenError, CodegenResult};
@@ -2225,8 +2225,8 @@ pub struct EmitState {
pub(crate) virtual_sp_offset: i64, pub(crate) virtual_sp_offset: i64,
/// Offset of FP from nominal-SP. /// Offset of FP from nominal-SP.
pub(crate) nominal_sp_to_fp: i64, pub(crate) nominal_sp_to_fp: i64,
/// Safepoint stackmap for upcoming instruction, as provided to `pre_safepoint()`. /// Safepoint stack map for upcoming instruction, as provided to `pre_safepoint()`.
stackmap: Option<Stackmap>, stack_map: Option<StackMap>,
} }
impl MachInstEmit for Inst { impl MachInstEmit for Inst {
@@ -2246,22 +2246,22 @@ impl MachInstEmitState<Inst> for EmitState {
EmitState { EmitState {
virtual_sp_offset: 0, virtual_sp_offset: 0,
nominal_sp_to_fp: abi.frame_size() as i64, nominal_sp_to_fp: abi.frame_size() as i64,
stackmap: None, stack_map: None,
} }
} }
fn pre_safepoint(&mut self, stackmap: Stackmap) { fn pre_safepoint(&mut self, stack_map: StackMap) {
self.stackmap = Some(stackmap); self.stack_map = Some(stack_map);
} }
} }
impl EmitState { impl EmitState {
fn take_stackmap(&mut self) -> Option<Stackmap> { fn take_stack_map(&mut self) -> Option<StackMap> {
self.stackmap.take() self.stack_map.take()
} }
fn clear_post_insn(&mut self) { fn clear_post_insn(&mut self) {
self.stackmap = None; self.stack_map = None;
} }
} }

View File

@@ -1,6 +1,6 @@
//! ABI definitions. //! ABI definitions.
use crate::binemit::Stackmap; use crate::binemit::StackMap;
use crate::ir::StackSlot; use crate::ir::StackSlot;
use crate::machinst::*; use crate::machinst::*;
use crate::settings; use crate::settings;
@@ -96,14 +96,14 @@ pub trait ABIBody {
/// Store to a spillslot. /// Store to a spillslot.
fn store_spillslot(&self, slot: SpillSlot, ty: Type, from_reg: Reg) -> Self::I; fn store_spillslot(&self, slot: SpillSlot, ty: Type, from_reg: Reg) -> Self::I;
/// Generate a stackmap, given a list of spillslots and the emission state /// Generate a stack map, given a list of spillslots and the emission state
/// at a given program point (prior to emission fo the safepointing /// at a given program point (prior to emission fo the safepointing
/// instruction). /// instruction).
fn spillslots_to_stackmap( fn spillslots_to_stack_map(
&self, &self,
slots: &[SpillSlot], slots: &[SpillSlot],
state: &<Self::I as MachInstEmit>::State, state: &<Self::I as MachInstEmit>::State,
) -> Stackmap; ) -> StackMap;
/// Generate a prologue, post-regalloc. This should include any stack /// Generate a prologue, post-regalloc. This should include any stack
/// frame or other setup necessary to use the other methods (`load_arg`, /// frame or other setup necessary to use the other methods (`load_arg`,

View File

@@ -140,7 +140,7 @@
//! Given these invariants, we argue why each optimization preserves execution //! Given these invariants, we argue why each optimization preserves execution
//! semantics below (grep for "Preserves execution semantics"). //! semantics below (grep for "Preserves execution semantics").
use crate::binemit::{Addend, CodeOffset, CodeSink, Reloc, Stackmap}; use crate::binemit::{Addend, CodeOffset, CodeSink, Reloc, StackMap};
use crate::ir::{ExternalName, Opcode, SourceLoc, TrapCode}; use crate::ir::{ExternalName, Opcode, SourceLoc, TrapCode};
use crate::machinst::{BlockIndex, MachInstLabelUse, VCodeInst}; use crate::machinst::{BlockIndex, MachInstLabelUse, VCodeInst};
use crate::timing; use crate::timing;
@@ -169,8 +169,8 @@ pub struct MachBuffer<I: VCodeInst> {
call_sites: SmallVec<[MachCallSite; 16]>, call_sites: SmallVec<[MachCallSite; 16]>,
/// Any source location mappings referring to this code. /// Any source location mappings referring to this code.
srclocs: SmallVec<[MachSrcLoc; 64]>, srclocs: SmallVec<[MachSrcLoc; 64]>,
/// Any stackmaps referring to this code. /// Any stack maps referring to this code.
stackmaps: SmallVec<[MachStackMap; 8]>, stack_maps: SmallVec<[MachStackMap; 8]>,
/// The current source location in progress (after `start_srcloc()` and /// The current source location in progress (after `start_srcloc()` and
/// before `end_srcloc()`). This is a (start_offset, src_loc) tuple. /// before `end_srcloc()`). This is a (start_offset, src_loc) tuple.
cur_srcloc: Option<(CodeOffset, SourceLoc)>, cur_srcloc: Option<(CodeOffset, SourceLoc)>,
@@ -234,8 +234,8 @@ pub struct MachBufferFinalized {
call_sites: SmallVec<[MachCallSite; 16]>, call_sites: SmallVec<[MachCallSite; 16]>,
/// Any source location mappings referring to this code. /// Any source location mappings referring to this code.
srclocs: SmallVec<[MachSrcLoc; 64]>, srclocs: SmallVec<[MachSrcLoc; 64]>,
/// Any stackmaps referring to this code. /// Any stack maps referring to this code.
stackmaps: SmallVec<[MachStackMap; 8]>, stack_maps: SmallVec<[MachStackMap; 8]>,
} }
static UNKNOWN_LABEL_OFFSET: CodeOffset = 0xffff_ffff; static UNKNOWN_LABEL_OFFSET: CodeOffset = 0xffff_ffff;
@@ -261,8 +261,8 @@ impl MachLabel {
} }
} }
/// A stackmap extent, when creating a stackmap. /// A stack map extent, when creating a stack map.
pub enum StackmapExtent { pub enum StackMapExtent {
/// The stack map starts at this instruction, and ends after the number of upcoming bytes /// The stack map starts at this instruction, and ends after the number of upcoming bytes
/// (note: this is a code offset diff). /// (note: this is a code offset diff).
UpcomingBytes(CodeOffset), UpcomingBytes(CodeOffset),
@@ -282,7 +282,7 @@ impl<I: VCodeInst> MachBuffer<I> {
traps: SmallVec::new(), traps: SmallVec::new(),
call_sites: SmallVec::new(), call_sites: SmallVec::new(),
srclocs: SmallVec::new(), srclocs: SmallVec::new(),
stackmaps: SmallVec::new(), stack_maps: SmallVec::new(),
cur_srcloc: None, cur_srcloc: None,
label_offsets: SmallVec::new(), label_offsets: SmallVec::new(),
label_aliases: SmallVec::new(), label_aliases: SmallVec::new(),
@@ -1151,7 +1151,7 @@ impl<I: VCodeInst> MachBuffer<I> {
traps: self.traps, traps: self.traps,
call_sites: self.call_sites, call_sites: self.call_sites,
srclocs: self.srclocs, srclocs: self.srclocs,
stackmaps: self.stackmaps, stack_maps: self.stack_maps,
} }
} }
@@ -1212,28 +1212,28 @@ impl<I: VCodeInst> MachBuffer<I> {
} }
} }
/// Add stackmap metadata for this program point: a set of stack offsets (from SP upward) that /// Add stack map metadata for this program point: a set of stack offsets
/// contain live references. /// (from SP upward) that contain live references.
/// ///
/// The `offset_to_fp` value is the offset from the nominal SP (at which the `stack_offsets` /// The `offset_to_fp` value is the offset from the nominal SP (at which the `stack_offsets`
/// are based) and the FP value. By subtracting `offset_to_fp` from each `stack_offsets` /// are based) and the FP value. By subtracting `offset_to_fp` from each `stack_offsets`
/// element, one can obtain live-reference offsets from FP instead. /// element, one can obtain live-reference offsets from FP instead.
pub fn add_stackmap(&mut self, extent: StackmapExtent, stackmap: Stackmap) { pub fn add_stack_map(&mut self, extent: StackMapExtent, stack_map: StackMap) {
let (start, end) = match extent { let (start, end) = match extent {
StackmapExtent::UpcomingBytes(insn_len) => { StackMapExtent::UpcomingBytes(insn_len) => {
let start_offset = self.cur_offset(); let start_offset = self.cur_offset();
(start_offset, start_offset + insn_len) (start_offset, start_offset + insn_len)
} }
StackmapExtent::StartedAtOffset(start_offset) => { StackMapExtent::StartedAtOffset(start_offset) => {
let end_offset = self.cur_offset(); let end_offset = self.cur_offset();
debug_assert!(end_offset >= start_offset); debug_assert!(end_offset >= start_offset);
(start_offset, end_offset) (start_offset, end_offset)
} }
}; };
self.stackmaps.push(MachStackMap { self.stack_maps.push(MachStackMap {
offset: start, offset: start,
offset_end: end, offset_end: end,
stackmap, stack_map,
}); });
} }
} }
@@ -1295,9 +1295,9 @@ impl MachBufferFinalized {
sink.end_codegen(); sink.end_codegen();
} }
/// Get the stackmap metadata for this code. /// Get the stack map metadata for this code.
pub fn stackmaps(&self) -> &[MachStackMap] { pub fn stack_maps(&self) -> &[MachStackMap] {
&self.stackmaps[..] &self.stack_maps[..]
} }
} }
@@ -1378,17 +1378,17 @@ pub struct MachSrcLoc {
pub loc: SourceLoc, pub loc: SourceLoc,
} }
/// Record of stackmap metadata: stack offsets containing references. /// Record of stack map metadata: stack offsets containing references.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct MachStackMap { pub struct MachStackMap {
/// The code offset at which this stackmap applies. /// The code offset at which this stack map applies.
pub offset: CodeOffset, pub offset: CodeOffset,
/// The code offset just past the "end" of the instruction: that is, the /// The code offset just past the "end" of the instruction: that is, the
/// offset of the first byte of the following instruction, or equivalently, /// offset of the first byte of the following instruction, or equivalently,
/// the start offset plus the instruction length. /// the start offset plus the instruction length.
pub offset_end: CodeOffset, pub offset_end: CodeOffset,
/// The Stackmap itself. /// The stack map itself.
pub stackmap: Stackmap, pub stack_map: StackMap,
} }
/// Record of branch instruction in the buffer, to facilitate editing. /// Record of branch instruction in the buffer, to facilitate editing.

View File

@@ -23,7 +23,7 @@ where
// Build the lowering context. // Build the lowering context.
let lower = Lower::new(f, abi, block_order)?; let lower = Lower::new(f, abi, block_order)?;
// Lower the IR. // Lower the IR.
let (mut vcode, stackmap_request_info) = { let (mut vcode, stack_map_request_info) = {
let _tt = timing::vcode_lower(); let _tt = timing::vcode_lower();
lower.lower(b)? lower.lower(b)?
}; };
@@ -62,11 +62,11 @@ where
// If either there are no reference-typed values, or else there are // If either there are no reference-typed values, or else there are
// but there are no safepoints at which we need to know about them, // but there are no safepoints at which we need to know about them,
// then we don't need stackmaps. // then we don't need stack maps.
let sri = if stackmap_request_info.reftyped_vregs.len() > 0 let sri = if stack_map_request_info.reftyped_vregs.len() > 0
&& stackmap_request_info.safepoint_insns.len() > 0 && stack_map_request_info.safepoint_insns.len() > 0
{ {
Some(&stackmap_request_info) Some(&stack_map_request_info)
} else { } else {
None None
}; };

View File

@@ -778,10 +778,10 @@ impl<'func, I: VCodeInst> Lower<'func, I> {
self.copy_bbs_to_vcode(); self.copy_bbs_to_vcode();
// Now that we've emitted all instructions into the VCodeBuilder, let's build the VCode. // Now that we've emitted all instructions into the VCodeBuilder, let's build the VCode.
let (vcode, stackmap_info) = self.vcode.build(); let (vcode, stack_map_info) = self.vcode.build();
debug!("built vcode: {:?}", vcode); debug!("built vcode: {:?}", vcode);
Ok((vcode, stackmap_info)) Ok((vcode, stack_map_info))
} }
/// Get the actual inputs for a value. This is the implementation for /// Get the actual inputs for a value. This is the implementation for

View File

@@ -96,7 +96,7 @@
//! //!
//! ``` //! ```
use crate::binemit::{CodeInfo, CodeOffset, Stackmap}; use crate::binemit::{CodeInfo, CodeOffset, StackMap};
use crate::ir::condcodes::IntCC; use crate::ir::condcodes::IntCC;
use crate::ir::{Function, Type}; use crate::ir::{Function, Type};
use crate::result::CodegenResult; use crate::result::CodegenResult;
@@ -279,7 +279,7 @@ pub trait MachInstEmitState<I: MachInst>: Default + Clone + Debug {
fn new(abi: &dyn ABIBody<I = I>) -> Self; fn new(abi: &dyn ABIBody<I = I>) -> Self;
/// Update the emission state before emitting an instruction that is a /// Update the emission state before emitting an instruction that is a
/// safepoint. /// safepoint.
fn pre_safepoint(&mut self, _stackmap: Stackmap) {} fn pre_safepoint(&mut self, _stack_map: StackMap) {}
} }
/// The result of a `MachBackend::compile_function()` call. Contains machine /// The result of a `MachBackend::compile_function()` call. Contains machine

View File

@@ -94,7 +94,7 @@ pub struct VCode<I: VCodeInst> {
safepoint_insns: Vec<InsnIndex>, safepoint_insns: Vec<InsnIndex>,
/// For each safepoint entry in `safepoint_insns`, a list of `SpillSlot`s. /// For each safepoint entry in `safepoint_insns`, a list of `SpillSlot`s.
/// These are used to generate actual stackmaps at emission. Filled in /// These are used to generate actual stack maps at emission. Filled in
/// post-regalloc. /// post-regalloc.
safepoint_slots: Vec<Vec<SpillSlot>>, safepoint_slots: Vec<Vec<SpillSlot>>,
} }
@@ -117,8 +117,8 @@ pub struct VCodeBuilder<I: VCodeInst> {
/// In-progress VCode. /// In-progress VCode.
vcode: VCode<I>, vcode: VCode<I>,
/// In-progress stackmap-request info. /// In-progress stack map-request info.
stackmap_info: StackmapRequestInfo, stack_map_info: StackmapRequestInfo,
/// Index of the last block-start in the vcode. /// Index of the last block-start in the vcode.
block_start: InsnIndex, block_start: InsnIndex,
@@ -135,7 +135,7 @@ impl<I: VCodeInst> VCodeBuilder<I> {
pub fn new(abi: Box<dyn ABIBody<I = I>>, block_order: BlockLoweringOrder) -> VCodeBuilder<I> { pub fn new(abi: Box<dyn ABIBody<I = I>>, block_order: BlockLoweringOrder) -> VCodeBuilder<I> {
let reftype_class = I::ref_type_regclass(abi.flags()); let reftype_class = I::ref_type_regclass(abi.flags());
let vcode = VCode::new(abi, block_order); let vcode = VCode::new(abi, block_order);
let stackmap_info = StackmapRequestInfo { let stack_map_info = StackmapRequestInfo {
reftype_class, reftype_class,
reftyped_vregs: vec![], reftyped_vregs: vec![],
safepoint_insns: vec![], safepoint_insns: vec![],
@@ -143,7 +143,7 @@ impl<I: VCodeInst> VCodeBuilder<I> {
VCodeBuilder { VCodeBuilder {
vcode, vcode,
stackmap_info, stack_map_info,
block_start: 0, block_start: 0,
succ_start: 0, succ_start: 0,
cur_srcloc: SourceLoc::default(), cur_srcloc: SourceLoc::default(),
@@ -169,7 +169,7 @@ impl<I: VCodeInst> VCodeBuilder<I> {
} }
self.vcode.vreg_types[vreg.get_index()] = ty; self.vcode.vreg_types[vreg.get_index()] = ty;
if is_reftype(ty) { if is_reftype(ty) {
self.stackmap_info.reftyped_vregs.push(vreg); self.stack_map_info.reftyped_vregs.push(vreg);
self.vcode.have_ref_values = true; self.vcode.have_ref_values = true;
} }
} }
@@ -222,7 +222,7 @@ impl<I: VCodeInst> VCodeBuilder<I> {
self.vcode.insts.push(insn); self.vcode.insts.push(insn);
self.vcode.srclocs.push(self.cur_srcloc); self.vcode.srclocs.push(self.cur_srcloc);
if is_safepoint { if is_safepoint {
self.stackmap_info self.stack_map_info
.safepoint_insns .safepoint_insns
.push(InstIx::new((self.vcode.insts.len() - 1) as u32)); .push(InstIx::new((self.vcode.insts.len() - 1) as u32));
} }
@@ -239,12 +239,12 @@ impl<I: VCodeInst> VCodeBuilder<I> {
} }
/// Build the final VCode, returning the vcode itself as well as auxiliary /// Build the final VCode, returning the vcode itself as well as auxiliary
/// information, such as the stackmap request information. /// information, such as the stack map request information.
pub fn build(self) -> (VCode<I>, StackmapRequestInfo) { pub fn build(self) -> (VCode<I>, StackmapRequestInfo) {
// TODO: come up with an abstraction for "vcode and auxiliary data". The // TODO: come up with an abstraction for "vcode and auxiliary data". The
// auxiliary data needs to be separate from the vcode so that it can be // auxiliary data needs to be separate from the vcode so that it can be
// referenced as the vcode is mutated (e.g. by the register allocator). // referenced as the vcode is mutated (e.g. by the register allocator).
(self.vcode, self.stackmap_info) (self.vcode, self.stack_map_info)
} }
} }
@@ -460,11 +460,11 @@ impl<I: VCodeInst> VCode<I> {
&& self.safepoint_insns[safepoint_idx] == iix && self.safepoint_insns[safepoint_idx] == iix
{ {
if self.safepoint_slots[safepoint_idx].len() > 0 { if self.safepoint_slots[safepoint_idx].len() > 0 {
let stackmap = self.abi.spillslots_to_stackmap( let stack_map = self.abi.spillslots_to_stack_map(
&self.safepoint_slots[safepoint_idx][..], &self.safepoint_slots[safepoint_idx][..],
&state, &state,
); );
state.pre_safepoint(stackmap); state.pre_safepoint(stack_map);
} }
safepoint_idx += 1; safepoint_idx += 1;
} }

View File

@@ -14,7 +14,7 @@ use crate::regalloc::coloring::Coloring;
use crate::regalloc::live_value_tracker::LiveValueTracker; use crate::regalloc::live_value_tracker::LiveValueTracker;
use crate::regalloc::liveness::Liveness; use crate::regalloc::liveness::Liveness;
use crate::regalloc::reload::Reload; use crate::regalloc::reload::Reload;
use crate::regalloc::safepoint::emit_stackmaps; use crate::regalloc::safepoint::emit_stack_maps;
use crate::regalloc::spilling::Spilling; use crate::regalloc::spilling::Spilling;
use crate::regalloc::virtregs::VirtRegs; use crate::regalloc::virtregs::VirtRegs;
use crate::result::CodegenResult; use crate::result::CodegenResult;
@@ -206,7 +206,7 @@ impl Context {
// This function runs after register allocation has taken // This function runs after register allocation has taken
// place, meaning values have locations assigned already. // place, meaning values have locations assigned already.
if isa.flags().enable_safepoints() { if isa.flags().enable_safepoints() {
emit_stackmaps(func, domtree, &self.liveness, &mut self.tracker, isa); emit_stack_maps(func, domtree, &self.liveness, &mut self.tracker, isa);
} else { } else {
// Make sure no references are used. // Make sure no references are used.
for val in func.dfg.values() { for val in func.dfg.values() {

View File

@@ -23,4 +23,4 @@ mod spilling;
pub use self::context::Context; pub use self::context::Context;
pub use self::diversion::{EntryRegDiversions, RegDiversions}; pub use self::diversion::{EntryRegDiversions, RegDiversions};
pub use self::register_set::RegisterSet; pub use self::register_set::RegisterSet;
pub use self::safepoint::emit_stackmaps; pub use self::safepoint::emit_stack_maps;

View File

@@ -32,9 +32,9 @@ fn insert_and_encode_safepoint<'f>(
} }
} }
// The emit_stackmaps() function analyzes each instruction to retrieve the liveness of // The emit_stack_maps() function analyzes each instruction to retrieve the liveness of
// the defs and operands by traversing a function's blocks in layout order. // the defs and operands by traversing a function's blocks in layout order.
pub fn emit_stackmaps( pub fn emit_stack_maps(
func: &mut Function, func: &mut Function,
domtree: &DominatorTree, domtree: &DominatorTree,
liveness: &Liveness, liveness: &Liveness,

View File

@@ -3,7 +3,7 @@
use crate::container; use crate::container;
use anyhow::anyhow; use anyhow::anyhow;
use cranelift_codegen::binemit::{ use cranelift_codegen::binemit::{
Addend, CodeOffset, NullStackmapSink, Reloc, RelocSink, Stackmap, StackmapSink, TrapSink, Addend, CodeOffset, NullStackMapSink, Reloc, RelocSink, StackMap, StackMapSink, TrapSink,
}; };
use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::{self, binemit, ir}; use cranelift_codegen::{self, binemit, ir};
@@ -141,8 +141,8 @@ impl Backend for FaerieBackend {
TS: TrapSink, TS: TrapSink,
{ {
let mut code: Vec<u8> = vec![0; total_size as usize]; let mut code: Vec<u8> = vec![0; total_size as usize];
// TODO: Replace this with FaerieStackmapSink once it is implemented. // TODO: Replace this with FaerieStackMapSink once it is implemented.
let mut stackmap_sink = NullStackmapSink {}; let mut stack_map_sink = NullStackMapSink {};
// Non-lexical lifetimes would obviate the braces here. // Non-lexical lifetimes would obviate the braces here.
{ {
@@ -160,7 +160,7 @@ impl Backend for FaerieBackend {
code.as_mut_ptr(), code.as_mut_ptr(),
&mut reloc_sink, &mut reloc_sink,
trap_sink, trap_sink,
&mut stackmap_sink, &mut stack_map_sink,
) )
}; };
} }
@@ -469,14 +469,14 @@ impl<'a> RelocSink for FaerieRelocSink<'a> {
} }
#[allow(dead_code)] #[allow(dead_code)]
struct FaerieStackmapSink<'a> { struct FaerieStackMapSink<'a> {
artifact: &'a mut faerie::Artifact, artifact: &'a mut faerie::Artifact,
namespace: &'a ModuleNamespace<'a, FaerieBackend>, namespace: &'a ModuleNamespace<'a, FaerieBackend>,
} }
/// Faerie is currently not used in SpiderMonkey. Methods are unimplemented. /// Faerie is currently not used in SpiderMonkey. Methods are unimplemented.
impl<'a> StackmapSink for FaerieStackmapSink<'a> { impl<'a> StackMapSink for FaerieStackMapSink<'a> {
fn add_stackmap(&mut self, _: CodeOffset, _: Stackmap) { fn add_stack_map(&mut self, _: CodeOffset, _: StackMap) {
unimplemented!("faerie support for stackmaps"); unimplemented!("faerie support for stack maps");
} }
} }

View File

@@ -1,4 +1,4 @@
test stackmaps test stack_maps
set enable_safepoints=true set enable_safepoints=true
target x86_64 target x86_64

View File

@@ -1,4 +1,4 @@
test stackmaps test stack_maps
set enable_safepoints=true set enable_safepoints=true
target x86_64 target x86_64
@@ -28,4 +28,3 @@ block0(v0: r64, v1: r64, v2: r64, v3: r64, v4: r64):
; nextln: safepoint v4 ; nextln: safepoint v4
; nextln: - mapped words: 13 ; nextln: - mapped words: 13
; nextln: - live: [12] ; nextln: - live: [12]

View File

@@ -1,6 +1,6 @@
//! Provides functionality for compiling and running CLIF IR for `run` tests. //! Provides functionality for compiling and running CLIF IR for `run` tests.
use core::{mem, ptr}; use core::{mem, ptr};
use cranelift_codegen::binemit::{NullRelocSink, NullStackmapSink, NullTrapSink}; use cranelift_codegen::binemit::{NullRelocSink, NullStackMapSink, NullTrapSink};
use cranelift_codegen::ir::{condcodes::IntCC, Function, InstBuilder, Signature, Type}; use cranelift_codegen::ir::{condcodes::IntCC, Function, InstBuilder, Signature, Type};
use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::{ir, settings, CodegenError, Context}; use cranelift_codegen::{ir, settings, CodegenError, Context};
@@ -268,12 +268,12 @@ fn compile(function: Function, isa: &dyn TargetIsa) -> Result<Mmap, CompilationE
// Compile and encode the result to machine code. // Compile and encode the result to machine code.
let relocs = &mut NullRelocSink {}; let relocs = &mut NullRelocSink {};
let traps = &mut NullTrapSink {}; let traps = &mut NullTrapSink {};
let stackmaps = &mut NullStackmapSink {}; let stack_maps = &mut NullStackMapSink {};
let code_info = context.compile(isa)?; let code_info = context.compile(isa)?;
let mut code_page = MmapMut::map_anon(code_info.total_size as usize)?; let mut code_page = MmapMut::map_anon(code_info.total_size as usize)?;
unsafe { unsafe {
context.emit_to_memory(isa, code_page.as_mut_ptr(), relocs, traps, stackmaps); context.emit_to_memory(isa, code_page.as_mut_ptr(), relocs, traps, stack_maps);
}; };
let code_page = code_page.make_exec()?; let code_page = code_page.make_exec()?;

View File

@@ -56,7 +56,7 @@ mod test_safepoint;
mod test_shrink; mod test_shrink;
mod test_simple_gvn; mod test_simple_gvn;
mod test_simple_preopt; mod test_simple_preopt;
mod test_stackmaps; mod test_stack_maps;
mod test_unwind; mod test_unwind;
mod test_verifier; mod test_verifier;
@@ -140,7 +140,7 @@ fn new_subtest(parsed: &TestCommand) -> subtest::SubtestResult<Box<dyn subtest::
"shrink" => test_shrink::subtest(parsed), "shrink" => test_shrink::subtest(parsed),
"simple-gvn" => test_simple_gvn::subtest(parsed), "simple-gvn" => test_simple_gvn::subtest(parsed),
"simple_preopt" => test_simple_preopt::subtest(parsed), "simple_preopt" => test_simple_preopt::subtest(parsed),
"stackmaps" => test_stackmaps::subtest(parsed), "stack_maps" => test_stack_maps::subtest(parsed),
"unwind" => test_unwind::subtest(parsed), "unwind" => test_unwind::subtest(parsed),
"verifier" => test_verifier::subtest(parsed), "verifier" => test_verifier::subtest(parsed),
_ => Err(format!("unknown test command '{}'", parsed.command)), _ => Err(format!("unknown test command '{}'", parsed.command)),

View File

@@ -108,7 +108,7 @@ impl binemit::CodeSink for TextSink {
} }
fn begin_rodata(&mut self) {} fn begin_rodata(&mut self) {}
fn end_codegen(&mut self) {} fn end_codegen(&mut self) {}
fn add_stackmap( fn add_stack_map(
&mut self, &mut self,
_: &[ir::entities::Value], _: &[ir::entities::Value],
_: &ir::Function, _: &ir::Function,

View File

@@ -129,7 +129,7 @@ impl binemit::CodeSink for SizeSink {
fn begin_jumptables(&mut self) {} fn begin_jumptables(&mut self) {}
fn begin_rodata(&mut self) {} fn begin_rodata(&mut self) {}
fn end_codegen(&mut self) {} fn end_codegen(&mut self) {}
fn add_stackmap( fn add_stack_map(
&mut self, &mut self,
_: &[ir::entities::Value], _: &[ir::entities::Value],
_: &ir::Function, _: &ir::Function,

View File

@@ -132,5 +132,5 @@ impl binemit::CodeSink for RodataSink {
"Expected rodata to be emitted before the end of codegen" "Expected rodata to be emitted before the end of codegen"
); );
} }
fn add_stackmap(&mut self, _: &[Value], _: &Function, _: &dyn TargetIsa) {} fn add_stack_map(&mut self, _: &[Value], _: &Function, _: &dyn TargetIsa) {}
} }

View File

@@ -1,5 +1,5 @@
use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult}; use crate::subtest::{run_filecheck, Context, SubTest, SubtestResult};
use cranelift_codegen::binemit::{self, Addend, CodeOffset, CodeSink, Reloc, Stackmap}; use cranelift_codegen::binemit::{self, Addend, CodeOffset, CodeSink, Reloc, StackMap};
use cranelift_codegen::ir::*; use cranelift_codegen::ir::*;
use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::print_errors::pretty_error;
@@ -7,27 +7,27 @@ use cranelift_reader::TestCommand;
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt::Write; use std::fmt::Write;
struct TestStackmaps; struct TestStackMaps;
pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> { pub fn subtest(parsed: &TestCommand) -> SubtestResult<Box<dyn SubTest>> {
assert_eq!(parsed.command, "stackmaps"); assert_eq!(parsed.command, "stack_maps");
if !parsed.options.is_empty() { if !parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed)) Err(format!("No options allowed on {}", parsed))
} else { } else {
Ok(Box::new(TestStackmaps)) Ok(Box::new(TestStackMaps))
} }
} }
impl SubTest for TestStackmaps { impl SubTest for TestStackMaps {
fn name(&self) -> &'static str { fn name(&self) -> &'static str {
"stackmaps" "stack_maps"
} }
fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> { fn run(&self, func: Cow<Function>, context: &Context) -> SubtestResult<()> {
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned()); let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
comp_ctx comp_ctx
.compile(context.isa.expect("`test stackmaps` requires an isa")) .compile(context.isa.expect("`test stack_maps` requires an isa"))
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?; .map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
let mut sink = TestStackMapsSink::default(); let mut sink = TestStackMapsSink::default();
@@ -40,7 +40,7 @@ impl SubTest for TestStackmaps {
isa.emit_inst(func, inst, div, sink) isa.emit_inst(func, inst, div, sink)
}, },
&mut sink, &mut sink,
context.isa.expect("`test stackmaps` requires an isa"), context.isa.expect("`test stack_maps` requires an isa"),
); );
let mut text = comp_ctx.func.display(context.isa).to_string(); let mut text = comp_ctx.func.display(context.isa).to_string();
@@ -48,6 +48,7 @@ impl SubTest for TestStackmaps {
text.push_str("Stack maps:\n"); text.push_str("Stack maps:\n");
text.push('\n'); text.push('\n');
text.push_str(&sink.text); text.push_str(&sink.text);
log::debug!("FITZGEN:\n{}", text);
run_filecheck(&text, context) run_filecheck(&text, context)
} }
@@ -89,8 +90,8 @@ impl CodeSink for TestStackMapsSink {
fn begin_rodata(&mut self) {} fn begin_rodata(&mut self) {}
fn end_codegen(&mut self) {} fn end_codegen(&mut self) {}
fn add_stackmap(&mut self, val_list: &[Value], func: &Function, isa: &dyn TargetIsa) { fn add_stack_map(&mut self, val_list: &[Value], func: &Function, isa: &dyn TargetIsa) {
let map = Stackmap::from_values(&val_list, func, isa); let map = StackMap::from_values(&val_list, func, isa);
writeln!(&mut self.text, " - mapped words: {}", map.mapped_words()).unwrap(); writeln!(&mut self.text, " - mapped words: {}", map.mapped_words()).unwrap();
write!(&mut self.text, " - live: [").unwrap(); write!(&mut self.text, " - live: [").unwrap();

View File

@@ -2,7 +2,7 @@
use anyhow::anyhow; use anyhow::anyhow;
use cranelift_codegen::binemit::{ use cranelift_codegen::binemit::{
Addend, CodeOffset, NullStackmapSink, Reloc, RelocSink, TrapSink, Addend, CodeOffset, NullStackMapSink, Reloc, RelocSink, TrapSink,
}; };
use cranelift_codegen::entity::SecondaryMap; use cranelift_codegen::entity::SecondaryMap;
use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::isa::TargetIsa;
@@ -213,7 +213,7 @@ impl Backend for ObjectBackend {
{ {
let mut code: Vec<u8> = vec![0; code_size as usize]; let mut code: Vec<u8> = vec![0; code_size as usize];
let mut reloc_sink = ObjectRelocSink::new(self.object.format()); let mut reloc_sink = ObjectRelocSink::new(self.object.format());
let mut stackmap_sink = NullStackmapSink {}; let mut stack_map_sink = NullStackMapSink {};
unsafe { unsafe {
ctx.emit_to_memory( ctx.emit_to_memory(
@@ -221,7 +221,7 @@ impl Backend for ObjectBackend {
code.as_mut_ptr(), code.as_mut_ptr(),
&mut reloc_sink, &mut reloc_sink,
trap_sink, trap_sink,
&mut stackmap_sink, &mut stack_map_sink,
) )
}; };

View File

@@ -2,7 +2,7 @@
use crate::memory::Memory; use crate::memory::Memory;
use cranelift_codegen::binemit::{ use cranelift_codegen::binemit::{
Addend, CodeOffset, Reloc, RelocSink, Stackmap, StackmapSink, TrapSink, Addend, CodeOffset, Reloc, RelocSink, StackMap, StackMapSink, TrapSink,
}; };
use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::isa::TargetIsa;
use cranelift_codegen::settings::Configurable; use cranelift_codegen::settings::Configurable;
@@ -134,11 +134,11 @@ struct RelocRecord {
addend: Addend, addend: Addend,
} }
struct StackmapRecord { struct StackMapRecord {
#[allow(dead_code)] #[allow(dead_code)]
offset: CodeOffset, offset: CodeOffset,
#[allow(dead_code)] #[allow(dead_code)]
stackmap: Stackmap, stack_map: StackMap,
} }
pub struct SimpleJITCompiledFunction { pub struct SimpleJITCompiledFunction {
@@ -298,14 +298,14 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
self.record_function_for_perf(ptr, size, name); self.record_function_for_perf(ptr, size, name);
let mut reloc_sink = SimpleJITRelocSink::new(); let mut reloc_sink = SimpleJITRelocSink::new();
let mut stackmap_sink = SimpleJITStackmapSink::new(); let mut stack_map_sink = SimpleJITStackMapSink::new();
unsafe { unsafe {
ctx.emit_to_memory( ctx.emit_to_memory(
&*self.isa, &*self.isa,
ptr, ptr,
&mut reloc_sink, &mut reloc_sink,
trap_sink, trap_sink,
&mut stackmap_sink, &mut stack_map_sink,
) )
}; };
@@ -675,20 +675,20 @@ impl RelocSink for SimpleJITRelocSink {
} }
} }
struct SimpleJITStackmapSink { struct SimpleJITStackMapSink {
pub stackmaps: Vec<StackmapRecord>, pub stack_maps: Vec<StackMapRecord>,
} }
impl SimpleJITStackmapSink { impl SimpleJITStackMapSink {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
stackmaps: Vec::new(), stack_maps: Vec::new(),
} }
} }
} }
impl StackmapSink for SimpleJITStackmapSink { impl StackMapSink for SimpleJITStackMapSink {
fn add_stackmap(&mut self, offset: CodeOffset, stackmap: Stackmap) { fn add_stack_map(&mut self, offset: CodeOffset, stack_map: StackMap) {
self.stackmaps.push(StackmapRecord { offset, stackmap }); self.stack_maps.push(StackMapRecord { offset, stack_map });
} }
} }

View File

@@ -1,6 +1,6 @@
//! CLI tool to reduce Cranelift IR files crashing during compilation. //! CLI tool to reduce Cranelift IR files crashing during compilation.
use crate::disasm::{PrintRelocs, PrintStackmaps, PrintTraps}; use crate::disasm::{PrintRelocs, PrintStackMaps, PrintTraps};
use crate::utils::{parse_sets_and_triple, read_to_string}; use crate::utils::{parse_sets_and_triple, read_to_string};
use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::cursor::{Cursor, FuncCursor};
use cranelift_codegen::flowgraph::ControlFlowGraph; use cranelift_codegen::flowgraph::ControlFlowGraph;
@@ -1045,14 +1045,14 @@ impl<'a> CrashCheckContext<'a> {
let res = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { let res = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
let mut relocs = PrintRelocs::new(false); let mut relocs = PrintRelocs::new(false);
let mut traps = PrintTraps::new(false); let mut traps = PrintTraps::new(false);
let mut stackmaps = PrintStackmaps::new(false); let mut stack_maps = PrintStackMaps::new(false);
let _ = self.context.compile_and_emit( let _ = self.context.compile_and_emit(
self.isa, self.isa,
&mut self.code_memory, &mut self.code_memory,
&mut relocs, &mut relocs,
&mut traps, &mut traps,
&mut stackmaps, &mut stack_maps,
); );
})) { })) {
Ok(()) => CheckResult::Succeed, Ok(()) => CheckResult::Succeed,

View File

@@ -1,6 +1,6 @@
//! CLI tool to read Cranelift IR files and compile them into native code. //! CLI tool to read Cranelift IR files and compile them into native code.
use crate::disasm::{print_all, PrintRelocs, PrintStackmaps, PrintTraps}; use crate::disasm::{print_all, PrintRelocs, PrintStackMaps, PrintTraps};
use crate::utils::{parse_sets_and_triple, read_to_string}; use crate::utils::{parse_sets_and_triple, read_to_string};
use cranelift_codegen::print_errors::pretty_error; use cranelift_codegen::print_errors::pretty_error;
use cranelift_codegen::settings::FlagsOrIsa; use cranelift_codegen::settings::FlagsOrIsa;
@@ -58,7 +58,7 @@ fn handle_module(
for (func, _) in test_file.functions { for (func, _) in test_file.functions {
let mut relocs = PrintRelocs::new(flag_print); let mut relocs = PrintRelocs::new(flag_print);
let mut traps = PrintTraps::new(flag_print); let mut traps = PrintTraps::new(flag_print);
let mut stackmaps = PrintStackmaps::new(flag_print); let mut stack_maps = PrintStackMaps::new(flag_print);
if let Some(isa) = isa { if let Some(isa) = isa {
let mut context = Context::new(); let mut context = Context::new();
@@ -67,7 +67,7 @@ fn handle_module(
// Compile and encode the result to machine code. // Compile and encode the result to machine code.
let code_info = context let code_info = context
.compile_and_emit(isa, &mut mem, &mut relocs, &mut traps, &mut stackmaps) .compile_and_emit(isa, &mut mem, &mut relocs, &mut traps, &mut stack_maps)
.map_err(|err| pretty_error(&context.func, Some(isa), err))?; .map_err(|err| pretty_error(&context.func, Some(isa), err))?;
if flag_print { if flag_print {
@@ -82,7 +82,7 @@ fn handle_module(
code_info.jumptables_size + code_info.rodata_size, code_info.jumptables_size + code_info.rodata_size,
&relocs, &relocs,
&traps, &traps,
&stackmaps, &stack_maps,
)?; )?;
} }
} }

View File

@@ -97,12 +97,12 @@ impl binemit::TrapSink for PrintTraps {
} }
} }
pub struct PrintStackmaps { pub struct PrintStackMaps {
pub flag_print: bool, pub flag_print: bool,
pub text: String, pub text: String,
} }
impl PrintStackmaps { impl PrintStackMaps {
pub fn new(flag_print: bool) -> Self { pub fn new(flag_print: bool) -> Self {
Self { Self {
flag_print, flag_print,
@@ -111,10 +111,10 @@ impl PrintStackmaps {
} }
} }
impl binemit::StackmapSink for PrintStackmaps { impl binemit::StackMapSink for PrintStackMaps {
fn add_stackmap(&mut self, offset: binemit::CodeOffset, _: binemit::Stackmap) { fn add_stack_map(&mut self, offset: binemit::CodeOffset, _: binemit::StackMap) {
if self.flag_print { if self.flag_print {
writeln!(&mut self.text, "add_stackmap at {}", offset).unwrap(); writeln!(&mut self.text, "add_stack_map at {}", offset).unwrap();
} }
} }
} }
@@ -223,12 +223,12 @@ pub fn print_all(
rodata_size: u32, rodata_size: u32,
relocs: &PrintRelocs, relocs: &PrintRelocs,
traps: &PrintTraps, traps: &PrintTraps,
stackmaps: &PrintStackmaps, stack_maps: &PrintStackMaps,
) -> Result<(), String> { ) -> Result<(), String> {
print_bytes(&mem); print_bytes(&mem);
print_disassembly(isa, &mem[0..code_size as usize])?; print_disassembly(isa, &mem[0..code_size as usize])?;
print_readonly_data(&mem[code_size as usize..(code_size + rodata_size) as usize]); print_readonly_data(&mem[code_size as usize..(code_size + rodata_size) as usize]);
println!("\n{}\n{}\n{}", &relocs.text, &traps.text, &stackmaps.text); println!("\n{}\n{}\n{}", &relocs.text, &traps.text, &stack_maps.text);
Ok(()) Ok(())
} }

View File

@@ -7,7 +7,7 @@
allow(clippy::too_many_arguments, clippy::cognitive_complexity) allow(clippy::too_many_arguments, clippy::cognitive_complexity)
)] )]
use crate::disasm::{print_all, PrintRelocs, PrintStackmaps, PrintTraps}; use crate::disasm::{print_all, PrintRelocs, PrintStackMaps, PrintTraps};
use crate::utils::parse_sets_and_triple; use crate::utils::parse_sets_and_triple;
use crate::UseTerminalColor; use crate::UseTerminalColor;
use cranelift_codegen::ir::DisplayFunctionAnnotations; use cranelift_codegen::ir::DisplayFunctionAnnotations;
@@ -219,14 +219,14 @@ fn handle_module(
let mut mem = vec![]; let mut mem = vec![];
let mut relocs = PrintRelocs::new(flag_print); let mut relocs = PrintRelocs::new(flag_print);
let mut traps = PrintTraps::new(flag_print); let mut traps = PrintTraps::new(flag_print);
let mut stackmaps = PrintStackmaps::new(flag_print); let mut stack_maps = PrintStackMaps::new(flag_print);
if flag_check_translation { if flag_check_translation {
if let Err(errors) = context.verify(fisa) { if let Err(errors) = context.verify(fisa) {
return Err(pretty_verifier_error(&context.func, fisa.isa, None, errors)); return Err(pretty_verifier_error(&context.func, fisa.isa, None, errors));
} }
} else { } else {
let code_info = context let code_info = context
.compile_and_emit(isa, &mut mem, &mut relocs, &mut traps, &mut stackmaps) .compile_and_emit(isa, &mut mem, &mut relocs, &mut traps, &mut stack_maps)
.map_err(|err| pretty_error(&context.func, fisa.isa, err))?; .map_err(|err| pretty_error(&context.func, fisa.isa, err))?;
if flag_print_size { if flag_print_size {
@@ -289,7 +289,7 @@ fn handle_module(
rodata_size, rodata_size,
&relocs, &relocs,
&traps, &traps,
&stackmaps, &stack_maps,
)?; )?;
} }

View File

@@ -76,7 +76,7 @@ pub struct StackMapInformation {
pub code_offset: binemit::CodeOffset, pub code_offset: binemit::CodeOffset,
/// The stack map for identifying live GC refs at the GC safepoint. /// The stack map for identifying live GC refs at the GC safepoint.
pub stack_map: binemit::Stackmap, pub stack_map: binemit::StackMap,
} }
/// An error while compiling WebAssembly to machine code. /// An error while compiling WebAssembly to machine code.

View File

@@ -208,8 +208,8 @@ struct StackMapSink {
infos: Vec<StackMapInformation>, infos: Vec<StackMapInformation>,
} }
impl binemit::StackmapSink for StackMapSink { impl binemit::StackMapSink for StackMapSink {
fn add_stackmap(&mut self, code_offset: binemit::CodeOffset, stack_map: binemit::Stackmap) { fn add_stack_map(&mut self, code_offset: binemit::CodeOffset, stack_map: binemit::StackMap) {
self.infos.push(StackMapInformation { self.infos.push(StackMapInformation {
code_offset, code_offset,
stack_map, stack_map,

View File

@@ -1,7 +1,7 @@
#![doc(hidden)] #![doc(hidden)]
pub mod ir { pub mod ir {
pub use cranelift_codegen::binemit::{Reloc, Stackmap}; pub use cranelift_codegen::binemit::{Reloc, StackMap};
pub use cranelift_codegen::ir::{ pub use cranelift_codegen::ir::{
types, AbiParam, ArgumentPurpose, JumpTableOffsets, LibCall, Signature, SourceLoc, types, AbiParam, ArgumentPurpose, JumpTableOffsets, LibCall, Signature, SourceLoc,
StackSlots, TrapCode, Type, ValueLabel, ValueLoc, StackSlots, TrapCode, Type, ValueLabel, ValueLoc,

View File

@@ -22,7 +22,7 @@ pub use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
pub mod binemit { pub mod binemit {
pub use cranelift_codegen::binemit::NullTrapSink; pub use cranelift_codegen::binemit::NullTrapSink;
pub(super) use cranelift_codegen::binemit::{Addend, Reloc, RelocSink}; pub(super) use cranelift_codegen::binemit::{Addend, Reloc, RelocSink};
pub use cranelift_codegen::binemit::{CodeOffset, NullStackmapSink, TrapSink}; pub use cranelift_codegen::binemit::{CodeOffset, NullStackMapSink, TrapSink};
} }
/// Create a trampoline for invoking a function. /// Create a trampoline for invoking a function.
@@ -130,14 +130,14 @@ pub(crate) fn build_trampoline(
let mut code_buf = Vec::new(); let mut code_buf = Vec::new();
let mut reloc_sink = TrampolineRelocSink::default(); let mut reloc_sink = TrampolineRelocSink::default();
let mut trap_sink = binemit::NullTrapSink {}; let mut trap_sink = binemit::NullTrapSink {};
let mut stackmap_sink = binemit::NullStackmapSink {}; let mut stack_map_sink = binemit::NullStackMapSink {};
context context
.compile_and_emit( .compile_and_emit(
isa, isa,
&mut code_buf, &mut code_buf,
&mut reloc_sink, &mut reloc_sink,
&mut trap_sink, &mut trap_sink,
&mut stackmap_sink, &mut stack_map_sink,
) )
.map_err(|error| { .map_err(|error| {
SetupError::Compile(CompileError::Codegen(pretty_error( SetupError::Compile(CompileError::Codegen(pretty_error(

View File

@@ -110,7 +110,7 @@ use std::mem;
use std::ops::Deref; use std::ops::Deref;
use std::ptr::{self, NonNull}; use std::ptr::{self, NonNull};
use std::rc::Rc; use std::rc::Rc;
use wasmtime_environ::{ir::Stackmap, StackMapInformation}; use wasmtime_environ::{ir::StackMap, StackMapInformation};
/// An external reference to some opaque data. /// An external reference to some opaque data.
/// ///
@@ -780,7 +780,7 @@ struct ModuleStackMaps {
/// A map from a PC in this module (that is a GC safepoint) to its /// A map from a PC in this module (that is a GC safepoint) to its
/// associated stack map. /// associated stack map.
pc_to_stack_map: Vec<(usize, Rc<Stackmap>)>, pc_to_stack_map: Vec<(usize, Rc<StackMap>)>,
} }
impl StackMapRegistry { impl StackMapRegistry {
@@ -849,7 +849,7 @@ impl StackMapRegistry {
} }
/// Lookup the stack map for the given PC, if any. /// Lookup the stack map for the given PC, if any.
pub fn lookup_stack_map(&self, pc: usize) -> Option<Rc<Stackmap>> { pub fn lookup_stack_map(&self, pc: usize) -> Option<Rc<StackMap>> {
let inner = self.inner.borrow(); let inner = self.inner.borrow();
let stack_maps = inner.module_stack_maps(pc)?; let stack_maps = inner.module_stack_maps(pc)?;

View File

@@ -174,14 +174,14 @@ fn make_trampoline(
let mut code_buf: Vec<u8> = Vec::new(); let mut code_buf: Vec<u8> = Vec::new();
let mut reloc_sink = trampoline::TrampolineRelocSink::default(); let mut reloc_sink = trampoline::TrampolineRelocSink::default();
let mut trap_sink = binemit::NullTrapSink {}; let mut trap_sink = binemit::NullTrapSink {};
let mut stackmap_sink = binemit::NullStackmapSink {}; let mut stack_map_sink = binemit::NullStackMapSink {};
context context
.compile_and_emit( .compile_and_emit(
isa, isa,
&mut code_buf, &mut code_buf,
&mut reloc_sink, &mut reloc_sink,
&mut trap_sink, &mut trap_sink,
&mut stackmap_sink, &mut stack_map_sink,
) )
.map_err(|error| pretty_error(&context.func, Some(isa), error)) .map_err(|error| pretty_error(&context.func, Some(isa), error))
.expect("compile_and_emit"); .expect("compile_and_emit");