From d53f7f50183fb53b0e99ea288bd3b8fd798740fa Mon Sep 17 00:00:00 2001 From: Iain Ireland Date: Thu, 21 May 2020 17:33:29 +0000 Subject: [PATCH] Bug 1638154: Add is_int24 to shim r=tcampbell Adding `is_int24` is the only shim change necessary. While I was here, I took the opportunity to align `is_uint24` to more closely match the V8 version (https://github.com/v8/v8/blob/a0d493e27e8bb3c643fbedc388350766e9f1f874/src/utils/utils.h#L426-L472). Depends on D76250 Differential Revision: https://phabricator.services.mozilla.com/D76251 --- js/src/new-regexp/regexp-shim.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/src/new-regexp/regexp-shim.h b/js/src/new-regexp/regexp-shim.h index cc4911bd2e8e..6c8b88654b53 100644 --- a/js/src/new-regexp/regexp-shim.h +++ b/js/src/new-regexp/regexp-shim.h @@ -391,7 +391,14 @@ constexpr int kInt64Size = sizeof(int64_t); constexpr int kUC16Size = sizeof(uc16); inline constexpr bool IsDecimalDigit(uc32 c) { return c >= '0' && c <= '9'; } -inline bool is_uint24(int val) { return (val & 0x00ffffff) == val; } + +inline bool is_uint24(int64_t val) { + return !(val >> 24); +} +inline bool is_int24(int64_t val) { + int64_t limit = 1 << 23; + return (-limit <= val) && (val < limit); +} inline bool IsIdentifierStart(uc32 c) { return js::unicode::IsIdentifierStart(uint32_t(c));