Rustfmt
This commit is contained in:
parent
e910a24d44
commit
c352f91b40
5 changed files with 28 additions and 46 deletions
|
@ -81,9 +81,7 @@ fn main() {
|
||||||
None,
|
None,
|
||||||
Some(Box::new(move |_| {
|
Some(Box::new(move |_| {
|
||||||
Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend {
|
Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend {
|
||||||
config: rustc_codegen_cranelift::BackendConfig {
|
config: rustc_codegen_cranelift::BackendConfig { use_jit },
|
||||||
use_jit,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|
|
@ -84,9 +84,8 @@ impl WriterRelocate {
|
||||||
match reloc.name {
|
match reloc.name {
|
||||||
super::DebugRelocName::Section(_) => unreachable!(),
|
super::DebugRelocName::Section(_) => unreachable!(),
|
||||||
super::DebugRelocName::Symbol(sym) => {
|
super::DebugRelocName::Symbol(sym) => {
|
||||||
let addr = jit_product.lookup_func(
|
let addr = jit_product
|
||||||
cranelift_module::FuncId::from_u32(sym.try_into().unwrap()),
|
.lookup_func(cranelift_module::FuncId::from_u32(sym.try_into().unwrap()));
|
||||||
);
|
|
||||||
let val = (addr as u64 as i64 + reloc.addend) as u64;
|
let val = (addr as u64 as i64 + reloc.addend) as u64;
|
||||||
self.writer
|
self.writer
|
||||||
.write_udata_at(reloc.offset as usize, val, reloc.size)
|
.write_udata_at(reloc.offset as usize, val, reloc.size)
|
||||||
|
@ -163,12 +162,7 @@ impl Writer for WriterRelocate {
|
||||||
self.write_udata_at(offset, 0, size)
|
self.write_udata_at(offset, 0, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_eh_pointer(
|
fn write_eh_pointer(&mut self, address: Address, eh_pe: gimli::DwEhPe, size: u8) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
address: Address,
|
|
||||||
eh_pe: gimli::DwEhPe,
|
|
||||||
size: u8,
|
|
||||||
) -> Result<()> {
|
|
||||||
match address {
|
match address {
|
||||||
// Address::Constant arm copied from gimli
|
// Address::Constant arm copied from gimli
|
||||||
Address::Constant(val) => {
|
Address::Constant(val) => {
|
||||||
|
@ -186,27 +180,25 @@ impl Writer for WriterRelocate {
|
||||||
};
|
};
|
||||||
self.write_eh_pointer_data(val, eh_pe.format(), size)
|
self.write_eh_pointer_data(val, eh_pe.format(), size)
|
||||||
}
|
}
|
||||||
Address::Symbol { symbol, addend } => {
|
Address::Symbol { symbol, addend } => match eh_pe.application() {
|
||||||
match eh_pe.application() {
|
gimli::DW_EH_PE_pcrel => {
|
||||||
gimli::DW_EH_PE_pcrel => {
|
let size = match eh_pe.format() {
|
||||||
let size = match eh_pe.format() {
|
gimli::DW_EH_PE_sdata4 => 4,
|
||||||
gimli::DW_EH_PE_sdata4 => 4,
|
_ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)),
|
||||||
_ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)),
|
};
|
||||||
};
|
self.relocs.push(DebugReloc {
|
||||||
self.relocs.push(DebugReloc {
|
offset: self.len() as u32,
|
||||||
offset: self.len() as u32,
|
size,
|
||||||
size,
|
name: DebugRelocName::Symbol(symbol),
|
||||||
name: DebugRelocName::Symbol(symbol),
|
addend,
|
||||||
addend,
|
kind: object::RelocationKind::Relative,
|
||||||
kind: object::RelocationKind::Relative,
|
});
|
||||||
});
|
self.write_udata(0, size)
|
||||||
self.write_udata(0, size)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
_ => {
|
||||||
|
return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe));
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ impl<'tcx> UnwindContext<'tcx> {
|
||||||
|
|
||||||
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
let cie_id = if let Some(mut cie) = isa.create_systemv_cie() {
|
||||||
if isa.flags().is_pic() {
|
if isa.flags().is_pic() {
|
||||||
cie.fde_address_encoding = gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
|
cie.fde_address_encoding =
|
||||||
|
gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0);
|
||||||
}
|
}
|
||||||
Some(frame_table.add_cie(cie))
|
Some(frame_table.add_cie(cie))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc_codegen_ssa::CrateInfo;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
|
pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
|
||||||
use cranelift_simplejit::{SimpleJITModule, SimpleJITBuilder};
|
use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
15
src/trap.rs
15
src/trap.rs
|
@ -29,10 +29,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl Module>, msg: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trap code: user1
|
/// Trap code: user1
|
||||||
pub(crate) fn trap_abort(
|
pub(crate) fn trap_abort(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef<str>) {
|
||||||
fx: &mut FunctionCx<'_, '_, impl Module>,
|
|
||||||
msg: impl AsRef<str>,
|
|
||||||
) {
|
|
||||||
codegen_print(fx, msg.as_ref());
|
codegen_print(fx, msg.as_ref());
|
||||||
fx.bcx.ins().trap(TrapCode::User(1));
|
fx.bcx.ins().trap(TrapCode::User(1));
|
||||||
}
|
}
|
||||||
|
@ -41,10 +38,7 @@ pub(crate) fn trap_abort(
|
||||||
/// so you can **not** add instructions to it afterwards.
|
/// so you can **not** add instructions to it afterwards.
|
||||||
///
|
///
|
||||||
/// Trap code: user65535
|
/// Trap code: user65535
|
||||||
pub(crate) fn trap_unreachable(
|
pub(crate) fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef<str>) {
|
||||||
fx: &mut FunctionCx<'_, '_, impl Module>,
|
|
||||||
msg: impl AsRef<str>,
|
|
||||||
) {
|
|
||||||
codegen_print(fx, msg.as_ref());
|
codegen_print(fx, msg.as_ref());
|
||||||
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
|
||||||
}
|
}
|
||||||
|
@ -68,10 +62,7 @@ pub(crate) fn trap_unreachable_ret_value<'tcx>(
|
||||||
/// to it afterwards.
|
/// to it afterwards.
|
||||||
///
|
///
|
||||||
/// Trap code: user65535
|
/// Trap code: user65535
|
||||||
pub(crate) fn trap_unimplemented(
|
pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef<str>) {
|
||||||
fx: &mut FunctionCx<'_, '_, impl Module>,
|
|
||||||
msg: impl AsRef<str>,
|
|
||||||
) {
|
|
||||||
codegen_print(fx, msg.as_ref());
|
codegen_print(fx, msg.as_ref());
|
||||||
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
||||||
fx.bcx.ins().trapnz(true_, TrapCode::User(!0));
|
fx.bcx.ins().trapnz(true_, TrapCode::User(!0));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue