Skip to content

Commit 4a529fd

Browse files
committed
fix: migrate the #1003 fix to the VM v0.22
1 parent c803c42 commit 4a529fd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

codegen/masm/src/emit/mem.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ impl OpEmitter<'_> {
6969
"expected a 16-byte-aligned byte pointer for the word-copy fast path",
7070
span,
7171
),
72-
masm::Instruction::U32WrappingMulImm(4.into()),
72+
// `u32widening_mul` leaves `[lo, hi]` on the stack; assert on `hi` and keep `lo`.
73+
masm::Instruction::U32WideningMulImm(4.into()),
74+
masm::Instruction::Swap1,
7375
Self::assertz_with_message_inst(
7476
"word-copy fast path element address conversion overflowed",
7577
span,
@@ -720,6 +722,7 @@ impl OpEmitter<'_> {
720722
body_emitter.emit_all(
721723
[
722724
masm::Instruction::U32WideningMadd, // [value_size * i + dst, i, dst, count, value]
725+
masm::Instruction::Swap1,
723726
Self::assertz_with_message_inst(
724727
"memset destination address computation overflowed",
725728
span,
@@ -905,6 +908,7 @@ impl OpEmitter<'_> {
905908
masm::Instruction::Swap2,
906909
// Compute the corrected count
907910
masm::Instruction::U32WideningMulImm(factor.into()),
911+
masm::Instruction::Swap1,
908912
Self::assertz_with_message_inst(
909913
"memcpy word-copy fast path element count overflowed",
910914
span,
@@ -950,6 +954,7 @@ impl OpEmitter<'_> {
950954
body_emitter.emit_all(
951955
[
952956
masm::Instruction::U32WideningMadd,
957+
masm::Instruction::Swap1,
953958
Self::assertz_with_message_inst(
954959
"memcpy destination address computation overflowed",
955960
span,
@@ -963,6 +968,7 @@ impl OpEmitter<'_> {
963968
body_emitter.emit_all(
964969
[
965970
masm::Instruction::U32WideningMadd,
971+
masm::Instruction::Swap1,
966972
Self::assertz_with_message_inst(
967973
"memcpy source address computation overflowed",
968974
span,

0 commit comments

Comments
 (0)