mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
LibJS: Move source range cache from ExecutionContext to Executable
CachedSourceRange was a GC-allocated cell stored on the ExecutionContext, only needed because ExecutionContext must be trivially destructible. Move the source range cache to a HashMap<u32, SourceRange> on the Executable (keyed by program counter), where it belongs. This eliminates the GC::Cell subclass entirely and removes the cached_source_range field from ExecutionContext. StackTraceElement and TracebackFrame now store Optional<SourceRange> directly instead of GC::Ptr<CachedSourceRange>. Shrinks ExecutionContext from 144 to 136 bytes.
This commit is contained in:
parent
f02b67a700
commit
75e7bc1e2a
Notes:
github-actions[bot]
2026-03-11 12:35:21 +00:00
Author: https://github.com/awesomekling
Commit: 75e7bc1e2a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8360
Reviewed-by: https://github.com/shannonbooth
10 changed files with 31 additions and 68 deletions
|
|
@ -246,6 +246,17 @@ UnrealizedSourceRange Executable::source_range_at(size_t offset) const
|
|||
};
|
||||
}
|
||||
|
||||
SourceRange const& Executable::get_source_range(u32 program_counter)
|
||||
{
|
||||
return m_source_range_cache.ensure(program_counter, [&] {
|
||||
auto unrealized = source_range_at(program_counter);
|
||||
if (unrealized.source_code)
|
||||
return unrealized.realize();
|
||||
static SourceRange dummy { SourceCode::create({}, {}), {}, {} };
|
||||
return dummy;
|
||||
});
|
||||
}
|
||||
|
||||
Operand Executable::original_operand_from_raw(u32 raw) const
|
||||
{
|
||||
// NB: Layout is [registers | locals | constants | arguments]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue