Bug 1424368: Use an enum value for invalid WasmToken::Kind; r=luke
author<benj@benj.me>
Wed, 13 Dec 2017 02:41:55 +0000
changeset 396253 a5c733e0b6d18d8516b3711fe3060a212d4c8787
parent 396252 12c2e518c50d42afc5357f9dd0aed9ef181c543e
child 396254 cc95b6d1680b26b327c7c430082eb6bc45982d18
push id56959
push userbbouvier@mozilla.com
push dateWed, 13 Dec 2017 22:49:42 +0000
treeherderautoland@a5c733e0b6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1424368
milestone59.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 1424368: Use an enum value for invalid WasmToken::Kind; r=luke MozReview-Commit-ID: 8zfpuEMkzLU
js/src/wasm/WasmTextToBinary.cpp
--- a/js/src/wasm/WasmTextToBinary.cpp
+++ b/js/src/wasm/WasmTextToBinary.cpp
@@ -127,44 +127,46 @@ class WasmToken
         Text,
         Then,
         Type,
         UnaryOpcode,
         Unreachable,
         UnsignedInteger,
         ValueType,
         Wait,
-        Wake
+        Wake,
+        Invalid
     };
   private:
     Kind kind_;
     const char16_t* begin_;
     const char16_t* end_;
     union {
         uint32_t index_;
         uint64_t uint_;
         int64_t sint_;
         FloatLiteralKind floatLiteralKind_;
         ValType valueType_;
         Op op_;
         ThreadOp threadOp_;
     } u;
   public:
     WasmToken()
-      : kind_(Kind(-1)),
+      : kind_(Kind::Invalid),
         begin_(nullptr),
         end_(nullptr),
         u()
     { }
     WasmToken(Kind kind, const char16_t* begin, const char16_t* end)
       : kind_(kind),
         begin_(begin),
         end_(end)
     {
         MOZ_ASSERT(kind_ != Error);
+        MOZ_ASSERT(kind_ != Invalid);
         MOZ_ASSERT((kind == EndOfFile) == (begin == end));
     }
     explicit WasmToken(uint32_t index, const char16_t* begin, const char16_t* end)
       : kind_(Index),
         begin_(begin),
         end_(end)
     {
         MOZ_ASSERT(begin != end);
@@ -226,17 +228,17 @@ class WasmToken
         u.threadOp_ = op;
     }
     explicit WasmToken(const char16_t* begin)
       : kind_(Error),
         begin_(begin),
         end_(begin)
     {}
     Kind kind() const {
-        MOZ_ASSERT(kind_ != Kind(-1));
+        MOZ_ASSERT(kind_ != Kind::Invalid);
         return kind_;
     }
     const char16_t* begin() const {
         return begin_;
     }
     const char16_t* end() const {
         return end_;
     }
@@ -348,16 +350,18 @@ class WasmToken
           case Start:
           case Table:
           case Text:
           case Then:
           case Type:
           case UnsignedInteger:
           case ValueType:
             return false;
+          case Invalid:
+            break;
         }
         MOZ_CRASH("unexpected token kind");
     }
 };
 
 struct InlineImport
 {
     WasmToken module;