mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibJS: Optimize insertion order in the Exception constructor
By inserting the stack frames in the correct order we can improve the runtime for the test-js test suite by about 20%.
This commit is contained in:
parent
bc8d16ad28
commit
8b449214af
Notes:
sideshowbarker
2024-07-18 16:57:24 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/8b449214aff Pull-request: https://github.com/SerenityOS/serenity/pull/7729
|
@ -18,18 +18,18 @@ Exception::Exception(Value value)
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
m_traceback.ensure_capacity(vm.call_stack().size());
|
||||
for (auto* call_frame : vm.call_stack()) {
|
||||
for (ssize_t i = vm.call_stack().size() - 1; i >= 0; i--) {
|
||||
auto* call_frame = vm.call_stack()[i];
|
||||
auto function_name = call_frame->function_name;
|
||||
if (function_name.is_empty())
|
||||
function_name = "<anonymous>";
|
||||
m_traceback.prepend({
|
||||
.function_name = move(function_name),
|
||||
m_traceback.empend(
|
||||
move(function_name),
|
||||
// We might not have an AST node associated with the call frame, e.g. in promise
|
||||
// reaction jobs (which aren't called anywhere from the source code).
|
||||
// They're not going to generate any _unhandled_ exceptions though, so a meaningless
|
||||
// source range is fine.
|
||||
.source_range = call_frame->current_node ? call_frame->current_node->source_range() : SourceRange {},
|
||||
});
|
||||
call_frame->current_node ? call_frame->current_node->source_range() : SourceRange {});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue