1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 10:47:35 +00:00

LibJS: Align Instructions as void* and roundup variably sized ones sizes

Both is indeed needed,
the standard alignment would have been 4, but some Instructions, like
Jumps need an alignment of 8

Fixes #12127.
This commit is contained in:
Hendiadyoin1 2022-09-09 16:47:42 +02:00 committed by Linus Groh
parent 89408d5f64
commit 911506af9f
3 changed files with 9 additions and 5 deletions

View file

@ -8,6 +8,7 @@
#pragma once
#include <AK/StdLibExtras.h>
#include <LibCrypto/BigInt/SignedBigInteger.h>
#include <LibJS/Bytecode/IdentifierTable.h>
#include <LibJS/Bytecode/Instruction.h>
@ -990,9 +991,9 @@ ALWAYS_INLINE void Instruction::replace_references(BasicBlock const& from, Basic
ALWAYS_INLINE size_t Instruction::length() const
{
if (type() == Type::NewArray)
return static_cast<Op::NewArray const&>(*this).length_impl();
return round_up_to_power_of_two(static_cast<Op::NewArray const&>(*this).length_impl(), alignof(void*));
if (type() == Type::CopyObjectExcludingProperties)
return static_cast<Op::CopyObjectExcludingProperties const&>(*this).length_impl();
return round_up_to_power_of_two(static_cast<Op::CopyObjectExcludingProperties const&>(*this).length_impl(), alignof(void*));
#define __BYTECODE_OP(op) \
case Type::op: \