Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 74ae184

Browse files
authored
Merge pull request #196 from alexcrichton/merge
Easy Merge!
2 parents 48b15ca + 853f1f8 commit 74ae184

21 files changed

Lines changed: 503 additions & 449 deletions

File tree

cranelift/assembler-x64/meta/src/instructions/avg.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ pub fn list() -> Vec<Inst> {
1010
// AVX versions
1111
inst("vpavgb", fmt("B", [w(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f().op(0xE0), _64b | compat | avx),
1212
inst("vpavgw", fmt("B", [w(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f().op(0xE3), _64b | compat | avx),
13-
14-
1513
]
1614
}

cranelift/assembler-x64/meta/src/instructions/div.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::dsl::{Feature::*, Inst, Location::*, VexLength::*, align};
2-
use crate::dsl::{fmt, implicit, inst, r, rex, rw, vex};
1+
use crate::dsl::{Feature::*, Inst, Location::*, VexLength::*};
2+
use crate::dsl::{align, fmt, implicit, inst, r, rex, rw, vex};
33

44
#[rustfmt::skip] // Keeps instructions on a single line.
55
pub fn list() -> Vec<Inst> {
@@ -19,7 +19,7 @@ pub fn list() -> Vec<Inst> {
1919
inst("divsd", fmt("A", [rw(xmm1), r(xmm_m64)]), rex([0xF2, 0xF, 0x5E]).r(), _64b | compat | sse2),
2020
inst("vdivps", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._0f().op(0x5E).r(), _64b | compat | avx),
2121
inst("vdivpd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m128)]), vex(L128)._66()._0f().op(0x5E).r(), _64b | compat | avx),
22-
inst("vdivss", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m32)]), vex(L128)._f3()._0f().op(0x5E).r(), _64b | compat | avx),
23-
inst("vdivsd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m64)]), vex(L128)._f2()._0f().op(0x5E).r(), _64b | compat | avx),
22+
inst("vdivss", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m32)]), vex(LIG)._f3()._0f().op(0x5E).r(), _64b | compat | avx),
23+
inst("vdivsd", fmt("B", [rw(xmm1), r(xmm2), r(xmm_m64)]), vex(LIG)._f2()._0f().op(0x5E).r(), _64b | compat | avx),
2424
]
2525
}

cranelift/assembler-x64/meta/src/instructions/round.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ pub fn list() -> Vec<Inst> {
1414
inst("vroundps", fmt("RMI", [w(xmm1), r(xmm_m128), r(imm8)]), vex(L128)._66()._0f3a().ib().op(0x08), _64b | compat | avx),
1515
inst("vroundsd", fmt("RVMI", [w(xmm1), r(xmm2), r(xmm_m64), r(imm8)]), vex(LIG)._66()._0f3a().ib().op(0x0b), _64b | compat | avx),
1616
inst("vroundss", fmt("RVMI", [w(xmm1), r(xmm2), r(xmm_m32), r(imm8)]), vex(LIG)._66()._0f3a().ib().op(0x0a), _64b | compat | avx),
17-
18-
]
17+
]
1918
}

