From 6768d0dd72ddde27f7b297f1eec8e58b9eeaaedc Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:13:33 +0000 Subject: [PATCH 01/10] Booleans have been removed from Cranelift --- src/base.rs | 4 +--- src/intrinsics/mod.rs | 13 ++++++------- src/intrinsics/simd.rs | 5 +---- src/num.rs | 6 +----- src/optimize/peephole.rs | 20 -------------------- 5 files changed, 9 insertions(+), 39 deletions(-) diff --git a/src/base.rs b/src/base.rs index 1db44502742..41e58d34b00 100644 --- a/src/base.rs +++ b/src/base.rs @@ -388,11 +388,9 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { _ => unreachable!("{:?}", targets), }; - let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr); let (discr, is_inverted) = crate::optimize::peephole::maybe_unwrap_bool_not(&mut fx.bcx, discr); let test_zero = if is_inverted { !test_zero } else { test_zero }; - let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr); if let Some(taken) = crate::optimize::peephole::maybe_known_branch_taken( &fx.bcx, discr, test_zero, ) { @@ -569,7 +567,7 @@ fn codegen_stmt<'tcx>( UnOp::Not => match layout.ty.kind() { ty::Bool => { let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); - CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout) + CValue::by_val(res, layout) } ty::Uint(_) | ty::Int(_) => { CValue::by_val(fx.bcx.ins().bnot(val), layout) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 8f13af8154e..5c90ef8588b 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -197,7 +197,9 @@ fn bool_to_zero_or_max_uint<'tcx>( ty => ty, }; - let val = fx.bcx.ins().bint(int_ty, val); + let val = if int_ty == types::I8 { val } else { fx.bcx.ins().uextend(int_ty, val) }; + + // FIXME use bmask instead let mut res = fx.bcx.ins().ineg(val); if ty.is_float() { @@ -938,8 +940,7 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value { let old = fx.bcx.ins().atomic_cas(MemFlags::trusted(), ptr, test_old, new); let is_eq = fx.bcx.ins().icmp(IntCC::Equal, old, test_old); - let ret_val = - CValue::by_val_pair(old, fx.bcx.ins().bint(types::I8, is_eq), ret.layout()); + let ret_val = CValue::by_val_pair(old, is_eq, ret.layout()); ret.write_cvalue(fx, ret_val) } @@ -1261,8 +1262,7 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value { flags.set_notrap(); let lhs_val = fx.bcx.ins().load(clty, flags, lhs_ref, 0); let rhs_val = fx.bcx.ins().load(clty, flags, rhs_ref, 0); - let eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_val, rhs_val); - fx.bcx.ins().bint(types::I8, eq) + fx.bcx.ins().icmp(IntCC::Equal, lhs_val, rhs_val) } else { // Just call `memcmp` (like slices do in core) when the // size is too large or it's not a power-of-two. @@ -1272,8 +1272,7 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value { let returns = vec![AbiParam::new(types::I32)]; let args = &[lhs_ref, rhs_ref, bytes_val]; let cmp = fx.lib_call("memcmp", params, returns, args)[0]; - let eq = fx.bcx.ins().icmp_imm(IntCC::Equal, cmp, 0); - fx.bcx.ins().bint(types::I8, eq) + fx.bcx.ins().icmp_imm(IntCC::Equal, cmp, 0) }; ret.write_cvalue(fx, CValue::by_val(is_eq_value, ret.layout())); } diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 51fce8c854b..567c12fe316 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -112,10 +112,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( _ => unreachable!(), }; - let ty = fx.clif_type(res_lane_ty).unwrap(); - - let res_lane = fx.bcx.ins().bint(ty, res_lane); - fx.bcx.ins().ineg(res_lane) + bool_to_zero_or_max_uint(fx, res_lane_ty, res_lane) }); } diff --git a/src/num.rs b/src/num.rs index ecbab408ded..afacbec6445 100644 --- a/src/num.rs +++ b/src/num.rs @@ -49,7 +49,6 @@ fn codegen_compare_bin_op<'tcx>( ) -> CValue<'tcx> { let intcc = crate::num::bin_op_to_intcc(bin_op, signed).unwrap(); let val = fx.bcx.ins().icmp(intcc, lhs, rhs); - let val = fx.bcx.ins().bint(types::I8, val); CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)) } @@ -290,8 +289,6 @@ pub(crate) fn codegen_checked_int_binop<'tcx>( _ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs), }; - let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); - let out_layout = fx.layout_of(fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter())); CValue::by_val_pair(res, has_overflow, out_layout) } @@ -368,7 +365,6 @@ pub(crate) fn codegen_float_binop<'tcx>( _ => unreachable!(), }; let val = fx.bcx.ins().fcmp(fltcc, lhs, rhs); - let val = fx.bcx.ins().bint(types::I8, val); return CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)); } _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), @@ -440,7 +436,7 @@ pub(crate) fn codegen_ptr_binop<'tcx>( _ => panic!("bin_op {:?} on ptr", bin_op), }; - CValue::by_val(fx.bcx.ins().bint(types::I8, res), fx.layout_of(fx.tcx.types.bool)) + CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) } } diff --git a/src/optimize/peephole.rs b/src/optimize/peephole.rs index d637b4d8929..7f45bbd8f28 100644 --- a/src/optimize/peephole.rs +++ b/src/optimize/peephole.rs @@ -3,19 +3,6 @@ use cranelift_codegen::ir::{condcodes::IntCC, InstructionData, Opcode, Value, ValueDef}; use cranelift_frontend::FunctionBuilder; -/// If the given value was produced by a `bint` instruction, return it's input, otherwise return the -/// given value. -pub(crate) fn maybe_unwrap_bint(bcx: &mut FunctionBuilder<'_>, arg: Value) -> Value { - if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) { - match bcx.func.dfg[arg_inst] { - InstructionData::Unary { opcode: Opcode::Bint, arg } => arg, - _ => arg, - } - } else { - arg - } -} - /// If the given value was produced by the lowering of `Rvalue::Not` return the input and true, /// otherwise return the given value and false. pub(crate) fn maybe_unwrap_bool_not(bcx: &mut FunctionBuilder<'_>, arg: Value) -> (Value, bool) { @@ -48,13 +35,6 @@ pub(crate) fn maybe_known_branch_taken( }; match bcx.func.dfg[arg_inst] { - InstructionData::UnaryBool { opcode: Opcode::Bconst, imm } => { - if test_zero { - Some(!imm) - } else { - Some(imm) - } - } InstructionData::UnaryImm { opcode: Opcode::Iconst, imm } => { if test_zero { Some(imm.bits() == 0) From 16a2641444e16747ad87c09057d78054ce9ea63a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:18:19 +0000 Subject: [PATCH 02/10] Remove all usages of iconst.i128 Support was removed from Cranelift --- src/cast.rs | 2 +- src/common.rs | 9 +++++++++ src/discriminant.rs | 10 ++++++++-- src/intrinsics/simd.rs | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/cast.rs b/src/cast.rs index bad5d1f08a9..5091c5a9fed 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -149,7 +149,7 @@ pub(crate) fn clif_int_or_float_cast( } let is_not_nan = fx.bcx.ins().fcmp(FloatCC::Equal, from, from); - let zero = fx.bcx.ins().iconst(to_ty, 0); + let zero = type_zero_value(&mut fx.bcx, to_ty); fx.bcx.ins().select(is_not_nan, val, zero) } else if from_ty.is_float() && to_ty.is_float() { // float -> float diff --git a/src/common.rs b/src/common.rs index 6a3ab8881bb..2dcd42fbd8f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -167,6 +167,15 @@ pub(crate) fn codegen_icmp_imm( } } +pub(crate) fn type_zero_value(bcx: &mut FunctionBuilder<'_>, ty: Type) -> Value { + if ty == types::I128 { + let zero = bcx.ins().iconst(types::I64, 0); + bcx.ins().iconcat(zero, zero) + } else { + bcx.ins().iconst(ty, 0) + } +} + pub(crate) fn type_min_max_value( bcx: &mut FunctionBuilder<'_>, ty: Type, diff --git a/src/discriminant.rs b/src/discriminant.rs index b452047c760..3cbf313adf0 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -278,8 +278,14 @@ pub(crate) fn codegen_get_discriminant<'tcx>( fx.bcx.ins().iadd(tagged_discr, delta) }; - let untagged_variant = - fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32())); + let untagged_variant = if cast_to == types::I128 { + let zero = fx.bcx.ins().iconst(types::I64, 0); + let untagged_variant = + fx.bcx.ins().iconst(types::I64, i64::from(untagged_variant.as_u32())); + fx.bcx.ins().iconcat(untagged_variant, zero) + } else { + fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32())) + }; let discr = fx.bcx.ins().select(is_niche, tagged_discr, untagged_variant); let res = CValue::by_val(discr, dest_layout); dest.write_cvalue(fx, res); diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 567c12fe316..14f5e918739 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -713,7 +713,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let res_type = Type::int_with_byte_size(u16::try_from(expected_bytes).unwrap()).unwrap(); - let mut res = fx.bcx.ins().iconst(res_type, 0); + let mut res = type_zero_value(&mut fx.bcx, res_type); let lanes = match fx.tcx.sess.target.endian { Endian::Big => Box::new(0..lane_count) as Box>, From 777106a581dff9d42347cf84fc400bbde65649a9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:18:25 +0000 Subject: [PATCH 03/10] Fix warning --- src/debuginfo/unwind.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index d26392c4913..493359c743f 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -39,7 +39,9 @@ pub(crate) fn new(isa: &dyn TargetIsa, pic_eh_frame: bool) -> Self { } pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) { - let unwind_info = if let Some(unwind_info) = context.create_unwind_info(isa).unwrap() { + let unwind_info = if let Some(unwind_info) = + context.compiled_code().unwrap().create_unwind_info(isa).unwrap() + { unwind_info } else { return; From e9115eb6471661b8d29826fab4369dca9f79db52 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:20:30 +0000 Subject: [PATCH 04/10] Use git version of Cranelift --- Cargo.lock | 80 ++++++++++++++++++++++++++++++++---------------------- Cargo.toml | 12 ++++---- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6bf913e7f1d..e3298873e27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,24 +62,23 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4d6bb61f78cc312fbdebbb8a11b5aea6c16355ee682c57b89914691f3d57d0d" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f8572ccd8b99df7a8244d64feaa37f37877e47eccc245aa5e27f15dd336d7e" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "arrayvec", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-egraph", "cranelift-entity", "cranelift-isle", "gimli", @@ -91,30 +90,39 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2f284f49249a9fda931332f3feed56492651f47c330ffe1aa5a51f2b9d6b6" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6190411c55dfd88e68f506dfdbd028da0551dca40793d40811ea03cb6e0f4a" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" + +[[package]] +name = "cranelift-egraph" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown", + "indexmap", + "log", + "smallvec", +] [[package]] name = "cranelift-entity" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed8aa1104f54509dfb386520711cd8a6a0992ae42ce2df06fdebdfff4de2c2dd" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" [[package]] name = "cranelift-frontend" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d48087600d6c055f625754b1d9cc9cab36a0d26a365cbcb388825e331e0041ff" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "cranelift-codegen", "log", @@ -124,15 +132,13 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eead4df80ce3c68b913d071683790692a0316a67e3518b32e273169238876f0a" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" [[package]] name = "cranelift-jit" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d92ab547bf300966d5ef714e5575ae0437a2f8da6f92a30a3d35f9e7971ae9" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "anyhow", "cranelift-codegen", @@ -143,14 +149,14 @@ dependencies = [ "log", "region", "target-lexicon", + "wasmtime-jit-icache-coherence", "windows-sys", ] [[package]] name = "cranelift-module" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecae6c04ac78161c9380e4953ff5d56e44fe78e1e32a3d7e816bf2e9246283f" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "anyhow", "cranelift-codegen", @@ -158,9 +164,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3adde571ff9c6a77320b69ac03920c5ce70fed94f5f9ac53f5c0600a69fc142e" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "cranelift-codegen", "libc", @@ -169,9 +174,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.89.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb602999187ba96b81822fe48dbd544ecc36179741c0bc2dd6602e3ee0c5ead" +version = "0.90.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" dependencies = [ "anyhow", "cranelift-codegen", @@ -384,6 +388,16 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "2.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +dependencies = [ + "cfg-if", + "libc", + "windows-sys", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 1a97feb70b7..9f4a7e4f048 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,12 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { version = "0.89.1", features = ["unwind", "all-arch"] } -cranelift-frontend = "0.89.1" -cranelift-module = "0.89.1" -cranelift-native = "0.89.1" -cranelift-jit = { version = "0.89.1", optional = true } -cranelift-object = "0.89.1" +cranelift-codegen = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", features = ["unwind", "all-arch"] } +cranelift-frontend = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } +cranelift-module = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } +cranelift-native = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } +cranelift-jit = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", optional = true } +cranelift-object = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } target-lexicon = "0.12.0" gimli = { version = "0.26.0", default-features = false, features = ["write"]} object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } From ae98a2f570721601c0804f9996dbdf267ca9f193 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 2 Nov 2022 15:03:43 +0000 Subject: [PATCH 05/10] Simplify some code based on newly implemented instructions --- Cargo.lock | 30 +++++++------- src/base.rs | 6 --- src/intrinsics/mod.rs | 93 ++++++------------------------------------- 3 files changed, 28 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e3298873e27..540ba1ca79a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "cranelift-entity", ] @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "arrayvec", "bumpalo", @@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "cranelift-codegen-shared", ] @@ -99,12 +99,12 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" [[package]] name = "cranelift-egraph" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "cranelift-entity", "fxhash", @@ -117,12 +117,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" [[package]] name = "cranelift-frontend" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "cranelift-codegen", "log", @@ -133,12 +133,12 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" [[package]] name = "cranelift-jit" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "anyhow", "cranelift-codegen", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "anyhow", "cranelift-codegen", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "cranelift-codegen", "libc", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "anyhow", "cranelift-codegen", @@ -310,9 +310,9 @@ checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "regalloc2" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69025b4a161879ba90719837c06621c3d73cffa147a000aeacf458f6a9572485" +checksum = "91b2eab54204ea0117fe9a060537e0b07a4e72f7c7d182361ecc346cab2240e5" dependencies = [ "fxhash", "log", @@ -391,7 +391,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasmtime-jit-icache-coherence" version = "2.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#e8f3d03bbe17151530601bac82af912869f09080" +source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" dependencies = [ "cfg-if", "libc", diff --git a/src/base.rs b/src/base.rs index 41e58d34b00..12a15fbaee6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -575,12 +575,6 @@ fn codegen_stmt<'tcx>( _ => unreachable!("un op Not for {:?}", layout.ty), }, UnOp::Neg => match layout.ty.kind() { - ty::Int(IntTy::I128) => { - // FIXME remove this case once ineg.i128 works - let zero = - CValue::const_val(fx, layout, ty::ScalarInt::null(layout.size)); - crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand) - } ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout), ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout), _ => unreachable!("un op Neg for {:?}", layout.ty), diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 5c90ef8588b..76fc399097a 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -197,10 +197,7 @@ fn bool_to_zero_or_max_uint<'tcx>( ty => ty, }; - let val = if int_ty == types::I8 { val } else { fx.bcx.ins().uextend(int_ty, val) }; - - // FIXME use bmask instead - let mut res = fx.bcx.ins().ineg(val); + let mut res = fx.bcx.ins().bmask(int_ty, val); if ty.is_float() { res = fx.bcx.ins().bitcast(ty, res); @@ -636,85 +633,21 @@ fn codegen_regular_intrinsic_call<'tcx>( ret.write_cvalue(fx, res); } sym::bswap => { - // FIXME(CraneStation/cranelift#794) add bswap instruction to cranelift - fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value { - match bcx.func.dfg.value_type(v) { - types::I8 => v, - - // https://code.woboq.org/gcc/include/bits/byteswap.h.html - types::I16 => { - let tmp1 = bcx.ins().ishl_imm(v, 8); - let n1 = bcx.ins().band_imm(tmp1, 0xFF00); - - let tmp2 = bcx.ins().ushr_imm(v, 8); - let n2 = bcx.ins().band_imm(tmp2, 0x00FF); - - bcx.ins().bor(n1, n2) - } - types::I32 => { - let tmp1 = bcx.ins().ishl_imm(v, 24); - let n1 = bcx.ins().band_imm(tmp1, 0xFF00_0000); - - let tmp2 = bcx.ins().ishl_imm(v, 8); - let n2 = bcx.ins().band_imm(tmp2, 0x00FF_0000); - - let tmp3 = bcx.ins().ushr_imm(v, 8); - let n3 = bcx.ins().band_imm(tmp3, 0x0000_FF00); - - let tmp4 = bcx.ins().ushr_imm(v, 24); - let n4 = bcx.ins().band_imm(tmp4, 0x0000_00FF); - - let or_tmp1 = bcx.ins().bor(n1, n2); - let or_tmp2 = bcx.ins().bor(n3, n4); - bcx.ins().bor(or_tmp1, or_tmp2) - } - types::I64 => { - let tmp1 = bcx.ins().ishl_imm(v, 56); - let n1 = bcx.ins().band_imm(tmp1, 0xFF00_0000_0000_0000u64 as i64); - - let tmp2 = bcx.ins().ishl_imm(v, 40); - let n2 = bcx.ins().band_imm(tmp2, 0x00FF_0000_0000_0000u64 as i64); - - let tmp3 = bcx.ins().ishl_imm(v, 24); - let n3 = bcx.ins().band_imm(tmp3, 0x0000_FF00_0000_0000u64 as i64); - - let tmp4 = bcx.ins().ishl_imm(v, 8); - let n4 = bcx.ins().band_imm(tmp4, 0x0000_00FF_0000_0000u64 as i64); - - let tmp5 = bcx.ins().ushr_imm(v, 8); - let n5 = bcx.ins().band_imm(tmp5, 0x0000_0000_FF00_0000u64 as i64); - - let tmp6 = bcx.ins().ushr_imm(v, 24); - let n6 = bcx.ins().band_imm(tmp6, 0x0000_0000_00FF_0000u64 as i64); - - let tmp7 = bcx.ins().ushr_imm(v, 40); - let n7 = bcx.ins().band_imm(tmp7, 0x0000_0000_0000_FF00u64 as i64); - - let tmp8 = bcx.ins().ushr_imm(v, 56); - let n8 = bcx.ins().band_imm(tmp8, 0x0000_0000_0000_00FFu64 as i64); - - let or_tmp1 = bcx.ins().bor(n1, n2); - let or_tmp2 = bcx.ins().bor(n3, n4); - let or_tmp3 = bcx.ins().bor(n5, n6); - let or_tmp4 = bcx.ins().bor(n7, n8); - - let or_tmp5 = bcx.ins().bor(or_tmp1, or_tmp2); - let or_tmp6 = bcx.ins().bor(or_tmp3, or_tmp4); - bcx.ins().bor(or_tmp5, or_tmp6) - } - types::I128 => { - let (lo, hi) = bcx.ins().isplit(v); - let lo = swap(bcx, lo); - let hi = swap(bcx, hi); - bcx.ins().iconcat(hi, lo) - } - ty => unreachable!("bswap {}", ty), - } - } intrinsic_args!(fx, args => (arg); intrinsic); let val = arg.load_scalar(fx); - let res = CValue::by_val(swap(&mut fx.bcx, val), arg.layout()); + let res = match fx.bcx.func.dfg.value_type(val) { + types::I8 => val, + types::I128 => { + // FIXME(bytecodealliance/wasmtime#1092) bswap.i128 is not yet implemented + let (lsb, msb) = fx.bcx.ins().isplit(val); + let lsb_swap = fx.bcx.ins().bswap(lsb); + let msb_swap = fx.bcx.ins().bswap(msb); + fx.bcx.ins().iconcat(msb_swap, lsb_swap) + } + _ => fx.bcx.ins().bswap(val), + }; + let res = CValue::by_val(res, arg.layout()); ret.write_cvalue(fx, res); } sym::assert_inhabited | sym::assert_zero_valid | sym::assert_uninit_valid => { From 83dc7d1a123d2b2e0b0b84aa3d0ae6dc4a59fd4e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:10:12 +0000 Subject: [PATCH 06/10] Fix for removal of raw_bitcast --- Cargo.lock | 26 +++++++++++++------------- src/value_and_place.rs | 4 +--- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 540ba1ca79a..61e091bfe84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "cranelift-entity", ] @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "arrayvec", "bumpalo", @@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "cranelift-codegen-shared", ] @@ -99,12 +99,12 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" [[package]] name = "cranelift-egraph" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "cranelift-entity", "fxhash", @@ -117,12 +117,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" [[package]] name = "cranelift-frontend" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "cranelift-codegen", "log", @@ -133,12 +133,12 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" [[package]] name = "cranelift-jit" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "anyhow", "cranelift-codegen", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "anyhow", "cranelift-codegen", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "cranelift-codegen", "libc", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "anyhow", "cranelift-codegen", @@ -391,7 +391,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasmtime-jit-icache-coherence" version = "2.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#033758daaf3e7f0af4348e0d996f26de5c6ba4fc" +source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" dependencies = [ "cfg-if", "libc", diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 58a6508de7a..da712808c94 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -515,9 +515,7 @@ fn transmute_value<'tcx>( | (types::F32, types::I32) | (types::I64, types::F64) | (types::F64, types::I64) => fx.bcx.ins().bitcast(dst_ty, data), - _ if src_ty.is_vector() && dst_ty.is_vector() => { - fx.bcx.ins().raw_bitcast(dst_ty, data) - } + _ if src_ty.is_vector() && dst_ty.is_vector() => fx.bcx.ins().bitcast(dst_ty, data), _ if src_ty.is_vector() || dst_ty.is_vector() => { // FIXME do something more efficient for transmutes between vectors and integers. let stack_slot = fx.bcx.create_sized_stack_slot(StackSlotData { From 3df425e11e4cef5f9c4c08cd545db2bffdbb97bd Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:10:28 +0000 Subject: [PATCH 07/10] bswap.i128 is now supported --- src/intrinsics/mod.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 76fc399097a..7a380acf798 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -636,16 +636,10 @@ fn codegen_regular_intrinsic_call<'tcx>( intrinsic_args!(fx, args => (arg); intrinsic); let val = arg.load_scalar(fx); - let res = match fx.bcx.func.dfg.value_type(val) { - types::I8 => val, - types::I128 => { - // FIXME(bytecodealliance/wasmtime#1092) bswap.i128 is not yet implemented - let (lsb, msb) = fx.bcx.ins().isplit(val); - let lsb_swap = fx.bcx.ins().bswap(lsb); - let msb_swap = fx.bcx.ins().bswap(msb); - fx.bcx.ins().iconcat(msb_swap, lsb_swap) - } - _ => fx.bcx.ins().bswap(val), + let res = if fx.bcx.func.dfg.value_type(val) == types::I8 { + val + } else { + fx.bcx.ins().bswap(val) }; let res = CValue::by_val(res, arg.layout()); ret.write_cvalue(fx, res); From 155f5697949d21d5658115808d982aec01fbb649 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 10 Nov 2022 10:47:43 +0000 Subject: [PATCH 08/10] Update cranelift to the upcoming release-3.0.0 branch --- Cargo.lock | 26 +++++++++++++------------- Cargo.toml | 12 ++++++------ src/driver/jit.rs | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61e091bfe84..73d07648c3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "cranelift-entity", ] @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "arrayvec", "bumpalo", @@ -91,7 +91,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "cranelift-codegen-shared", ] @@ -99,12 +99,12 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" [[package]] name = "cranelift-egraph" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "cranelift-entity", "fxhash", @@ -117,12 +117,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" [[package]] name = "cranelift-frontend" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "cranelift-codegen", "log", @@ -133,12 +133,12 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" [[package]] name = "cranelift-jit" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "anyhow", "cranelift-codegen", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "anyhow", "cranelift-codegen", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "cranelift-codegen", "libc", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "anyhow", "cranelift-codegen", @@ -391,7 +391,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasmtime-jit-icache-coherence" version = "2.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git#2c69b94744c93247075ed1c6754b4cb5549cd90d" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" dependencies = [ "cfg-if", "libc", diff --git a/Cargo.toml b/Cargo.toml index 9f4a7e4f048..16c1636f9c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,12 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", features = ["unwind", "all-arch"] } -cranelift-frontend = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } -cranelift-module = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } -cranelift-native = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } -cranelift-jit = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", optional = true } -cranelift-object = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git" } +cranelift-codegen = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0", features = ["unwind", "all-arch"] } +cranelift-frontend = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } +cranelift-module = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } +cranelift-native = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } +cranelift-jit = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0", optional = true } +cranelift-object = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } target-lexicon = "0.12.0" gimli = { version = "0.26.0", default-features = false, features = ["write"]} object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 6a430b5215e..1dcb8025183 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -159,7 +159,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! { tcx.sess.abort_if_errors(); - jit_module.finalize_definitions(); + jit_module.finalize_definitions().unwrap(); unsafe { cx.unwind_context.register_jit(&jit_module) }; println!( @@ -278,7 +278,7 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) -> }); assert!(cx.global_asm.is_empty()); - jit_module.finalize_definitions(); + jit_module.finalize_definitions().unwrap(); unsafe { cx.unwind_context.register_jit(&jit_module) }; jit_module.get_finalized_function(func_id) }) From 202bdc1ceb7190b13e333737f696b519f2ba0550 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 21 Nov 2022 19:11:18 +0000 Subject: [PATCH 09/10] Update Cranelift to 0.90.0 --- Cargo.lock | 39 ++++++++++++++++++++++++++------------- Cargo.toml | 12 ++++++------ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73d07648c3a..11c1fda9812 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,8 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c200df7d943cd2b8cb3a67f6a56781c63849f122d74deff24d1767c3918b0bdc" dependencies = [ "cranelift-entity", ] @@ -71,7 +72,8 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f365623f4c3d576f47f11868568d0c90e18ac169497a9ed73c433fe2d3f9f2fb" dependencies = [ "arrayvec", "bumpalo", @@ -91,7 +93,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbaf79f8ae63bd86dc40a04417a7cc1691a217f6db204438026c164679b4694" dependencies = [ "cranelift-codegen-shared", ] @@ -99,12 +102,14 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "587db55845c943d8211e9c7198a977fa6686b44f18df15f31cec9a12fcf5dda8" [[package]] name = "cranelift-egraph" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6dccc0b16b7b8c1278162e436beebb35f3d321743b639d2b578138d630f43e" dependencies = [ "cranelift-entity", "fxhash", @@ -117,12 +122,14 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1b062935d2c6dba87387d2ac163eb9c54967ed6143c3136fffaba8acb5eaa9e" [[package]] name = "cranelift-frontend" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476ea81fe736b858d2d2c53b9d9fd28082589f57ebe4e1654a68af7359800a0c" dependencies = [ "cranelift-codegen", "log", @@ -133,12 +140,14 @@ dependencies = [ [[package]] name = "cranelift-isle" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c50a465703c15d3d913f6b0db8320c4e92c940f0f0cad874c7fcf5aecc066c0" [[package]] name = "cranelift-jit" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7178efab39f6c39e152ad8c6250d6010a296fd6232a77e4d8e3288b75732af7d" dependencies = [ "anyhow", "cranelift-codegen", @@ -156,7 +165,8 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb622cbbe26af304c8598599f3e3dbb6a8e88a0af0f8e9506e068daa7a8b01a6" dependencies = [ "anyhow", "cranelift-codegen", @@ -165,7 +175,8 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d9e0d1382584b8d454ec12c86fd562b64ccd454c1199846c1b7d158db9ed38" dependencies = [ "cranelift-codegen", "libc", @@ -175,7 +186,8 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.90.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d885261f93086c39882238862dcee007993738a01fb51a3532cf5db0f55d54" dependencies = [ "anyhow", "cranelift-codegen", @@ -391,7 +403,8 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasmtime-jit-icache-coherence" version = "2.0.0" -source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-3.0.0#0102cd7bc0c9a178a8a492340961f5822f9b95c8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb7b3e58024d8d395dfc4efbe2a58360a1998565b118b0342b3cf62a4084bde" dependencies = [ "cfg-if", "libc", diff --git a/Cargo.toml b/Cargo.toml index 16c1636f9c5..6e5bfca6715 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,12 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0", features = ["unwind", "all-arch"] } -cranelift-frontend = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } -cranelift-module = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } -cranelift-native = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } -cranelift-jit = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0", optional = true } -cranelift-object = { version = "0.90", git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-3.0.0" } +cranelift-codegen = { version = "0.90", features = ["unwind", "all-arch"] } +cranelift-frontend = "0.90" +cranelift-module = "0.90" +cranelift-native = "0.90" +cranelift-jit = { version = "0.90", optional = true } +cranelift-object = "0.90" target-lexicon = "0.12.0" gimli = { version = "0.26.0", default-features = false, features = ["write"]} object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } From a54a3775c90f3f5f7a13e64809a01fb3364e8d4a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 1 Dec 2022 17:46:48 +0000 Subject: [PATCH 10/10] Update Cranelift to 0.90.1 This fixes building on FreeBSD --- Cargo.lock | 52 ++++++++++++++++++++++++++-------------------------- Cargo.toml | 12 ++++++------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11c1fda9812..de5d166b8ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,18 +62,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c200df7d943cd2b8cb3a67f6a56781c63849f122d74deff24d1767c3918b0bdc" +checksum = "b62c772976416112fa4484cbd688cb6fb35fd430005c1c586224fc014018abad" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f365623f4c3d576f47f11868568d0c90e18ac169497a9ed73c433fe2d3f9f2fb" +checksum = "9b40ed2dd13c2ac7e24f88a3090c68ad3414eb1d066a95f8f1f7b3b819cb4e46" dependencies = [ "arrayvec", "bumpalo", @@ -92,24 +92,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbaf79f8ae63bd86dc40a04417a7cc1691a217f6db204438026c164679b4694" +checksum = "bb927a8f1c27c34ee3759b6b0ffa528d2330405d5cc4511f0cab33fe2279f4b5" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "587db55845c943d8211e9c7198a977fa6686b44f18df15f31cec9a12fcf5dda8" +checksum = "43dfa417b884a9ab488d95fd6b93b25e959321fe7bfd7a0a960ba5d7fb7ab927" [[package]] name = "cranelift-egraph" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6dccc0b16b7b8c1278162e436beebb35f3d321743b639d2b578138d630f43e" +checksum = "e0a66b39785efd8513d2cca967ede56d6cc57c8d7986a595c7c47d0c78de8dce" dependencies = [ "cranelift-entity", "fxhash", @@ -121,15 +121,15 @@ dependencies = [ [[package]] name = "cranelift-entity" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b062935d2c6dba87387d2ac163eb9c54967ed6143c3136fffaba8acb5eaa9e" +checksum = "0637ffde963cb5d759bc4d454cfa364b6509e6c74cdaa21298add0ed9276f346" [[package]] name = "cranelift-frontend" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "476ea81fe736b858d2d2c53b9d9fd28082589f57ebe4e1654a68af7359800a0c" +checksum = "fb72b8342685e850cb037350418f62cc4fc55d6c2eb9c7ca01b82f9f1a6f3d56" dependencies = [ "cranelift-codegen", "log", @@ -139,15 +139,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c50a465703c15d3d913f6b0db8320c4e92c940f0f0cad874c7fcf5aecc066c0" +checksum = "850579cb9e4b448f7c301f1e6e6cbad99abe3f1f1d878a4994cb66e33c6db8cd" [[package]] name = "cranelift-jit" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7178efab39f6c39e152ad8c6250d6010a296fd6232a77e4d8e3288b75732af7d" +checksum = "9add822ad66dcbe152b5ab57de10240a2df4505099f2f6c27159acb711890bd4" dependencies = [ "anyhow", "cranelift-codegen", @@ -164,9 +164,9 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb622cbbe26af304c8598599f3e3dbb6a8e88a0af0f8e9506e068daa7a8b01a6" +checksum = "406b772626fc2664864cf947f3895a23b619895c7fff635f3622e2d857f4492f" dependencies = [ "anyhow", "cranelift-codegen", @@ -174,9 +174,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d9e0d1382584b8d454ec12c86fd562b64ccd454c1199846c1b7d158db9ed38" +checksum = "2d0a279e5bcba3e0466c734d8d8eb6bfc1ad29e95c37f3e4955b492b5616335e" dependencies = [ "cranelift-codegen", "libc", @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.90.0" +version = "0.90.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10d885261f93086c39882238862dcee007993738a01fb51a3532cf5db0f55d54" +checksum = "39793c550f0c1d7db96c2fc1324583670c8143befe6edbfbaf1c68aba53be983" dependencies = [ "anyhow", "cranelift-codegen", @@ -402,9 +402,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasmtime-jit-icache-coherence" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb7b3e58024d8d395dfc4efbe2a58360a1998565b118b0342b3cf62a4084bde" +checksum = "e6bbabb309c06cc238ee91b1455b748c45f0bdcab0dda2c2db85b0a1e69fcb66" dependencies = [ "cfg-if", "libc", diff --git a/Cargo.toml b/Cargo.toml index 6e5bfca6715..a9ad5a5d383 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,12 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { version = "0.90", features = ["unwind", "all-arch"] } -cranelift-frontend = "0.90" -cranelift-module = "0.90" -cranelift-native = "0.90" -cranelift-jit = { version = "0.90", optional = true } -cranelift-object = "0.90" +cranelift-codegen = { version = "0.90.1", features = ["unwind", "all-arch"] } +cranelift-frontend = "0.90.1" +cranelift-module = "0.90.1" +cranelift-native = "0.90.1" +cranelift-jit = { version = "0.90.1", optional = true } +cranelift-object = "0.90.1" target-lexicon = "0.12.0" gimli = { version = "0.26.0", default-features = false, features = ["write"]} object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }