LibJS: Skip allocation of temp object for primitive types in Value::get

Previously, `String.prototype.split()` caused the construction of a
temporary StringObject when a string primitive was passed as an
argument, solely to perform a Symbol.split lookup. This change allows
skipping that allocation by looking directly into the prototype of
primitive values.

As a result, we can avoid ~200000 StringObject allocations in a single
test from the Speedometer 2 benchmark.

Co-Authored-By: Andreas Kling <andreas@ladybird.org>
This commit is contained in:
Aliaksandr Kalenik 2025-03-24 16:25:33 +00:00 committed by Alexander Kalenik
commit a8285f255b
Notes: github-actions[bot] 2025-03-24 19:39:12 +00:00
2 changed files with 17 additions and 1 deletions

View file

@ -105,6 +105,8 @@ public:
return StringOrSymbol(as_symbol());
}
bool operator==(PropertyKey const&) const = default;
private:
friend Traits<JS::PropertyKey>;