LibJS+LibWeb: Inline fast path for Value::to_object()

Adds inline implementation for the most common case when `Value` is
already an object.

1.47x improvement on the following benchmark:
```js
const o = {};
for (let i = 0; i < 10_000_000; i++) {
    o.a = 1;
    o.b = 2;
    o.c = 3;
}
```
This commit is contained in:
Aliaksandr Kalenik 2025-09-13 20:50:09 +02:00 committed by Alexander Kalenik
parent f5fd6338d5
commit 85e029b2e7
Notes: github-actions[bot] 2025-09-15 10:18:00 +00:00
16 changed files with 22 additions and 1 deletions

View file

@ -585,7 +585,7 @@ ThrowCompletionOr<Value> Value::to_primitive_slow_case(VM& vm, PreferredType pre
}
// 7.1.18 ToObject ( argument ), https://tc39.es/ecma262/#sec-toobject
ThrowCompletionOr<GC::Ref<Object>> Value::to_object(VM& vm) const
ThrowCompletionOr<GC::Ref<Object>> Value::to_object_slow(VM& vm) const
{
auto& realm = *vm.current_realm();
VERIFY(!is_special_empty_value());