Update Cranelift for SimpleJIT changes

This commit is contained in:
bjorn3 2020-11-12 11:56:09 +01:00
parent 96c4542dc3
commit 6eaa502049
4 changed files with 19 additions and 18 deletions

20
Cargo.lock generated
View File

@ -50,7 +50,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cranelift-bforest"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"cranelift-entity",
]
@ -58,7 +58,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"byteorder",
"cranelift-bforest",
@ -76,7 +76,7 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity",
@ -85,17 +85,17 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
[[package]]
name = "cranelift-entity"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
[[package]]
name = "cranelift-frontend"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"cranelift-codegen",
"log",
@ -106,7 +106,7 @@ dependencies = [
[[package]]
name = "cranelift-module"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"anyhow",
"cranelift-codegen",
@ -118,7 +118,7 @@ dependencies = [
[[package]]
name = "cranelift-native"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"cranelift-codegen",
"raw-cpuid",
@ -128,7 +128,7 @@ dependencies = [
[[package]]
name = "cranelift-object"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"anyhow",
"cranelift-codegen",
@ -141,7 +141,7 @@ dependencies = [
[[package]]
name = "cranelift-simplejit"
version = "0.68.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#b326f29885ec0f530230bf550164f805ffb04e41"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#19640367dbf0da7093e61add3306c8d092644fb3"
dependencies = [
"cranelift-codegen",
"cranelift-entity",

View File

@ -76,7 +76,7 @@ impl WriterRelocate {
#[cfg(feature = "jit")]
pub(super) fn relocate_for_jit(
mut self,
jit_product: &cranelift_simplejit::SimpleJITProduct,
jit_module: &cranelift_simplejit::SimpleJITModule,
) -> Vec<u8> {
use std::convert::TryInto;
@ -84,8 +84,9 @@ impl WriterRelocate {
match reloc.name {
super::DebugRelocName::Section(_) => unreachable!(),
super::DebugRelocName::Symbol(sym) => {
let addr = jit_product
.lookup_func(cranelift_module::FuncId::from_u32(sym.try_into().unwrap()));
let addr = jit_module.get_finalized_function(
cranelift_module::FuncId::from_u32(sym.try_into().unwrap()),
);
let val = (addr as u64 as i64 + reloc.addend) as u64;
self.writer
.write_udata_at(reloc.offset as usize, val, reloc.size)

View File

@ -80,7 +80,7 @@ impl<'tcx> UnwindContext<'tcx> {
#[cfg(feature = "jit")]
pub(crate) unsafe fn register_jit(
self,
jit_product: &cranelift_simplejit::SimpleJITProduct,
jit_module: &cranelift_simplejit::SimpleJITModule,
) -> Option<UnwindRegistry> {
let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(
self.tcx,
@ -91,7 +91,7 @@ impl<'tcx> UnwindContext<'tcx> {
return None;
}
let mut eh_frame = eh_frame.0.relocate_for_jit(jit_product);
let mut eh_frame = eh_frame.0.relocate_for_jit(jit_module);
// GCC expects a terminating "empty" length, so write a 0 length at the end of the table.
eh_frame.extend(&[0, 0, 0, 0]);

View File

@ -81,11 +81,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
tcx.sess.abort_if_errors();
let jit_product = jit_module.finish();
jit_module.finalize_definitions();
let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_product) };
let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_module) };
let finalized_main: *const u8 = jit_product.lookup_func(main_func_id);
let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id);
println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed");