Bug 1383157 - change pn_type to a ParseNodeKind; r?jimb draft
authorTom Tromey <tom@tromey.com>
Fri, 21 Jul 2017 11:07:54 -0600
changeset 614517 a4a5d65f4e5d6f8a72cad91c6e5b61b0ef1d7962
parent 613211 f1de1df4ac3d2ee6b0d59a523b1d90570de622f4
child 638885 5c5adca233eae63290a89d46c37a17d41d598586
push id70034
push userbmo:ttromey@mozilla.com
push dateMon, 24 Jul 2017 17:45:31 +0000
reviewersjimb
bugs1383157
milestone56.0a1
Bug 1383157 - change pn_type to a ParseNodeKind; r?jimb MozReview-Commit-ID: 3woMGwYs3wY
js/src/frontend/ParseNode.h
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -174,17 +174,17 @@ class ObjectBox;
  * not a concrete syntax tree in all respects (for example, || and && are left
  * associative, but (A && B && C) translates into the right-associated tree
  * <A && <B && C>> so that code generation can emit a left-associative branch
  * around <B && C> when A is false).  Nodes are labeled by kind, with a
  * secondary JSOp label when needed.
  *
  * The long comment after this enum block describes the kinds in detail.
  */
-enum ParseNodeKind
+enum ParseNodeKind : uint16_t
 {
 #define EMIT_ENUM(name) PNK_##name,
     FOR_EACH_PARSE_NODE_KIND(EMIT_ENUM)
 #undef EMIT_ENUM
     PNK_LIMIT, /* domain size */
     PNK_BINOP_FIRST = PNK_OR,
     PNK_BINOP_LAST = PNK_POW,
     PNK_ASSIGNMENT_START = PNK_ASSIGN,
@@ -445,17 +445,21 @@ enum ParseNodeArity
 class LoopControlStatement;
 class BreakStatement;
 class ContinueStatement;
 class ConditionalExpression;
 class PropertyAccess;
 
 class ParseNode
 {
-    uint16_t pn_type;   /* PNK_* type */
+    ParseNodeKind pn_type;   /* PNK_* type */
+    // pn_op and pn_arity are not declared as the correct enum types
+    // due to difficulties with MS bitfield layout rules and a GCC
+    // bug.  See https://bugzilla.mozilla.org/show_bug.cgi?id=1383157#c4 for
+    // details.
     uint8_t pn_op;      /* see JSOp enum and jsopcode.tbl */
     uint8_t pn_arity:4; /* see ParseNodeArity enum */
     bool pn_parens:1;   /* this expr was enclosed in parens */
     bool pn_rhs_anon_fun:1;  /* this expr is anonymous function or class that
                               * is a direct RHS of PNK_ASSIGN or PNK_COLON of
                               * property, that needs SetFunctionName. */
 
     ParseNode(const ParseNode& other) = delete;
@@ -489,17 +493,17 @@ class ParseNode
     }
 
     JSOp getOp() const                     { return JSOp(pn_op); }
     void setOp(JSOp op)                    { pn_op = op; }
     bool isOp(JSOp op) const               { return getOp() == op; }
 
     ParseNodeKind getKind() const {
         MOZ_ASSERT(pn_type < PNK_LIMIT);
-        return ParseNodeKind(pn_type);
+        return pn_type;
     }
     void setKind(ParseNodeKind kind) {
         MOZ_ASSERT(kind < PNK_LIMIT);
         pn_type = kind;
     }
     bool isKind(ParseNodeKind kind) const  { return getKind() == kind; }
 
     ParseNodeArity getArity() const        { return ParseNodeArity(pn_arity); }