mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibJS: Flatten Operand to 32-bit index in bytecode instruction stream
While we're in the bytecode compiler, we want to know which type of Operand we're dealing with, but once we've generated the bytecode stream, we only ever need its index. This patch simplifies Operand by removing the aarch64 bitfield hacks and makes it 32-bit on all platforms. We keep 3 type bits in the high bits of the index while compiling, and then zero them out when flattening the final bytecode stream. This makes bytecode more compact on x86_64, and avoids bit twiddling on aarch64. Everyone wins something! When stringifying bytecode for debugging output, we now have an API in Executable that can look at a raw operand index and tell you what type of operand it was, based on known quantities of each type in the stack frame.
This commit is contained in:
committed by
Andreas Kling
parent
3248f5bc59
commit
9f822345bf
Notes:
github-actions[bot]
2025-12-10 03:48:09 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/9f822345bf2 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7080
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2024, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2021-2025, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
@@ -115,4 +115,15 @@ UnrealizedSourceRange Executable::source_range_at(size_t offset) const
|
||||
};
|
||||
}
|
||||
|
||||
Operand Executable::original_operand_from_raw(u32 raw) const
|
||||
{
|
||||
if (raw < number_of_registers)
|
||||
return Operand { Operand::Type::Register, raw };
|
||||
if (raw < local_index_base)
|
||||
return Operand { Operand::Type::Constant, raw - static_cast<u32>(number_of_registers) };
|
||||
if (raw < argument_index_base)
|
||||
return Operand { Operand::Type::Local, raw - static_cast<u32>(local_index_base) };
|
||||
return Operand { Operand::Type::Argument, raw - static_cast<u32>(argument_index_base) };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user