Bug 1336783 - followup: Fix rooting. r=bustage
authorTooru Fujisawa <arai_a@mac.com>
Thu, 16 Feb 2017 01:39:41 +0900
changeset 343110 2810dbb5675c94ba4b2f0dd5fc92504d1dfecb96
parent 343109 d50d32601e7f7a78163fab0f99bfe3335f659e02
child 343111 7ecbacf4e84c972da2977dbc3eb924297dd0b636
push id31369
push userkwierso@gmail.com
push dateThu, 16 Feb 2017 00:18:40 +0000
treeherdermozilla-central@e9b926463f9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1336783
milestone54.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 1336783 - followup: Fix rooting. r=bustage
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -8562,122 +8562,128 @@ Parser<ParseHandler>::newName(PropertyNa
 template <typename ParseHandler>
 typename ParseHandler::Node
 Parser<ParseHandler>::newName(PropertyName* name, TokenPos pos)
 {
     return handler.newName(name, pos, context);
 }
 
 template <typename ParseHandler>
-PropertyName*
-Parser<ParseHandler>::checkLabelOrIdentifierReference(PropertyName* ident,
+bool
+Parser<ParseHandler>::checkLabelOrIdentifierReference(HandlePropertyName ident,
                                                       uint32_t offset,
                                                       YieldHandling yieldHandling)
 {
     if (ident == context->names().yield) {
         if (yieldHandling == YieldIsKeyword ||
             versionNumber() >= JSVERSION_1_7)
         {
             errorAt(offset, JSMSG_RESERVED_ID, "yield");
-            return nullptr;
+            return false;
         }
         if (pc->sc()->needStrictChecks()) {
             if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "yield"))
-                return nullptr;
-        }
-
-        return ident;
+                return false;
+        }
+
+        return true;
     }
 
     if (ident == context->names().await) {
         if (awaitIsKeyword()) {
             errorAt(offset, JSMSG_RESERVED_ID, "await");
-            return nullptr;
-        }
-        return ident;
+            return false;
+        }
+        return true;
     }
 
     if (IsKeyword(ident) || IsReservedWordLiteral(ident)) {
         errorAt(offset, JSMSG_INVALID_ID, ReservedWordToCharZ(ident));
-        return nullptr;
+        return false;
     }
 
     if (IsFutureReservedWord(ident)) {
         errorAt(offset, JSMSG_RESERVED_ID, ReservedWordToCharZ(ident));
-        return nullptr;
+        return false;
     }
 
     if (pc->sc()->needStrictChecks()) {
         if (IsStrictReservedWord(ident)) {
             if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, ReservedWordToCharZ(ident)))
-                return nullptr;
-            return ident;
+                return false;
+            return true;
         }
 
         if (ident == context->names().let) {
             if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "let"))
-                return nullptr;
-            return ident;
+                return false;
+            return true;
         }
 
         if (ident == context->names().static_) {
             if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "static"))
-                return nullptr;
-            return ident;
-        }
-    }
-
-    return ident;
-}
-
-template <typename ParseHandler>
-PropertyName*
-Parser<ParseHandler>::checkBindingIdentifier(PropertyName* ident,
+                return false;
+            return true;
+        }
+    }
+
+    return true;
+}
+
+template <typename ParseHandler>
+bool
+Parser<ParseHandler>::checkBindingIdentifier(HandlePropertyName ident,
                                              uint32_t offset,
                                              YieldHandling yieldHandling)
 {
     if (!checkLabelOrIdentifierReference(ident, offset, yieldHandling))
-        return nullptr;
+        return false;
 
     if (pc->sc()->needStrictChecks()) {
         if (ident == context->names().arguments) {
             if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "arguments"))
-                return nullptr;
-            return ident;
+                return false;
+            return true;
         }
 
         if (ident == context->names().eval) {
             if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "eval"))
-                return nullptr;
-            return ident;
-        }
-    }
-
-    return ident;
+                return false;
+            return true;
+        }
+    }
+
+    return true;
 }
 
 template <typename ParseHandler>
 PropertyName*
 Parser<ParseHandler>::labelOrIdentifierReference(YieldHandling yieldHandling)
 {
     // ES 2017 draft 12.1.1.
     //   StringValue of IdentifierName normalizes any Unicode escape sequences
     //   in IdentifierName hence such escapes cannot be used to write an
     //   Identifier whose code point sequence is the same as a ReservedWord.
     //
     // Use PropertyName* instead of TokenKind to reflect the normalization.
 
-    return checkLabelOrIdentifierReference(tokenStream.currentName(), pos().begin, yieldHandling);
+    RootedPropertyName ident(context, tokenStream.currentName());
+    if (!checkLabelOrIdentifierReference(ident, pos().begin, yieldHandling))
+        return nullptr;
+    return ident;
 }
 
 template <typename ParseHandler>
 PropertyName*
 Parser<ParseHandler>::bindingIdentifier(YieldHandling yieldHandling)
 {
-    return checkBindingIdentifier(tokenStream.currentName(), pos().begin, yieldHandling);
+    RootedPropertyName ident(context, tokenStream.currentName());
+    if (!checkBindingIdentifier(ident, pos().begin, yieldHandling))
+        return nullptr;
+    return ident;
 }
 
 template <typename ParseHandler>
 typename ParseHandler::Node
 Parser<ParseHandler>::identifierReference(Handle<PropertyName*> name)
 {
     Node pn = newName(name);
     if (!pn)
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -1324,24 +1324,24 @@ class Parser final : public ParserBase, 
     bool namedImportsOrNamespaceImport(TokenKind tt, Node importSpecSet);
     bool checkExportedName(JSAtom* exportName);
     bool checkExportedNamesForDeclaration(Node node);
 
     enum ClassContext { ClassStatement, ClassExpression };
     Node classDefinition(YieldHandling yieldHandling, ClassContext classContext,
                          DefaultHandling defaultHandling);
 
-    PropertyName* checkLabelOrIdentifierReference(PropertyName* ident,
-                                                  uint32_t offset,
-                                                  YieldHandling yieldHandling);
-
-    PropertyName* checkBindingIdentifier(PropertyName* ident,
+    bool checkLabelOrIdentifierReference(HandlePropertyName ident,
                                          uint32_t offset,
                                          YieldHandling yieldHandling);
 
+    bool checkBindingIdentifier(HandlePropertyName ident,
+                                uint32_t offset,
+                                YieldHandling yieldHandling);
+
     PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling);
 
     PropertyName* labelIdentifier(YieldHandling yieldHandling) {
         return labelOrIdentifierReference(yieldHandling);
     }
 
     PropertyName* identifierReference(YieldHandling yieldHandling) {
         return labelOrIdentifierReference(yieldHandling);