LibJS: Add cache for the string "[object Object]"

This is very frequently returned by Object.prototype.toString(),
so we benefit from caching it instead of recreating it every time.

Takes Speedometer2.1/EmberJS-Debug-TodoMVC from ~4000ms to ~3700ms
on my M3 MacBook Pro.
This commit is contained in:
Andreas Kling 2025-04-14 23:42:31 +02:00 committed by Andreas Kling
commit 81d4ed27d8
Notes: github-actions[bot] 2025-04-15 11:09:47 +00:00
4 changed files with 27 additions and 20 deletions

View file

@ -229,7 +229,8 @@ public:
GC::Ptr<PrimitiveString> boolean;
GC::Ptr<PrimitiveString> bigint;
GC::Ptr<PrimitiveString> function;
} typeof_strings;
GC::Ptr<PrimitiveString> object_Object;
} cached_strings;
void run_queued_promise_jobs();
void enqueue_promise_job(GC::Ref<GC::Function<ThrowCompletionOr<Value>()>> job, Realm*);