LibJS/Bytecode: Keep instruction source mappings in Executable

Instead of storing source offsets with each instruction, we now keep
them in a side table in Executable.

This shrinks each instruction by 8 bytes, further improving locality.
This commit is contained in:
Andreas Kling 2024-05-06 07:51:14 +02:00
commit 5a08544138
Notes: sideshowbarker 2024-07-17 02:28:18 +09:00
8 changed files with 27 additions and 14 deletions

View file

@ -106,11 +106,13 @@ UnrealizedSourceRange Executable::source_range_at(size_t offset) const
return {};
auto it = InstructionStreamIterator(bytecode.span().slice(offset), this);
VERIFY(!it.at_end());
auto& instruction = *it;
auto mapping = source_map.get(offset);
if (!mapping.has_value())
return {};
return UnrealizedSourceRange {
.source_code = source_code,
.start_offset = instruction.source_record().source_start_offset,
.end_offset = instruction.source_record().source_end_offset,
.start_offset = mapping->source_start_offset,
.end_offset = mapping->source_end_offset,
};
}