Bug 1320105 : Convert JSID_IS_INT to PropertyKey::isInt() r=jandem
authorinspiro <sharma.divyansh.501@iitg.ac.in>
Sat, 22 Dec 2018 14:17:44 +0000
changeset 508933 968418409443d19c6e6598c1c0054ea129ac1f81
parent 508932 3cedbcfaf7f99f6ef9ef2923545b9279937f3f47
child 508934 6b1554f389f179f5ce6f0ff32fd2a27e1e185b20
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1320105
milestone66.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 1320105 : Convert JSID_IS_INT to PropertyKey::isInt() r=jandem Convert JSID_IS_INT to PropertyKey::isInt() Differential Revision: https://phabricator.services.mozilla.com/D14011
js/public/Id.h
--- a/js/public/Id.h
+++ b/js/public/Id.h
@@ -48,16 +48,19 @@ struct PropertyKey {
   static constexpr MOZ_ALWAYS_INLINE PropertyKey fromRawBits(size_t bits) {
     PropertyKey id;
     id.asBits = bits;
     return id;
   }
 
   bool operator==(const PropertyKey& rhs) const { return asBits == rhs.asBits; }
   bool operator!=(const PropertyKey& rhs) const { return asBits != rhs.asBits; }
+
+  MOZ_ALWAYS_INLINE bool isInt() const { return !!(asBits & JSID_TYPE_INT_BIT); }
+  
 } JS_HAZ_GC_POINTER;
 
 }  // namespace JS
 
 using jsid = JS::PropertyKey;
 
 #define JSID_BITS(id) (id.asBits)
 
@@ -86,16 +89,17 @@ static MOZ_ALWAYS_INLINE JSString* JSID_
 JS_PUBLIC_API jsid INTERNED_STRING_TO_JSID(JSContext* cx, JSString* str);
 
 static MOZ_ALWAYS_INLINE bool JSID_IS_INT(jsid id) {
   return !!(JSID_BITS(id) & JSID_TYPE_INT_BIT);
 }
 
 static MOZ_ALWAYS_INLINE int32_t JSID_TO_INT(jsid id) {
   MOZ_ASSERT(JSID_IS_INT(id));
+  MOZ_ASSERT(id.isInt());
   uint32_t bits = static_cast<uint32_t>(JSID_BITS(id)) >> 1;
   return static_cast<int32_t>(bits);
 }
 
 #define JSID_INT_MIN 0
 #define JSID_INT_MAX INT32_MAX
 
 static MOZ_ALWAYS_INLINE bool INT_FITS_IN_JSID(int32_t i) { return i >= 0; }