1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:37:36 +00:00

LibJS+LibJIT: Add fast path for Int32 * Int32

This commit is contained in:
Andreas Kling 2023-11-03 09:15:21 +01:00
parent 0aeb83b03f
commit 24fb009cf5
3 changed files with 64 additions and 1 deletions

View file

@ -546,6 +546,28 @@ struct Assembler {
}
}
void mul32(Operand dest, Operand src, Optional<Label&> overflow_label)
{
// imul32 dest, src (32-bit signed)
if (dest.type == Operand::Type::Reg && src.type == Operand::Type::Reg) {
emit_rex_for_rm(dest, src, REX_W::No);
emit8(0x0f);
emit8(0xaf);
emit_modrm_rm(dest, src);
} else if (dest.type == Operand::Type::Reg && src.type == Operand::Type::Mem64BaseAndOffset) {
emit_rex_for_rm(dest, src, REX_W::No);
emit8(0x0f);
emit8(0xaf);
emit_modrm_rm(dest, src);
} else {
VERIFY_NOT_REACHED();
}
if (overflow_label.has_value()) {
jump_if(Condition::Overflow, *overflow_label);
}
}
void enter()
{
push(Operand::Register(Reg::RBP));