Bug 838813 part 3 - Remove SRC_DECL. r=njn.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 08 Feb 2013 16:11:51 -0600
changeset 131291 a09cbd4863fdde8c1a3f0dd63c6ca534e27e537c
parent 131290 cb6e7fd832a652bbcca1951ca140d87511f8be2f
child 131292 23e605cc03244b214c8f79abfc2486d0bdf20f3b
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs838813
milestone21.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 838813 part 3 - Remove SRC_DECL. r=njn.
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/BytecodeEmitter.h
js/src/jsopcode.cpp
js/src/shell/js.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -3168,17 +3168,16 @@ EmitVariables(JSContext *cx, BytecodeEmi
               LetNotes *letNotes = NULL)
 {
     JS_ASSERT(pn->isArity(PN_LIST));
     JS_ASSERT(!!letNotes == (emitOption == PushInitialValues));
 
     ptrdiff_t off = -1, noteIndex = -1;
     ParseNode *next;
     for (ParseNode *pn2 = pn->pn_head; ; pn2 = next) {
-        bool first = pn2 == pn->pn_head;
         next = pn2->pn_next;
 
         ParseNode *pn3;
         if (!pn2->isKind(PNK_NAME)) {
 #if JS_HAS_DESTRUCTURING
             if (pn2->isKind(PNK_ARRAY) || pn2->isKind(PNK_OBJECT)) {
                 /*
                  * Emit variable binding ops, but not destructuring ops.  The
@@ -3329,24 +3328,16 @@ EmitVariables(JSContext *cx, BytecodeEmi
         /* If we are not initializing, nothing to pop. */
         if (emitOption != InitializeVars) {
             if (next)
                 continue;
             break;
         }
 
         JS_ASSERT_IF(pn2->isDefn(), pn3 == pn2->pn_expr);
-        if (first && NewSrcNote2(cx, bce, SRC_DECL,
-                                 (pn->isOp(JSOP_DEFCONST))
-                                 ? SRC_DECL_CONST
-                                 : (pn->isOp(JSOP_DEFVAR))
-                                 ? SRC_DECL_VAR
-                                 : SRC_DECL_LET) < 0) {
-            return false;
-        }
         if (!pn2->pn_cookie.isFree()) {
             if (!EmitVarOp(cx, pn2, op, bce))
                 return false;
         } else {
             if (!EmitIndexOp(cx, op, atomIndex, bce))
                 return false;
         }
 
@@ -4159,31 +4150,29 @@ EmitIf(JSContext *cx, BytecodeEmitter *b
  *  evaluate b        +1
  *  dup               +1          SRC_DESTRUCTLET + offset to enterlet0
  *  destructure y
  *  pick 1
  *  dup               +1          SRC_DESTRUCTLET + offset to enterlet0
  *  destructure z
  *  pick 1
  *  pop               -1
- *  enterlet0                     SRC_DECL + offset to leaveblockexpr
+ *  enterlet0
  *  evaluate e        +1
  *  leaveblockexpr    -3          SRC_PCBASE + offset to evaluate a
  *
  * Note that, since enterlet0 simply changes fp->blockChain and does not
  * otherwise touch the stack, evaluation of the let-var initializers must leave
  * the initial value in the let-var's future slot.
  *
  * The SRC_DESTRUCTLET distinguish JSOP_DUP as the beginning of a destructuring
  * let initialization and the offset allows the decompiler to find the block
  * object from which to find let var names. These forward offsets require
  * backpatching, which is handled by LetNotes.
  *
- * The SRC_DECL offset allows recursive decompilation of 'e'.
- *
  * The SRC_PCBASE allows js_DecompileValueGenerator to walk backwards from
  * JSOP_LEAVEBLOCKEXPR to the beginning of the let and is only needed for
  * let-expressions.
  */
 /*
  * Using MOZ_NEVER_INLINE in here is a workaround for llvm.org/pr14047. See
  * the comment on EmitSwitch.
  */
@@ -4216,20 +4205,16 @@ EmitLet(JSContext *cx, BytecodeEmitter *
     }
 
     StmtInfoBCE stmtInfo(cx);
     PushBlockScopeBCE(bce, &stmtInfo, *blockObj, bce->offset());
 
     if (!letNotes.update(cx, bce, bce->offset()))
         return false;
 
-    ptrdiff_t declNote = NewSrcNote(cx, bce, SRC_DECL);
-    if (declNote < 0)
-        return false;
-
     ptrdiff_t bodyBegin = bce->offset();
     if (!EmitEnterBlock(cx, bce, letBody, JSOP_ENTERLET0))
         return false;
 
     if (!EmitTree(cx, bce, letBody->pn_expr))
         return false;
 
     JSOp leaveOp = letBody->getOp();
@@ -4239,23 +4224,17 @@ EmitLet(JSContext *cx, BytecodeEmitter *
     }
 
     JS_ASSERT(leaveOp == JSOP_LEAVEBLOCK || leaveOp == JSOP_LEAVEBLOCKEXPR);
     EMIT_UINT16_IMM_OP(leaveOp, blockObj->slotCount());
 
     ptrdiff_t bodyEnd = bce->offset();
     JS_ASSERT(bodyEnd > bodyBegin);
 
-    if (!PopStatementBCE(cx, bce))
-        return false;
-
-    ptrdiff_t o = PackLetData((bodyEnd - bodyBegin) -
-                              (JSOP_ENTERLET0_LENGTH + JSOP_LEAVEBLOCK_LENGTH),
-                              letNotes.isGroupAssign());
-    return SetSrcNoteOffset(cx, bce, declNote, 0, o);
+    return PopStatementBCE(cx, bce);
 }
 #endif
 
 /*
  * Using MOZ_NEVER_INLINE in here is a workaround for llvm.org/pr14047. See
  * the comment on EmitSwitch.
  */
 MOZ_NEVER_INLINE static bool
@@ -4434,22 +4413,16 @@ EmitForIn(JSContext *cx, BytecodeEmitter
      * 'for (var x in y)'.
      */
     if (Emit1(cx, bce, JSOP_ITERNEXT) < 0)
         return false;
     if (!EmitAssignment(cx, bce, forHead->pn_kid2, JSOP_NOP, NULL))
         return false;
 
     ptrdiff_t tmp2 = bce->offset();
-    if (forHead->pn_kid1 && NewSrcNote2(cx, bce, SRC_DECL,
-                                        (forHead->pn_kid1->isOp(JSOP_DEFVAR))
-                                        ? SRC_DECL_VAR
-                                        : SRC_DECL_LET) < 0) {
-        return false;
-    }
     if (Emit1(cx, bce, JSOP_POP) < 0)
         return false;
 
     /* The stack should be balanced around the assignment opcode sequence. */
     JS_ASSERT(bce->stackDepth == loopDepth);
 
     /* Emit code for the loop body. */
     if (!EmitTree(cx, bce, forBody))
@@ -6669,17 +6642,17 @@ CGConstList::finish(ConstArray *array)
     JS_ASSERT(length() == array->length);
 
     for (unsigned i = 0; i < length(); i++)
         array->vector[i] = list[i];
 }
 
 /*
  * We should try to get rid of offsetBias (always 0 or 1, where 1 is
- * JSOP_{NOP,POP}_LENGTH), which is used only by SRC_FOR and SRC_DECL.
+ * JSOP_{NOP,POP}_LENGTH), which is used only by SRC_FOR.
  */
 JS_FRIEND_DATA(JSSrcNoteSpec) js_SrcNoteSpec[] = {
     {"null",            0},
     {"if",              0},
     {"if-else",         2},
     {"for",             3},
     {"while",           1},
     {"continue",        0},
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -266,17 +266,16 @@ enum SrcNoteType {
     SRC_WHILE       = 4,        /* JSOP_GOTO to for or while loop condition
                                    from before loop, else JSOP_NOP at top of
                                    do-while loop */
     SRC_CONTINUE    = 5,        /* JSOP_GOTO is a continue, not a break;
                                    JSOP_ENDINIT needs extra comma at end of
                                    array literal: [1,2,,];
                                    JSOP_DUP continuing destructuring pattern;
                                    JSOP_POP at end of for-in */
-    SRC_DECL        = 6,        /* type of a declaration (var, const, let*) */
     SRC_DESTRUCT    = 6,        /* JSOP_DUP starting a destructuring assignment
                                    operation, with SRC_DECL_* offset operand */
     SRC_PCDELTA     = 7,        /* distance forward from comma-operator to
                                    next POP, or from CONDSWITCH to first CASE
                                    opcode, etc. -- always a forward delta */
     SRC_GROUPASSIGN = 7,        /* SRC_DESTRUCT variant for [a, b] = [c, d] */
     SRC_DESTRUCTLET = 7,        /* JSOP_DUP starting a destructuring let
                                    operation, with offset to JSOP_ENTERLET0 */
@@ -300,17 +299,17 @@ enum SrcNoteType {
     SRC_CATCH       = 20,       /* catch block has guard */
     SRC_COLSPAN     = 21,       /* number of columns this opcode spans */
     SRC_NEWLINE     = 22,       /* bytecode follows a source newline */
     SRC_SETLINE     = 23,       /* a file-absolute source line number note */
     SRC_XDELTA      = 24        /* 24-31 are for extended delta notes */
 };
 
 /*
- * Constants for the SRC_DECL source note.
+ * Constants for the SRC_DESTRUCTLET source note.
  *
  * NB: the var_prefix array in jsopcode.c depends on these dense indexes from
  * SRC_DECL_VAR through SRC_DECL_LET.
  */
 #define SRC_DECL_VAR            0
 #define SRC_DECL_CONST          1
 #define SRC_DECL_LET            2
 #define SRC_DECL_NONE           3
@@ -431,38 +430,16 @@ BytecodeEmitter::countFinalSourceNotes()
                     : SN_DELTA_MASK - (*sn & SN_DELTA_MASK);
         }
         if (diff > 0)
             cnt += JS_HOWMANY(diff, SN_XDELTA_MASK);
     }
     return cnt;
 }
 
-/*
- * To avoid offending js_SrcNoteSpec[SRC_DECL].arity, pack the two data needed
- * to decompile let into one ptrdiff_t:
- *   offset: offset to the LEAVEBLOCK(EXPR) op (not including ENTER/LEAVE)
- *   groupAssign: whether this was an optimized group assign ([x,y] = [a,b])
- */
-inline ptrdiff_t PackLetData(size_t offset, bool groupAssign)
-{
-    JS_ASSERT(offset <= (size_t(-1) >> 1));
-    return ptrdiff_t(offset << 1) | ptrdiff_t(groupAssign);
-}
-
-inline size_t LetDataToOffset(ptrdiff_t w)
-{
-    return size_t(w) >> 1;
-}
-
-inline bool LetDataToGroupAssign(ptrdiff_t w)
-{
-    return size_t(w) & 1;
-}
-
 } /* namespace frontend */
 } /* namespace js */
 
 struct JSSrcNoteSpec {
     const char      *name;      /* name for disassembly/debugging output */
     int8_t          arity;      /* number of offset operands */
 };
 
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -51,18 +51,16 @@
 #include "jsautooplen.h"
 
 #include "vm/RegExpObject-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
 using js::frontend::IsIdentifier;
-using js::frontend::LetDataToGroupAssign;
-using js::frontend::LetDataToOffset;
 using mozilla::ArrayLength;
 
 /*
  * Index limit must stay within 32 bits.
  */
 JS_STATIC_ASSERT(sizeof(uint32_t) * JS_BITS_PER_BYTE >= INDEX_LIMIT_LOG2 + 1);
 
 /* Verify JSOP_XXX_LENGTH constant definitions. */
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1748,17 +1748,16 @@ SrcNotes(JSContext *cx, HandleScript scr
             Sprint(sp, " else %u elseif %u",
                    unsigned(js_GetSrcNoteOffset(sn, 0)),
                    unsigned(js_GetSrcNoteOffset(sn, 1)));
             break;
           case SRC_COND:
           case SRC_WHILE:
           case SRC_PCBASE:
           case SRC_PCDELTA:
-          case SRC_DECL:
           case SRC_BRACE:
             Sprint(sp, " offset %u", unsigned(js_GetSrcNoteOffset(sn, 0)));
             break;
           case SRC_LABEL:
           case SRC_LABELBRACE:
           case SRC_BREAK2LABEL:
           case SRC_CONT2LABEL: {
             uint32_t index = js_GetSrcNoteOffset(sn, 0);