v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
safe_conversions_arm_impl.h
Go to the documentation of this file.
1
// Copyright 2017 The Chromium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Slightly adapted for inclusion in V8.
6
// Copyright 2025 the V8 project authors. All rights reserved.
7
8
#ifndef V8_BASE_NUMERICS_SAFE_CONVERSIONS_ARM_IMPL_H_
9
#define V8_BASE_NUMERICS_SAFE_CONVERSIONS_ARM_IMPL_H_
10
11
// IWYU pragma: private, include "src/base/numerics/safe_conversions.h"
12
13
#include <stdint.h>
14
15
#include <algorithm>
16
#include <concepts>
17
#include <type_traits>
18
19
#include "
src/base/numerics/safe_conversions_impl.h
"
20
21
namespace
v8::base
{
22
namespace
internal
{
23
24
// Fast saturation to a destination type.
25
template
<
typename
Dst,
typename
Src>
26
struct
SaturateFastAsmOp
{
27
static
constexpr
bool
is_supported
=
28
kEnableAsmCode
&& std::signed_integral<Src> && std::integral<Dst> &&
29
kIntegerBitsPlusSign<Src>
<=
kIntegerBitsPlusSign<int32_t>
&&
30
kIntegerBitsPlusSign<Dst>
<=
kIntegerBitsPlusSign<int32_t>
&&
31
!kIsTypeInRangeForNumericType<Dst, Src>;
32
33
__attribute__
((always_inline))
static
Dst
Do
(Src value) {
34
int32_t src =
value
;
35
if
constexpr
(std::is_signed_v<Dst>) {
36
int32_t
result
;
37
asm
(
"ssat %[dst], %[shift], %[src]"
38
: [dst]
"=r"
(
result
)
39
: [src]
"r"
(src), [shift]
"n"
(
40
std::min(
kIntegerBitsPlusSign<Dst>
, 32)));
41
return
static_cast<
Dst
>
(
result
);
42
}
else
{
43
uint32_t
result
;
44
asm
(
"usat %[dst], %[shift], %[src]"
45
: [dst]
"=r"
(
result
)
46
: [src]
"r"
(src), [shift]
"n"
(
47
std::min(
kIntegerBitsPlusSign<Dst>
, 31)));
48
return
static_cast<
Dst
>
(
result
);
49
}
50
}
51
};
52
53
}
// namespace internal
54
}
// namespace v8::base
55
56
#endif
// V8_BASE_NUMERICS_SAFE_CONVERSIONS_ARM_IMPL_H_
result
ZoneVector< RpoNumber > & result
Definition
jump-threading.cc:21
v8::base::internal::kEnableAsmCode
constexpr bool kEnableAsmCode
Definition
safe_conversions_impl.h:80
v8::base::internal::kIntegerBitsPlusSign
constexpr int kIntegerBitsPlusSign
Definition
safe_conversions_impl.h:36
v8::base
Definition
scopes.h:26
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
safe_conversions_impl.h
v8::base::internal::SaturateFastAsmOp
Definition
safe_conversions_arm_impl.h:26
v8::base::internal::SaturateFastAsmOp::__attribute__
__attribute__((always_inline)) static Dst Do(Src value)
Definition
safe_conversions_arm_impl.h:33
v8::base::internal::SaturateFastAsmOp::Do
static constexpr Dst Do(Src)
Definition
safe_conversions.h:34
v8::base::internal::SaturateFastAsmOp::is_supported
static constexpr bool is_supported
Definition
safe_conversions.h:33
value
std::unique_ptr< ValueMirror > value
Definition
value-mirror.cc:950
src
base
numerics
safe_conversions_arm_impl.h
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0