[vm] Let the C++ compiler know it can assume the low bit of a Smi is clear.

TEST=ci
Change-Id: I89f60532a6fe7923a5d4d7bbcd624228ab899854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481300
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2026-02-23 13:01:19 -08:00
committed by Commit Queue
parent 0c3771aaee
commit 60fe67bb4b
2 changed files with 14 additions and 0 deletions
+11
View File
@@ -250,6 +250,17 @@ struct simd128_value_t {
#error Automatic compiler detection failed.
#endif
#if defined(__clang__)
#define DART_ASSUME(expr) __builtin_assume(expr)
#elif defined(__GNUC__)
#define DART_ASSUME(expr) \
if (!(expr)) __builtin_unreachable()
#elif defined(_MSC_VER)
#define DART_ASSUME(expr) __assume(expr)
#else
#error Automatic compiler detection failed.
#endif
#ifdef _MSC_VER
#elif __GNUC__
#define DART_HAS_COMPUTED_GOTO 1
+3
View File
@@ -457,6 +457,9 @@ inline intptr_t RawSmiValue(const SmiPtr raw_value) {
static_cast<uint32_t>(static_cast<uintptr_t>(raw_value))));
#endif
ASSERT((value & kSmiTagMask) == kSmiTag);
// Let the C++ compiler know that it is safe to combine this right shift with
// a following left shift, such as often occurs for index scaling.
DART_ASSUME((value & kSmiTagMask) == kSmiTag);
return (value >> kSmiTagShift);
}