mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibJS: Move ExecutionContext::cached_source_range to rare data
This commit is contained in:
parent
3ef55f8859
commit
5b9469786e
|
|
@ -144,7 +144,6 @@ void ExecutionContext::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(variable_environment);
|
visitor.visit(variable_environment);
|
||||||
visitor.visit(lexical_environment);
|
visitor.visit(lexical_environment);
|
||||||
visitor.visit(private_environment);
|
visitor.visit(private_environment);
|
||||||
visitor.visit(cached_source_range);
|
|
||||||
visitor.visit(m_rare_data);
|
visitor.visit(m_rare_data);
|
||||||
if (this_value.has_value())
|
if (this_value.has_value())
|
||||||
visitor.visit(*this_value);
|
visitor.visit(*this_value);
|
||||||
|
|
@ -161,6 +160,7 @@ void ExecutionContextRareData::visit_edges(Cell::Visitor& visitor)
|
||||||
{
|
{
|
||||||
Base::visit_edges(visitor);
|
Base::visit_edges(visitor);
|
||||||
visitor.visit(context_owner);
|
visitor.visit(context_owner);
|
||||||
|
visitor.visit(cached_source_range);
|
||||||
for (auto& context : unwind_contexts) {
|
for (auto& context : unwind_contexts) {
|
||||||
visitor.visit(context.lexical_environment);
|
visitor.visit(context.lexical_environment);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ public:
|
||||||
Vector<Optional<size_t>> previously_scheduled_jumps;
|
Vector<Optional<size_t>> previously_scheduled_jumps;
|
||||||
Vector<GC::Ptr<Environment>> saved_lexical_environments;
|
Vector<GC::Ptr<Environment>> saved_lexical_environments;
|
||||||
|
|
||||||
|
mutable GC::Ptr<CachedSourceRange> cached_source_range;
|
||||||
|
|
||||||
// Non-standard: This points at something that owns this ExecutionContext, in case it needs to be protected from GC.
|
// Non-standard: This points at something that owns this ExecutionContext, in case it needs to be protected from GC.
|
||||||
GC::Ptr<Cell> context_owner;
|
GC::Ptr<Cell> context_owner;
|
||||||
|
|
||||||
|
|
@ -90,8 +92,6 @@ public:
|
||||||
// FIXME: Move this out of LibJS (e.g. by using the CustomData concept), as it's used exclusively by LibWeb.
|
// FIXME: Move this out of LibJS (e.g. by using the CustomData concept), as it's used exclusively by LibWeb.
|
||||||
u32 skip_when_determining_incumbent_counter { 0 };
|
u32 skip_when_determining_incumbent_counter { 0 };
|
||||||
|
|
||||||
mutable GC::Ptr<CachedSourceRange> cached_source_range;
|
|
||||||
|
|
||||||
Optional<Value> this_value;
|
Optional<Value> this_value;
|
||||||
|
|
||||||
GC::Ptr<Bytecode::Executable> executable;
|
GC::Ptr<Bytecode::Executable> executable;
|
||||||
|
|
|
||||||
|
|
@ -753,20 +753,21 @@ void VM::load_imported_module(ImportedModuleReferrer referrer, ModuleRequest con
|
||||||
finish_loading_imported_module(referrer, module_request, payload, module);
|
finish_loading_imported_module(referrer, module_request, payload, module);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GC::Ptr<CachedSourceRange> get_source_range(ExecutionContext const* context)
|
static GC::Ptr<CachedSourceRange> get_source_range(ExecutionContext* context)
|
||||||
{
|
{
|
||||||
// native function
|
// native function
|
||||||
if (!context->executable)
|
if (!context->executable)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
if (!context->cached_source_range
|
if (!context->rare_data()
|
||||||
|| context->cached_source_range->program_counter != context->program_counter) {
|
|| !context->rare_data()->cached_source_range
|
||||||
|
|| context->rare_data()->cached_source_range->program_counter != context->program_counter) {
|
||||||
auto unrealized_source_range = context->executable->source_range_at(context->program_counter);
|
auto unrealized_source_range = context->executable->source_range_at(context->program_counter);
|
||||||
context->cached_source_range = context->executable->heap().allocate<CachedSourceRange>(
|
context->ensure_rare_data()->cached_source_range = context->executable->heap().allocate<CachedSourceRange>(
|
||||||
context->program_counter,
|
context->program_counter,
|
||||||
move(unrealized_source_range));
|
move(unrealized_source_range));
|
||||||
}
|
}
|
||||||
return context->cached_source_range;
|
return context->rare_data()->cached_source_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<StackTraceElement> VM::stack_trace() const
|
Vector<StackTraceElement> VM::stack_trace() const
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user