mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 18:47:15 +02:00
LibJS: Cache PutById to setters in the prototype chain
This is *extremely* common on the web, but barely shows up at all in JavaScript benchmarks. A typical example is setting Element.innerHTML on a HTMLDivElement. HTMLDivElement doesn't have innerHTML, so it has to travel up the prototype chain until it finds it. Before this change, we didn't cache this at all, so we had to travel the prototype chain every time a setter like this was used. We now use the same mechanism we already had for GetBydId and cache PutById setter accesses in the prototype chain as well. 1.74x speedup on MicroBench/setter-in-prototype-chain.js
This commit is contained in:
committed by
Andreas Kling
parent
71665fa504
commit
183c847c80
Notes:
github-actions[bot]
2025-05-05 13:22:41 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/183c847c806 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4597
@@ -39,11 +39,11 @@ void ObservableArray::set_on_delete_an_indexed_value_callback(DeleteAnIndexedVal
|
||||
m_on_delete_an_indexed_value = GC::create_function(heap(), move(callback));
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<bool> ObservableArray::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata)
|
||||
JS::ThrowCompletionOr<bool> ObservableArray::internal_set(JS::PropertyKey const& property_key, JS::Value value, JS::Value receiver, JS::CacheablePropertyMetadata* metadata, PropertyLookupPhase phase)
|
||||
{
|
||||
if (property_key.is_number() && m_on_set_an_indexed_value)
|
||||
TRY(Bindings::throw_dom_exception_if_needed(vm(), [&] { return m_on_set_an_indexed_value->function()(value); }));
|
||||
return TRY(Base::internal_set(property_key, value, receiver, metadata));
|
||||
return TRY(Base::internal_set(property_key, value, receiver, metadata, phase));
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<bool> ObservableArray::internal_delete(JS::PropertyKey const& property_key)
|
||||
|
||||
Reference in New Issue
Block a user