Skip to content

Truly independent web browser

LibJS: Remove the fused move instructions

Andreas Klingfba9c37598fe
diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S
index 513cc0c3b59..1138b863e92 100644
--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S
+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/aarch64.S
@@ -197,11 +197,7 @@ asm_dispatch_table:
.quad asm_handler_ResolveThisBinding
.quad asm_handler_GetPrivateById
.quad asm_handler_PutPrivateById
- .quad asm_handler_Mov2
- .quad asm_handler_Mov3
.quad asm_handler_MovSrcUndefined
- .quad asm_handler_MovUndefined2
- .quad asm_handler_MovUndefined3
.quad asm_handler_AddLhsInt32
.quad asm_handler_AddRhsInt32
.quad asm_handler_SubRhsInt32
@@ -269,6 +265,10 @@ asm_dispatch_table:
.quad asm_handler_fallback
.quad asm_handler_fallback
.quad asm_handler_fallback
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback
.globl CSYM(js_interpreter_debug_dispatch_table)
CSYM(js_interpreter_debug_dispatch_table):
@@ -1269,26 +1269,10 @@ CSYM(js_interpreter_handler_ranges):
.quad asm_handler_PutPrivateById_hot_end
.quad asm_handler_PutPrivateById_cold
.quad asm_handler_PutPrivateById_cold_end
- .quad asm_handler_Mov2
- .quad asm_handler_Mov2_hot_end
- .quad asm_handler_Mov2_cold
- .quad asm_handler_Mov2_cold_end
- .quad asm_handler_Mov3
- .quad asm_handler_Mov3_hot_end
- .quad asm_handler_Mov3_cold
- .quad asm_handler_Mov3_cold_end
.quad asm_handler_MovSrcUndefined
.quad asm_handler_MovSrcUndefined_hot_end
.quad asm_handler_MovSrcUndefined_cold
.quad asm_handler_MovSrcUndefined_cold_end
- .quad asm_handler_MovUndefined2
- .quad asm_handler_MovUndefined2_hot_end
- .quad asm_handler_MovUndefined2_cold
- .quad asm_handler_MovUndefined2_cold_end
- .quad asm_handler_MovUndefined3
- .quad asm_handler_MovUndefined3_hot_end
- .quad asm_handler_MovUndefined3_cold
- .quad asm_handler_MovUndefined3_cold_end
.quad asm_handler_AddLhsInt32
.quad asm_handler_AddLhsInt32_hot_end
.quad asm_handler_AddLhsInt32_cold
@@ -1557,6 +1541,22 @@ CSYM(js_interpreter_handler_ranges):
.quad asm_handler_fallback_hot_end
.quad asm_handler_fallback_cold
.quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
.text
@@ -6633,37 +6633,6 @@ asm_handler_ResolveThisBinding:
br x10
asm_handler_ResolveThisBinding_hot_end:
-.p2align 4
-asm_handler_Mov2:
- ldp w0, w1, [x21, #4]
- ldr x1, [x27, x1, lsl #3]
- str x1, [x27, x0, lsl #3]
- ldp w0, w1, [x21, #12]
- ldr x1, [x27, x1, lsl #3]
- str x1, [x27, x0, lsl #3]
- ldrb w9, [x21, #24]
- add x21, x21, #24
- ldr x10, [x19, x9, lsl #3]
- br x10
-asm_handler_Mov2_hot_end:
-
-.p2align 4
-asm_handler_Mov3:
- ldp w0, w1, [x21, #4]
- ldr x1, [x27, x1, lsl #3]
- str x1, [x27, x0, lsl #3]
- ldp w0, w1, [x21, #12]
- ldr x1, [x27, x1, lsl #3]
- str x1, [x27, x0, lsl #3]
- ldp w0, w1, [x21, #20]
- ldr x1, [x27, x1, lsl #3]
- str x1, [x27, x0, lsl #3]
- ldrb w9, [x21, #32]
- add x21, x21, #32
- ldr x10, [x19, x9, lsl #3]
- br x10
-asm_handler_Mov3_hot_end:
-
.p2align 4
asm_handler_MovSrcUndefined:
ldr w9, [x21, #4]
@@ -6675,37 +6644,6 @@ asm_handler_MovSrcUndefined:
br x10
asm_handler_MovSrcUndefined_hot_end:
-.p2align 4
-asm_handler_MovUndefined2:
- ldr w9, [x21, #4]
- movz x10, #0x7ffe, lsl #48
- str x10, [x27, x9, lsl #3]
- ldr w9, [x21, #8]
- movz x10, #0x7ffe, lsl #48
- str x10, [x27, x9, lsl #3]
- ldrb w9, [x21, #16]
- add x21, x21, #16
- ldr x10, [x19, x9, lsl #3]
- br x10
-asm_handler_MovUndefined2_hot_end:
-
-.p2align 4
-asm_handler_MovUndefined3:
- ldr w9, [x21, #4]
- movz x10, #0x7ffe, lsl #48
- str x10, [x27, x9, lsl #3]
- ldr w9, [x21, #8]
- movz x10, #0x7ffe, lsl #48
- str x10, [x27, x9, lsl #3]
- ldr w9, [x21, #12]
- movz x10, #0x7ffe, lsl #48
- str x10, [x27, x9, lsl #3]
- ldrb w9, [x21, #16]
- add x21, x21, #16
- ldr x10, [x19, x9, lsl #3]
- br x10
-asm_handler_MovUndefined3_hot_end:
-
.p2align 4
asm_handler_AddLhsInt32:
ldr w2, [x21, #8]
@@ -18146,16 +18084,8 @@ asm_handler_PutPrivateById_hot_end:
asm_handler_PutPrivateById_cold:
asm_handler_PutPrivateById_cold_end:
-asm_handler_Mov2_cold:
-asm_handler_Mov2_cold_end:
-asm_handler_Mov3_cold:
-asm_handler_Mov3_cold_end:
asm_handler_MovSrcUndefined_cold:
asm_handler_MovSrcUndefined_cold_end:
-asm_handler_MovUndefined2_cold:
-asm_handler_MovUndefined2_cold_end:
-asm_handler_MovUndefined3_cold:
-asm_handler_MovUndefined3_cold_end:
asm_handler_AddLhsInt32_cold:
// Cold paths for AddLhsInt32
.Lasm_AddLhsInt32.ssa_block_6:
diff --git a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S
index 5085c2135fb..b94589afcf9 100644
--- a/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S
+++ b/Libraries/LibJS/Flap/tests/interpreter-assembly/x86_64.S
@@ -198,11 +198,7 @@ asm_dispatch_table:
.quad asm_handler_ResolveThisBinding
.quad asm_handler_GetPrivateById
.quad asm_handler_PutPrivateById
- .quad asm_handler_Mov2
- .quad asm_handler_Mov3
.quad asm_handler_MovSrcUndefined
- .quad asm_handler_MovUndefined2
- .quad asm_handler_MovUndefined3
.quad asm_handler_AddLhsInt32
.quad asm_handler_AddRhsInt32
.quad asm_handler_SubRhsInt32
@@ -270,6 +266,10 @@ asm_dispatch_table:
.quad asm_handler_fallback
.quad asm_handler_fallback
.quad asm_handler_fallback
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback
.globl CSYM(js_interpreter_debug_dispatch_table)
CSYM(js_interpreter_debug_dispatch_table):
@@ -1270,26 +1270,10 @@ CSYM(js_interpreter_handler_ranges):
.quad asm_handler_PutPrivateById_hot_end
.quad asm_handler_PutPrivateById_cold
.quad asm_handler_PutPrivateById_cold_end
- .quad asm_handler_Mov2
- .quad asm_handler_Mov2_hot_end
- .quad asm_handler_Mov2_cold
- .quad asm_handler_Mov2_cold_end
- .quad asm_handler_Mov3
- .quad asm_handler_Mov3_hot_end
- .quad asm_handler_Mov3_cold
- .quad asm_handler_Mov3_cold_end
.quad asm_handler_MovSrcUndefined
.quad asm_handler_MovSrcUndefined_hot_end
.quad asm_handler_MovSrcUndefined_cold
.quad asm_handler_MovSrcUndefined_cold_end
- .quad asm_handler_MovUndefined2
- .quad asm_handler_MovUndefined2_hot_end
- .quad asm_handler_MovUndefined2_cold
- .quad asm_handler_MovUndefined2_cold_end
- .quad asm_handler_MovUndefined3
- .quad asm_handler_MovUndefined3_hot_end
- .quad asm_handler_MovUndefined3_cold
- .quad asm_handler_MovUndefined3_cold_end
.quad asm_handler_AddLhsInt32
.quad asm_handler_AddLhsInt32_hot_end
.quad asm_handler_AddLhsInt32_cold
@@ -1558,6 +1542,22 @@ CSYM(js_interpreter_handler_ranges):
.quad asm_handler_fallback_hot_end
.quad asm_handler_fallback_cold
.quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
+ .quad asm_handler_fallback
+ .quad asm_handler_fallback_hot_end
+ .quad asm_handler_fallback_cold
+ .quad asm_handler_fallback_cold_end
.text
@@ -6760,40 +6760,6 @@ asm_handler_ResolveThisBinding:
jmp [r12 + rax * 8]
asm_handler_ResolveThisBinding_hot_end:
-.p2align 6
-asm_handler_Mov2:
- mov eax, DWORD PTR [r14 + r13 + 4]
- mov ecx, DWORD PTR [r14 + r13 + 8]
- mov rcx, QWORD PTR [rbx + rcx * 8]
- mov QWORD PTR [rbx + rax * 8], rcx
- mov eax, DWORD PTR [r14 + r13 + 12]
- mov ecx, DWORD PTR [r14 + r13 + 16]
- mov rcx, QWORD PTR [rbx + rcx * 8]
- mov QWORD PTR [rbx + rax * 8], rcx
- add r13d, 24
- movzx eax, BYTE PTR [r14 + r13]
- jmp [r12 + rax * 8]
-asm_handler_Mov2_hot_end:
-
-.p2align 6
-asm_handler_Mov3:
- mov eax, DWORD PTR [r14 + r13 + 4]
- mov ecx, DWORD PTR [r14 + r13 + 8]
- mov rcx, QWORD PTR [rbx + rcx * 8]
- mov QWORD PTR [rbx + rax * 8], rcx
- mov eax, DWORD PTR [r14 + r13 + 12]
- mov ecx, DWORD PTR [r14 + r13 + 16]
- mov rcx, QWORD PTR [rbx + rcx * 8]
- mov QWORD PTR [rbx + rax * 8], rcx
- mov eax, DWORD PTR [r14 + r13 + 20]
- mov ecx, DWORD PTR [r14 + r13 + 24]
- mov rcx, QWORD PTR [rbx + rcx * 8]
- mov QWORD PTR [rbx + rax * 8], rcx
- add r13d, 32
- movzx eax, BYTE PTR [r14 + r13]
- jmp [r12 + rax * 8]
-asm_handler_Mov3_hot_end:
-
.p2align 6
asm_handler_MovSrcUndefined:
movabs r11, 9222809086901354496
@@ -6804,35 +6770,6 @@ asm_handler_MovSrcUndefined:
jmp [r12 + rax * 8]
asm_handler_MovSrcUndefined_hot_end:
-.p2align 6
-asm_handler_MovUndefined2:
- movabs r11, 9222809086901354496
- mov eax, DWORD PTR [r14 + r13 + 4]
- mov QWORD PTR [rbx + rax * 8], r11
- movabs r11, 9222809086901354496
- mov eax, DWORD PTR [r14 + r13 + 8]
- mov QWORD PTR [rbx + rax * 8], r11
- add r13d, 16
- movzx eax, BYTE PTR [r14 + r13]
- jmp [r12 + rax * 8]
-asm_handler_MovUndefined2_hot_end:
-
-.p2align 6
-asm_handler_MovUndefined3:
- movabs r11, 9222809086901354496
- mov eax, DWORD PTR [r14 + r13 + 4]
- mov QWORD PTR [rbx + rax * 8], r11
- movabs r11, 9222809086901354496
- mov eax, DWORD PTR [r14 + r13 + 8]
- mov QWORD PTR [rbx + rax * 8], r11
- movabs r11, 9222809086901354496
- mov eax, DWORD PTR [r14 + r13 + 12]
- mov QWORD PTR [rbx + rax * 8], r11
- add r13d, 16
- movzx eax, BYTE PTR [r14 + r13]
- jmp [r12 + rax * 8]
-asm_handler_MovUndefined3_hot_end:
-
.p2align 6
asm_handler_AddLhsInt32:
mov edx, DWORD PTR [r14 + r13 + 8]
@@ -17729,16 +17666,8 @@ asm_handler_PutPrivateById_hot_end:
asm_handler_PutPrivateById_cold:
asm_handler_PutPrivateById_cold_end:
-asm_handler_Mov2_cold:
-asm_handler_Mov2_cold_end:
-asm_handler_Mov3_cold:
-asm_handler_Mov3_cold_end:
asm_handler_MovSrcUndefined_cold:
asm_handler_MovSrcUndefined_cold_end:
-asm_handler_MovUndefined2_cold:
-asm_handler_MovUndefined2_cold_end:
-asm_handler_MovUndefined3_cold:
-asm_handler_MovUndefined3_cold_end:
asm_handler_AddLhsInt32_cold:
# Cold paths for AddLhsInt32
.Lasm_AddLhsInt32.ssa_block_6:
diff --git a/Libraries/LibJS/Interpreter/interpreter.flap b/Libraries/LibJS/Interpreter/interpreter.flap
index 8bc6b8a9d44..67fb663bf8a 100644
--- a/Libraries/LibJS/Interpreter/interpreter.flap
+++ b/Libraries/LibJS/Interpreter/interpreter.flap
@@ -1271,11 +1271,7 @@ handler Mov(
dispatch_next;
}
-specialize Mov() + Mov() as Mov2;
-specialize Mov() + Mov() + Mov() as Mov3;
specialize Mov(src: Undefined);
-specialize Mov(src: Undefined) + Mov(src: Undefined) as MovUndefined2;
-specialize Mov(src: Undefined) + Mov(src: Undefined) + Mov(src: Undefined) as MovUndefined3;
specialize Add(lhs: Int32);
specialize Add(rhs: Int32);
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/handling.rs b/Libraries/LibJS/JIT/Rust/src/builder/handling.rs
index 1fe8eb95701..5a72e838276 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/handling.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/handling.rs
@@ -91,11 +91,7 @@ pub fn handling(opcode: OpCode) -> Handling {
// Control flow, moves and frame setup.
O::Enter
| O::Mov
- | O::Mov2
- | O::Mov3
| O::MovSrcUndefined
- | O::MovUndefined2
- | O::MovUndefined3
| O::Jump
| O::JumpIf
| O::JumpTrue
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/mod.rs b/Libraries/LibJS/JIT/Rust/src/builder/mod.rs
index de676e14fc1..d6b52741093 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/mod.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/mod.rs
@@ -1430,25 +1430,13 @@ impl<'a> GraphBuilder<'a> {
};
}
}
- Instruction::Mov { dst, src } => self.build_moves(&[(dst, src)])?,
- Instruction::Mov2 {
- c0_dst,
- c0_src,
- c1_dst,
- c1_src,
- } => self.build_moves(&[(c0_dst, c0_src), (c1_dst, c1_src)])?,
- Instruction::Mov3 {
- c0_dst,
- c0_src,
- c1_dst,
- c1_src,
- c2_dst,
- c2_src,
- } => self.build_moves(&[(c0_dst, c0_src), (c1_dst, c1_src), (c2_dst, c2_src)])?,
- Instruction::MovSrcUndefined { dst } => self.build_undefined_moves(&[dst])?,
- Instruction::MovUndefined2 { c0_dst, c1_dst } => self.build_undefined_moves(&[c0_dst, c1_dst])?,
- Instruction::MovUndefined3 { c0_dst, c1_dst, c2_dst } => {
- self.build_undefined_moves(&[c0_dst, c1_dst, c2_dst])?;
+ Instruction::Mov { dst, src } => {
+ let value = self.read(src)?;
+ self.write(dst, value)?;
+ }
+ Instruction::MovSrcUndefined { dst } => {
+ let undefined = self.constant(value::UNDEFINED);
+ self.write(dst, undefined)?;
}
Instruction::Jump { target } | Instruction::JumpLoop { target } => {
let target = self.block_for_label(target)?;
@@ -1903,22 +1891,6 @@ impl<'a> GraphBuilder<'a> {
))
}
- fn build_moves(&mut self, moves: &[(Operand, Operand)]) -> Result<(), CompileFailure> {
- for (dst, src) in moves {
- let value = self.read(*src)?;
- self.write(*dst, value)?;
- }
- Ok(())
- }
-
- fn build_undefined_moves(&mut self, destinations: &[Operand]) -> Result<(), CompileFailure> {
- let undefined = self.constant(value::UNDEFINED);
- for dst in destinations {
- self.write(*dst, undefined)?;
- }
- Ok(())
- }
-
fn build_tag_branch(
&mut self,
condition: BranchCondition,
diff --git a/Libraries/LibJS/JIT/Rust/src/builder/tests.rs b/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
index 9256947f657..6307ff4567a 100644
--- a/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/builder/tests.rs
@@ -751,21 +751,14 @@ fn trivial_frame_operations_are_native() {
let program = assemble(|_| {
vec![
Instruction::GetLexicalEnvironment { dst: r(5) },
- Instruction::MovUndefined2 {
- c0_dst: r(6),
- c1_dst: r(3),
- },
+ Instruction::MovSrcUndefined { dst: r(6) },
+ Instruction::MovSrcUndefined { dst: r(3) },
Instruction::IsCallable { dst: r(7), value: r(5) },
Instruction::SetLexicalEnvironment { environment: r(5) },
Instruction::LeavePrivateEnvironment,
- Instruction::Mov3 {
- c0_dst: l(0),
- c0_src: r(7),
- c1_dst: r(7),
- c1_src: r(6),
- c2_dst: l(1),
- c2_src: r(2),
- },
+ Instruction::Mov { dst: l(0), src: r(7) },
+ Instruction::Mov { dst: r(7), src: r(6) },
+ Instruction::Mov { dst: l(1), src: r(2) },
Instruction::Throw { src: l(0) },
]
});
@@ -781,10 +774,10 @@ fn trivial_frame_operations_are_native() {
[[V5]] = IsCallable ([[V2]])
[[V6]]:pointer = SetLexicalEnvironment ([[V2]])
LeavePrivateEnvironment
- CallSlowPath Throw @88 ([[V5]]) [[[FS0]]]
+ CallSlowPath Throw @104 ([[V5]]) [[[FS0]]]
Unreachable
frame states:
- [[FS0]]: pc 88 after {}
+ [[FS0]]: pc 104 after {}
",
);
}
diff --git a/Libraries/LibJS/JIT/Rust/src/bytecode/instruction.rs b/Libraries/LibJS/JIT/Rust/src/bytecode/instruction.rs
index 18f842569b5..b949b886cd0 100644
--- a/Libraries/LibJS/JIT/Rust/src/bytecode/instruction.rs
+++ b/Libraries/LibJS/JIT/Rust/src/bytecode/instruction.rs
@@ -418,11 +418,9 @@ mod tests {
lhs: operand(6),
rhs: -5,
},
- Instruction::Mov2 {
- c0_dst: operand(5),
- c0_src: operand(6),
- c1_dst: operand(7),
- c1_src: operand(5),
+ Instruction::Mov {
+ dst: operand(5),
+ src: operand(6),
},
Instruction::PostfixIncrement {
arith_feedback: 0,
@@ -465,12 +463,7 @@ mod tests {
assert!(operands_with_roles(&decoded[4].instruction).is_empty());
assert_eq!(
operands_with_roles(&decoded[6].instruction),
- [
- (5, OperandRole::Out),
- (6, OperandRole::In),
- (7, OperandRole::Out),
- (5, OperandRole::In)
- ]
+ [(5, OperandRole::Out), (6, OperandRole::In)]
);
assert_eq!(
operands_with_roles(&decoded[7].instruction),
diff --git a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs
index dc17d6b9695..9f137a3f2ca 100644
--- a/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/codegen/tests.rs
@@ -1686,15 +1686,6 @@ mod execution {
}
}
Instruction::Mov { dst, src } => slots[dst.raw() as usize] = read(&slots, src),
- Instruction::Mov2 {
- c0_dst,
- c0_src,
- c1_dst,
- c1_src,
- } => {
- slots[c0_dst.raw() as usize] = read(&slots, c0_src);
- slots[c1_dst.raw() as usize] = read(&slots, c1_src);
- }
Instruction::MovSrcUndefined { dst } => slots[dst.raw() as usize] = value::UNDEFINED,
Instruction::Add { dst, lhs, rhs, .. } => {
slots[dst.raw() as usize] = reference_add(read(&slots, lhs), read(&slots, rhs));
diff --git a/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs b/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
index d8bf3204214..8e9905f46b6 100644
--- a/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
+++ b/Libraries/LibJS/JIT/Rust/src/regalloc/tests.rs
@@ -715,13 +715,7 @@ impl ProgramGenerator {
dst: self.writable(),
src: self.readable(),
},
- 3 => Instruction::Mov2 {
- c0_dst: self.writable(),
- c0_src: self.readable(),
- c1_dst: self.writable(),
- c1_src: self.readable(),
- },
- 4 => Instruction::MovSrcUndefined { dst: self.writable() },
+ 3 | 4 => Instruction::MovSrcUndefined { dst: self.writable() },
5 => Instruction::Add {
arith_feedback: 0,
dst: self.writable(),
diff --git a/Libraries/LibJS/Rust/src/bytecode/instruction.rs b/Libraries/LibJS/Rust/src/bytecode/instruction.rs
index bd4394cf70f..54f75017194 100644
--- a/Libraries/LibJS/Rust/src/bytecode/instruction.rs
+++ b/Libraries/LibJS/Rust/src/bytecode/instruction.rs
@@ -43,35 +43,15 @@ mod tests {
#[test]
fn selects_declarative_undefined_move_specializations() {
- let instructions = [
- Instruction::Mov {
- dst: Operand::register(Register(0)),
- src: Operand::constant(0),
- },
- Instruction::Mov {
- dst: Operand::register(Register(1)),
- src: Operand::constant(0),
- },
- Instruction::Mov {
- dst: Operand::register(Register(2)),
- src: Operand::constant(0),
- },
- ];
+ let instruction = Instruction::Mov {
+ dst: Operand::register(Register(0)),
+ src: Operand::constant(0),
+ };
let constants = [ConstantValue::Undefined];
let (specialized, component_count) =
- specialize_instruction_sequence(instructions[..1].iter(), &constants).expect("Mov should specialize");
+ specialize_instruction_sequence([&instruction].into_iter(), &constants).expect("Mov should specialize");
assert_eq!(component_count, 1);
assert!(matches!(specialized, Instruction::MovSrcUndefined { .. }));
-
- let (specialized, component_count) =
- specialize_instruction_sequence(instructions[..2].iter(), &constants).expect("Mov pair should specialize");
- assert_eq!(component_count, 2);
- assert!(matches!(specialized, Instruction::MovUndefined2 { .. }));
-
- let (specialized, component_count) =
- specialize_instruction_sequence(instructions.iter(), &constants).expect("Mov triplet should specialize");
- assert_eq!(component_count, 3);
- assert!(matches!(specialized, Instruction::MovUndefined3 { .. }));
}
}