cranelift/codegen/src/legalizer/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ pub fn simple_legalize(func: &mut ir::Function, isa: &dyn TargetIsa) {
5555
trace!("Pre-legalization function:\n{}", func.display());
5656

5757
let mut pos = FuncCursor::new(func);
58-
let func_begin = pos.position();
59-
pos.set_position(func_begin);
6058
while let Some(_block) = pos.next_block() {
6159
let mut prev_pos = pos.position();
6260
while let Some(inst) = pos.next_inst() {

cranelift/codegen/src/opts/icmp.isle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,5 +288,5 @@
288288
(slt ty (iconcat $I64 a_lo a_hi) (iconcat $I64 b_lo b_hi)))
289289

290290

291-
(rule (simplify (eq cty x (bxor bty x y))) (subsume (eq cty y (iconst_u bty 0))))
292-
(rule (simplify (ne cty x (bxor bty x y))) (subsume (ne cty y (iconst_u bty 0))))
291+
(rule (simplify (eq cty x (bxor (ty_int bty) x y))) (subsume (eq cty y (iconst_u bty 0))))
292+
(rule (simplify (ne cty x (bxor (ty_int bty) x y))) (subsume (ne cty y (iconst_u bty 0))))

cranelift/filetests/filetests/egraph/icmp.clif

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,25 @@ block0(v0: i32, v1: i32):
201201
; v5 = icmp ne v1, v4 ; v4 = 0
202202
; return v5
203203
; }
204+
205+
function %issue_10929_no_crash_on_icmp_vectors() -> i32x4 {
206+
const0 = 0x40ad3fb47cb16076c8cb1fdd8189d40f
207+
208+
block0():
209+
v1 = vconst.i32x4 const0
210+
v2 = bxor_not v1, v1
211+
v3 = icmp.i32x4 ne v1, v2
212+
return v3
213+
}
214+
215+
; function %issue_10929_no_crash_on_icmp_vectors() -> i32x4 fast {
216+
; const0 = 0x40ad3fb47cb16076c8cb1fdd8189d40f
217+
;
218+
; block0:
219+
; v1 = vconst.i32x4 const0
220+
; v4 = bnot v1 ; v1 = const0
221+
; v2 = bxor v1, v4 ; v1 = const0
222+
; v3 = icmp ne v1, v2 ; v1 = const0
223+
; return v3
224+
; }
225+

crates/environ/src/trap_encoding.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ pub enum Trap {
9999
/// Attempt to resume a continuation twice.
100100
ContinuationAlreadyConsumed,
101101

102-
/// FIXME(frank-emrich) Only used for stack switching debugging code, to be
103-
/// removed from final upstreamed code.
104-
DeleteMeDebugAssertion,
105-
106102
/// A Pulley opcode was executed at runtime when the opcode was disabled at
107103
/// compile time.
108104
DisabledOpcode,
@@ -150,7 +146,6 @@ impl Trap {
150146
NoAsyncResult
151147
UnhandledTag
152148
ContinuationAlreadyConsumed
153-
DeleteMeDebugAssertion
154149
DisabledOpcode
155150
AsyncDeadlock
156151
}
@@ -186,7 +181,6 @@ impl fmt::Display for Trap {
186181
NoAsyncResult => "async-lifted export failed to produce a result",
187182
UnhandledTag => "unhandled tag",
188183
ContinuationAlreadyConsumed => "continuation already consumed",
189-
DeleteMeDebugAssertion => "triggered debug assertion",
190184
DisabledOpcode => "pulley opcode disabled at compile time was executed",
191185
AsyncDeadlock => "deadlock detected: event loop cannot make further progress",
192186
};

crates/wasmtime/src/runtime/component/instance.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ const _: () = {
5353

5454
impl Instance {
5555
/// Creates a raw `Instance` from the internal identifiers within the store.
56-
///
57-
/// # Safety
58-
///
59-
/// The safety of this function relies on `id` belonging to the instance
60-
/// within `store`.
61-
pub(crate) unsafe fn from_wasmtime(store: &StoreOpaque, id: ComponentInstanceId) -> Instance {
56+
pub(crate) fn from_wasmtime(store: &StoreOpaque, id: ComponentInstanceId) -> Instance {
6257
Instance {
6358
id: StoreComponentInstanceId::new(store.id(), id),
6459
}
@@ -1003,10 +998,7 @@ impl<T: 'static> InstancePre<T> {
1003998
.decrement_component_instance_count();
1004999
e
10051000
})?;
1006-
// SAFETY: `from_wasmtime` requires that `id` belongs to the store
1007-
// provided, and it was just inserted above so the condition should be
1008-
// satisfied.
1009-
let instance = unsafe { Instance::from_wasmtime(store.0, instantiator.id) };
1001+
let instance = Instance::from_wasmtime(store.0, instantiator.id);
10101002
store.0.push_component_instance(instance);
10111003
Ok(instance)
10121004
}

crates/wasmtime/src/runtime/externals/global.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl Global {
305305
match self.kind {
306306
VMGlobalKind::Instance(index) => {
307307
let instance = InstanceId::from_u32(self.instance);
308-
let module = store.instance(instance).module();
308+
let module = store.instance(instance).env_module();
309309
let index = module.global_index(index);
310310
&module.globals[index]
311311
}
@@ -363,7 +363,7 @@ impl Global {
363363
match self.kind {
364364
VMGlobalKind::Instance(index) => {
365365
let instance = InstanceId::from_u32(self.instance);
366-
store.instance(instance).instance().global_ptr(index)
366+
store.instance(instance).global_ptr(index)
367367
}
368368
VMGlobalKind::Host(index) => unsafe {
369369
NonNull::from(&mut store.host_globals()[index].get().as_mut().global)

crates/wasmtime/src/runtime/instance.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::linker::{Definition, DefinitionType};
22
use crate::prelude::*;
33
use crate::runtime::vm::{
4-
Imports, ModuleRuntimeInfo, VMFuncRef, VMFunctionImport, VMGlobalImport, VMMemoryImport,
4+
self, Imports, ModuleRuntimeInfo, VMFuncRef, VMFunctionImport, VMGlobalImport, VMMemoryImport,
55
VMOpaqueContext, VMTableImport, VMTagImport,
66
};
77
use crate::store::{AllocateInstanceKind, InstanceId, StoreInstanceId, StoreOpaque};
@@ -321,10 +321,8 @@ impl Instance {
321321
.engine()
322322
.features()
323323
.contains(WasmFeatures::BULK_MEMORY);
324-
store
325-
.instance(id)
326-
.clone()
327-
.initialize(store, compiled_module.module(), bulk_memory)?;
324+
325+
vm::initialize_instance(store, id, compiled_module.module(), bulk_memory)?;
328326

329327
Ok((instance, compiled_module.module().start_func))
330328
}
@@ -338,7 +336,7 @@ impl Instance {
338336
fn start_raw<T>(&self, store: &mut StoreContextMut<'_, T>, start: FuncIndex) -> Result<()> {
339337
// If a start function is present, invoke it. Make sure we use all the
340338
// trap-handling configuration in `store` as well.
341-
let instance = &mut store.0[self.id];
339+
let instance = self.id.get_mut(store.0);
342340
let f = instance.get_exported_func(start);
343341
let caller_vmctx = instance.vmctx();
344342
unsafe {

0 commit comments

Comments
 (0)