LibJS: Avoid function call if @@hasInstance is default implementation

This makes the instanceof operator signficantly faster by avoiding a
generic function call to @@hasInstance unless it has been overridden.

1.15x speed-up on Octane/earley-boyer.js
This commit is contained in:
Andreas Kling
2025-10-13 12:21:59 +02:00
committed by Andreas Kling
parent 5a7b0a07cb
commit 0e4450f4b3
Notes: github-actions[bot] 2025-10-13 15:18:08 +00:00
5 changed files with 12 additions and 1 deletions

View File

@@ -49,6 +49,8 @@ public:
bool is_set_prototype_next_builtin() const { return m_builtin.has_value() && *m_builtin == Bytecode::Builtin::SetIteratorPrototypeNext; }
bool is_string_prototype_next_builtin() const { return m_builtin.has_value() && *m_builtin == Bytecode::Builtin::StringIteratorPrototypeNext; }
Optional<Bytecode::Builtin> builtin() const { return m_builtin; }
protected:
NativeFunction(Utf16FlyString name, Object& prototype);
NativeFunction(AK::Function<ThrowCompletionOr<Value>(VM&)>, Object* prototype, Realm& realm, Optional<Bytecode::Builtin> builtin);