Bug 1275064 - Use unsigned type in RealWord bitfield. r=froydnj
☠☠ backed out by 42a8ed44e75c ☠ ☠
authorEric Rahm <erahm@mozilla.com>
Mon, 23 May 2016 15:05:19 -0700
changeset 337730 ac9e8b31ac78cbef46ee425d030e1ccc0f7de968
parent 337729 ffe20266c00e83906a3a974ee06092e5ea80e008
child 337731 6afb408165adbb6431a8ad7aa428861bef0177ea
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1275064
milestone49.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 1275064 - Use unsigned type in RealWord bitfield. r=froydnj
extensions/spellcheck/src/mozInlineSpellWordUtil.h
--- a/extensions/spellcheck/src/mozInlineSpellWordUtil.h
+++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.h
@@ -120,23 +120,24 @@ private:
       : mNodeOffset(aNodeOffset), mSoftTextOffset(aSoftTextOffset),
         mLength(aLength) {}
   };
   nsTArray<DOMTextMapping> mSoftTextDOMMapping;
   
   // A list of the "real words" in mSoftText, ordered by mSoftTextOffset
   struct RealWord {
     int32_t      mSoftTextOffset;
-    int32_t      mLength : 31;
-    int32_t mCheckableWord : 1;
+    uint32_t      mLength : 31;
+    uint32_t mCheckableWord : 1;
     
-    RealWord(int32_t aOffset, int32_t aLength, bool aCheckable)
+    RealWord(int32_t aOffset, uint32_t aLength, bool aCheckable)
       : mSoftTextOffset(aOffset), mLength(aLength), mCheckableWord(aCheckable)
     {
       static_assert(sizeof(RealWord) == 8, "RealWord should be limited to 8 bytes");
+      MOZ_ASSERT(aLength < INT32_MAX, "Word length is too large to fit in the bitfield");
     }
 
     int32_t EndOffset() const { return mSoftTextOffset + mLength; }
   };
   nsTArray<RealWord> mRealWords;
   int32_t            mNextWordIndex;
 
   bool mSoftTextValid;