mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-12 22:22:55 +00:00
LibJS/Bytecode: Avoid Value==Value in Call built-in fast path
Comparing two Values has to call the generic same_value() helper, and we can avoid this by simply using a stronger type for built-in native function handlers.
This commit is contained in:
parent
1060c63bd8
commit
01e9eee7dd
Notes:
sideshowbarker
2024-07-17 11:34:34 +09:00
Author: https://github.com/awesomekling
Commit: 01e9eee7dd
Pull-request: https://github.com/SerenityOS/serenity/pull/23390
Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 8 additions and 5 deletions
|
@ -1248,7 +1248,10 @@ ThrowCompletionOr<void> Call::execute_impl(Bytecode::Interpreter& interpreter) c
|
|||
|
||||
TRY(throw_if_needed_for_call(interpreter, callee, call_type(), expression_string()));
|
||||
|
||||
if (m_builtin.has_value() && m_argument_count == Bytecode::builtin_argument_count(m_builtin.value()) && interpreter.realm().get_builtin_value(m_builtin.value()) == callee) {
|
||||
if (m_builtin.has_value()
|
||||
&& m_argument_count == Bytecode::builtin_argument_count(m_builtin.value())
|
||||
&& callee.is_object()
|
||||
&& interpreter.realm().get_builtin_value(m_builtin.value()) == &callee.as_object()) {
|
||||
interpreter.set(dst(), TRY(dispatch_builtin_call(interpreter, m_builtin.value(), { m_arguments, m_argument_count })));
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -52,14 +52,14 @@ public:
|
|||
HostDefined* host_defined() { return m_host_defined; }
|
||||
void set_host_defined(OwnPtr<HostDefined> host_defined) { m_host_defined = move(host_defined); }
|
||||
|
||||
void define_builtin(Bytecode::Builtin builtin, Value value)
|
||||
void define_builtin(Bytecode::Builtin builtin, NonnullGCPtr<NativeFunction> value)
|
||||
{
|
||||
m_builtins[to_underlying(builtin)] = value;
|
||||
}
|
||||
|
||||
Value get_builtin_value(Bytecode::Builtin builtin)
|
||||
NonnullGCPtr<NativeFunction> get_builtin_value(Bytecode::Builtin builtin)
|
||||
{
|
||||
return m_builtins[to_underlying(builtin)];
|
||||
return *m_builtins[to_underlying(builtin)];
|
||||
}
|
||||
|
||||
static FlatPtr global_environment_offset() { return OFFSET_OF(Realm, m_global_environment); }
|
||||
|
@ -74,7 +74,7 @@ private:
|
|||
GCPtr<Object> m_global_object; // [[GlobalObject]]
|
||||
GCPtr<GlobalEnvironment> m_global_environment; // [[GlobalEnv]]
|
||||
OwnPtr<HostDefined> m_host_defined; // [[HostDefined]]
|
||||
AK::Array<Value, to_underlying(Bytecode::Builtin::__Count)> m_builtins;
|
||||
AK::Array<GCPtr<NativeFunction>, to_underlying(Bytecode::Builtin::__Count)> m_builtins;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue