From bc9b76c92e87b7459d392ab4d12d37a998429272 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 9 Apr 2025 23:08:32 +0200 Subject: [PATCH] LibJS: Move Value::to_i32() and to_u32() back out-of-line While good on arm64, this appears to have angered the x86_64 benchmark runner, so let's just put them back out-of-line. --- Libraries/LibJS/Runtime/Value.cpp | 20 ++++++++++++++++++++ Libraries/LibJS/Runtime/ValueInlines.h | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Libraries/LibJS/Runtime/Value.cpp b/Libraries/LibJS/Runtime/Value.cpp index f6660045812..a61ef9c9bef 100644 --- a/Libraries/LibJS/Runtime/Value.cpp +++ b/Libraries/LibJS/Runtime/Value.cpp @@ -926,6 +926,26 @@ ThrowCompletionOr Value::to_property_key(VM& vm) const return MUST(key.to_string(vm)); } +// 7.1.6 ToInt32 ( argument ), https://tc39.es/ecma262/#sec-toint32 +ThrowCompletionOr Value::to_i32(VM& vm) const +{ + if (is_int32()) + return as_i32(); + +#if __has_builtin(__builtin_arm_jcvt) + if (is_double()) + return __builtin_arm_jcvt(m_value.as_double); +#endif + + return to_i32_slow_case(vm); +} + +// 7.1.7 ToUint32 ( argument ), https://tc39.es/ecma262/#sec-touint32 +ThrowCompletionOr Value::to_u32(VM& vm) const +{ + return static_cast(TRY(to_i32(vm))); +} + // 7.1.6 ToInt32 ( argument ), https://tc39.es/ecma262/#sec-toint32 ThrowCompletionOr Value::to_i32_slow_case(VM& vm) const { diff --git a/Libraries/LibJS/Runtime/ValueInlines.h b/Libraries/LibJS/Runtime/ValueInlines.h index c9616e3843b..94d96701596 100644 --- a/Libraries/LibJS/Runtime/ValueInlines.h +++ b/Libraries/LibJS/Runtime/ValueInlines.h @@ -48,24 +48,4 @@ inline ThrowCompletionOr Value::to_primitive(VM& vm, PreferredType prefer return to_primitive_slow_case(vm, preferred_type); } -// 7.1.6 ToInt32 ( argument ), https://tc39.es/ecma262/#sec-toint32 -inline ThrowCompletionOr Value::to_i32(VM& vm) const -{ - if (is_int32()) - return as_i32(); - -#if __has_builtin(__builtin_arm_jcvt) - if (is_double()) - return __builtin_arm_jcvt(m_value.as_double); -#endif - - return to_i32_slow_case(vm); -} - -// 7.1.7 ToUint32 ( argument ), https://tc39.es/ecma262/#sec-touint32 -inline ThrowCompletionOr Value::to_u32(VM& vm) const -{ - return static_cast(TRY(to_i32(vm))); -} - }