Bug 1551501 - Fix BinASTTokenReaderContext::readVarU32 to match encoder. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Mon, 20 May 2019 10:39:45 +0000
changeset 474503 62f8232e95795381a6b8a14b25121f73d9a1877a
parent 474502 db45f0c580bb9c8f84d1ef46281e842903d06c4f
child 474504 b7e30b4bf3f9f3d19abd1b2bfd7dc9d7f7aac1f1
push id36041
push userccoroiu@mozilla.com
push dateMon, 20 May 2019 21:55:28 +0000
treeherdermozilla-central@29bdbbe89264 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1551501
milestone68.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 1551501 - Fix BinASTTokenReaderContext::readVarU32 to match encoder. r=Yoric Differential Revision: https://phabricator.services.mozilla.com/D31054
js/src/frontend/BinASTTokenReaderContext.cpp
--- a/js/src/frontend/BinASTTokenReaderContext.cpp
+++ b/js/src/frontend/BinASTTokenReaderContext.cpp
@@ -160,36 +160,37 @@ BinASTTokenReaderContext::AutoList::Auto
 
 void BinASTTokenReaderContext::AutoList::init() { AutoBase::init(); }
 
 JS::Result<Ok> BinASTTokenReaderContext::AutoList::done() {
   return reader_.raiseError("Not Yet Implemented");
 }
 
 // Internal uint32_t
+// Note that this is different than varnum in multipart.
 //
 // Encoded as variable length number.
 
 MOZ_MUST_USE JS::Result<uint32_t> BinASTTokenReaderContext::readVarU32() {
   uint32_t result = 0;
   uint32_t shift = 0;
   while (true) {
     MOZ_ASSERT(shift < 32);
     uint32_t byte;
     MOZ_TRY_VAR(byte, readByte());
 
-    const uint32_t newResult = result | (byte >> 1) << shift;
+    const uint32_t newResult = result | (byte & 0x7f) << shift;
     if (newResult < result) {
       return raiseError("Overflow during readVarU32");
     }
 
     result = newResult;
     shift += 7;
 
-    if ((byte & 1) == 0) {
+    if ((byte & 0x80) == 0) {
       return result;
     }
 
     if (shift >= 32) {
       return raiseError("Overflow during readVarU32");
     }
   }
 }