LibJS: Cache Executable constants for asm Call

Mirror Executable's constants size and data pointer in adjacent fields
so the asm Call fast path can pair-load them together. The underlying
Vector layout keeps size and data apart, so a small cached raw span
lets the hot constant-copy loop fetch both pieces of metadata at once.
This commit is contained in:
Andreas Kling 2026-04-14 10:16:33 +02:00 committed by Andreas Kling
parent 5761f6bc54
commit b6c7f6c0c4
4 changed files with 7 additions and 2 deletions

View file

@ -2139,8 +2139,7 @@ handler Call
.copy_constants:
load64 t0, [t2, EXECUTION_CONTEXT_EXECUTABLE]
load64 t3, [t0, EXECUTABLE_CONSTANTS_SIZE]
load64 t0, [t0, EXECUTABLE_CONSTANTS_DATA]
load_pair64 t3, t0, [t0, EXECUTABLE_ASM_CONSTANTS_SIZE], [t0, EXECUTABLE_ASM_CONSTANTS_DATA]
mov t1, t5
xor t8, t8
.copy_constants_loop:

View file

@ -132,6 +132,8 @@ int main()
EMIT_OFFSET(EXECUTABLE_PROPERTY_LOOKUP_CACHES, Executable, property_lookup_caches);
EMIT_OFFSET(EXECUTABLE_REGISTERS_AND_LOCALS_COUNT, Executable, registers_and_locals_count);
EMIT_OFFSET(EXECUTABLE_REGISTERS_AND_LOCALS_AND_CONSTANTS_COUNT, Executable, registers_and_locals_and_constants_count);
EMIT_OFFSET(EXECUTABLE_ASM_CONSTANTS_SIZE, Executable, asm_constants_size);
EMIT_OFFSET(EXECUTABLE_ASM_CONSTANTS_DATA, Executable, asm_constants_data);
// ExecutionContext layout
outln("\n# ExecutionContext layout");

View file

@ -83,6 +83,8 @@ Executable::Executable(
template_object_caches.resize(number_of_template_object_caches);
object_shape_caches.resize(number_of_object_shape_caches);
object_property_iterator_caches.resize(number_of_object_property_iterator_caches);
asm_constants_size = this->constants.size();
asm_constants_data = this->constants.data();
}
Executable::~Executable() = default;

View file

@ -193,6 +193,8 @@ public:
u32 registers_and_locals_count { 0 };
u32 registers_and_locals_and_constants_count { 0 };
size_t asm_constants_size { 0 };
Value const* asm_constants_data { nullptr };
struct ExceptionHandlers {
size_t start_offset;