Bug 1638154: Add is_int24 to shim r=tcampbell
authorIain Ireland <iireland@mozilla.com>
Thu, 21 May 2020 17:33:29 +0000
changeset 531521 979cea3e1aa94b6234d7863df2f905d066329816
parent 531520 1011b207d264908077a1ac1aeefbe28bc386dfdb
child 531522 fd143c3d9027c00237fd2054f75e91fb925942b2
push id116700
push useriireland@mozilla.com
push dateThu, 21 May 2020 19:38:40 +0000
treeherderautoland@979cea3e1aa9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1638154
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
--- a/js/src/new-regexp/regexp-shim.h
+++ b/js/src/new-regexp/regexp-shim.h
@@ -386,17 +386,24 @@ constexpr double kMaxSafeInteger = 90071
 
 constexpr int kBitsPerByte = 8;
 constexpr int kBitsPerByteLog2 = 3;
 constexpr int kUInt32Size = sizeof(uint32_t);
 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));
 }
 inline bool IsIdentifierPart(uc32 c) {
   return js::unicode::IsIdentifierPart(uint32_t(c));
 }