Bug 795768 (part 2) - De-macroize js_GetSrcNote().
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 30 Sep 2012 21:18:07 -0700
changeset 108975 c92d00f777de3dd12fefbdd31788a90479bfd966
parent 108974 9c656027f5c27fdcfaf9a1099206dd5d36c80012
child 108976 42a7cb309ca13cfc55d1082e0cddf2fa563fdbe2
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
bugs795768
milestone18.0a1
Bug 795768 (part 2) - De-macroize js_GetSrcNote().
js/src/ion/CompileInfo.h
js/src/jsopcode.cpp
js/src/jsscript.cpp
js/src/jsscript.h
--- a/js/src/ion/CompileInfo.h
+++ b/js/src/ion/CompileInfo.h
@@ -79,17 +79,17 @@ class CompileInfo
     }
     JSFunction *getFunction(jsbytecode *pc) const {
         return script_->getFunction(GET_UINT32_INDEX(pc));
     }
     const Value &getConst(jsbytecode *pc) const {
         return script_->getConst(GET_UINT32_INDEX(pc));
     }
     jssrcnote *getNote(JSContext *cx, jsbytecode *pc) const {
-        return js_GetSrcNoteCached(cx, script(), pc);
+        return js_GetSrcNote(cx, script(), pc);
     }
 
     // Total number of slots: args, locals, and stack.
     unsigned nslots() const {
         return nslots_;
     }
 
     unsigned nargs() const {
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -2130,17 +2130,17 @@ DecompileDestructuring(SprintStack *ss, 
 
           case JSOP_DOUBLE:
             d = jp->script->getConst(GET_UINT32_INDEX(pc)).toDouble();
             LOCAL_ASSERT(MOZ_DOUBLE_IS_FINITE(d) && !MOZ_DOUBLE_IS_NEGATIVE_ZERO(d));
             i = (int)d;
 
           do_getelem:
           {
-            jssrcnote *sn = js_GetSrcNote(jp->script, pc);
+            jssrcnote *sn = js_GetSrcNote(cx, jp->script, pc);
             pc += oplen;
             if (pc == endpc)
                 return pc;
             LOAD_OP_DATA(pc);
             LOCAL_ASSERT(op == JSOP_GETELEM);
 
             /* Distinguish object from array by opcode or source note. */
             if (sn && SN_TYPE(sn) == SRC_INITPROP) {
@@ -2230,17 +2230,17 @@ DecompileDestructuring(SprintStack *ss, 
         /*
          * We should stop if JSOP_DUP is either without notes or its note is
          * not SRC_CONTINUE. The former happens when JSOP_DUP duplicates the
          * last destructuring reference implementing an op= assignment like in
          * '([t] = z).y += x'. In the latter case the note is SRC_DESTRUCT and
          * means another destructuring initialiser abuts this one like in
          * '[a] = [b] = c'.
          */
-        jssrcnote *sn = js_GetSrcNote(jp->script, pc);
+        jssrcnote *sn = js_GetSrcNote(cx, jp->script, pc);
         if (!sn)
             break;
         if (SN_TYPE(sn) != SRC_CONTINUE) {
             LOCAL_ASSERT(SN_TYPE(sn) == SRC_DESTRUCT || SN_TYPE(sn) == SRC_DESTRUCTLET);
             break;
         }
 
         if (!hole && ss->sprinter.put(", ", 2) < 0)
@@ -2438,17 +2438,17 @@ GetTokenForAssignment(JSPrinter *jp, jss
     return token;
 }
 
 static ptrdiff_t
 SprintNormalFor(JSContext *cx, JSPrinter *jp, SprintStack *ss, const char *initPrefix,
                 const char *init, jsbytecode *initpc, jsbytecode **ppc, ptrdiff_t *plen)
 {
     jsbytecode *pc = *ppc;
-    jssrcnote *sn = js_GetSrcNote(jp->script, pc);
+    jssrcnote *sn = js_GetSrcNote(cx, jp->script, pc);
     JS_ASSERT(SN_TYPE(sn) == SRC_FOR);
 
     /* Print the keyword and the possibly empty init-part. */
     js_printf(jp, "\tfor (%s", initPrefix);
     SprintOpcodePermanent(jp, init, initpc);
     js_printf(jp, ";");
 
     /* Skip the JSOP_NOP or JSOP_POP bytecode. */
@@ -2805,17 +2805,17 @@ Decompile(SprintStack *ss, jsbytecode *p
             jp->dvgfence = NULL;
         }
 
         jsbytecode *pushpc = pc;
 
         if (token) {
             switch (nuses) {
               case 2:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 if (sn && SN_TYPE(sn) == SRC_ASSIGNOP) {
                     /*
                      * Avoid over-parenthesizing y in x op= y based on its
                      * expansion: x = x op y (replace y by z = w to see the
                      * problem).
                      */
                     op = (JSOp) pc[oplen];
                     rval = PopStr(ss, op, &lastrvalpc);
@@ -2841,17 +2841,17 @@ Decompile(SprintStack *ss, jsbytecode *p
 
               case 1:
                 rval = PopStrDupe(ss, op, &rvalpc);
                 todo = ss->sprinter.put(token);
                 SprintOpcode(ss, rval, rvalpc, pc, todo);
                 break;
 
               case 0:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 if (sn && SN_TYPE(sn) == SRC_CONTINUE) {
                     /* Hoisted let decl (e.g. 'y' in 'let (x) { let y; }'). */
                     todo = ss->sprinter.put(SkipString);
                     break;
                 }
                 todo = ss->sprinter.put(token);
                 break;
 
@@ -2862,24 +2862,24 @@ Decompile(SprintStack *ss, jsbytecode *p
         } else {
             switch (op) {
               case JSOP_NOP:
                 /*
                  * Check for a do-while loop, a for-loop with an empty
                  * initializer part, a labeled statement, a function
                  * definition, or try/finally.
                  */
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 todo = -2;
                 switch (sn ? SN_TYPE(sn) : SRC_NULL) {
                   case SRC_WHILE:
                     /* First instuction (NOP) contains offset to condition */
                     ++pc;
                     /* Second instruction (TRACE) contains offset to JSOP_IFNE */
-                    sn = js_GetSrcNote(jp->script, pc);
+                    sn = js_GetSrcNote(cx, jp->script, pc);
                     tail = js_GetSrcNoteOffset(sn, 0);
                     LOCAL_ASSERT(pc[tail] == JSOP_IFNE);
                     js_printf(jp, "\tdo {\n");
                     jp->indent += 4;
                     DECOMPILE_CODE(pc, tail);
                     jp->indent -= 4;
                     js_printf(jp, "\t} while (");
                     rval = PopCondStr(ss, &rvalpc);
@@ -2927,17 +2927,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                     js_printf(jp, "\t}\n");
                     break;
 
                   default:;
                 }
                 break;
 
               case JSOP_LABEL:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 todo = -2;
                 switch (sn ? SN_TYPE(sn) : SRC_NULL) {
                   case SRC_LABEL:
                     GET_SOURCE_NOTE_ATOM(sn, atom);
                     jp->indent -= 4;
                     rval = QuoteString(&ss->sprinter, atom, 0);
                     if (!rval)
                         return NULL;
@@ -3016,17 +3016,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                  * The decompiler must match the code generator's model, which
                  * is why JSOP_FINALLY pushes a cookie that JSOP_RETSUB pops.
                  */
                 oldtop = ss->top;
                 newtop = oldtop - GET_UINT16(pc);
                 LOCAL_ASSERT(newtop <= oldtop);
                 todo = -2;
 
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 if (sn && SN_TYPE(sn) == SRC_HIDDEN)
                     break;
 #if JS_HAS_DESTRUCTURING
                 if (sn && SN_TYPE(sn) == SRC_GROUPASSIGN) {
                     todo = Sprint(&ss->sprinter, "%s[] = [",
                                   VarPrefix(sn));
                     if (todo < 0)
                         return NULL;
@@ -3075,17 +3075,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                      * Sprinter::put.
                      */
                     rval = ss->sprinter.stringAt(todo);
                     rvalpc = NULL;
                     todo = -2;
                     pc2 = pc + oplen;
 
                     if (*pc2 == JSOP_NOP) {
-                        sn = js_GetSrcNote(jp->script, pc2);
+                        sn = js_GetSrcNote(cx, jp->script, pc2);
                         if (sn) {
                             if (SN_TYPE(sn) == SRC_FOR) {
                                 op = JSOP_NOP;
                                 pc = pc2;
                                 todo = SprintNormalFor(cx, jp, ss, "", rval, rvalpc, &pc, &len);
                                 break;
                             }
                         } else {
@@ -3131,17 +3131,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                  * a stacked expression decompilation.  We auto-parenthesize
                  * only when JSOP_POP is annotated with SRC_PCDELTA, meaning
                  * comma operator.
                  */
                 op = JSOP_POPV;
                 /* FALL THROUGH */
 
               case JSOP_POPV:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 switch (sn ? SN_TYPE(sn) : SRC_NULL) {
                   case SRC_FOR:
                     /* Force parens around 'in' expression at 'for' front. */
                     if (ss->opcodes[ss->top-1] == JSOP_IN)
                         op = JSOP_LSH;
                     rval = PopStr(ss, op, &rvalpc);
                     todo = SprintNormalFor(cx, jp, ss, "", rval, rvalpc, &pc, &len);
                     break;
@@ -3234,27 +3234,27 @@ Decompile(SprintStack *ss, jsbytecode *p
                         i * sizeof(ss->opcodes[0]));
                 ss->opcodes[ss->top - 1] = pickedOpcode;
 
                 todo = -2;
                 break;
               }
 
               case JSOP_ENTERWITH:
-                LOCAL_ASSERT(!js_GetSrcNote(jp->script, pc));
+                LOCAL_ASSERT(!js_GetSrcNote(cx, jp->script, pc));
                 rval = PopStr(ss, op, &rvalpc);
                 js_printf(jp, "\twith (");
                 SprintOpcodePermanent(jp, rval, rvalpc);
                 js_printf(jp, ") {\n");
                 jp->indent += 4;
                 todo = Sprint(&ss->sprinter, with_cookie);
                 break;
 
               case JSOP_LEAVEWITH:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 todo = -2;
                 if (sn && SN_TYPE(sn) == SRC_HIDDEN)
                     break;
                 rval = POP_STR();
                 LOCAL_ASSERT(strcmp(rval, with_cookie) == 0);
                 jp->indent -= 4;
                 js_printf(jp, "\t}\n");
                 break;
@@ -3263,17 +3263,17 @@ Decompile(SprintStack *ss, jsbytecode *p
               {
                 obj = jp->script->getObject(GET_UINT32_INDEX(pc));
                 AtomVector atoms(cx);
                 StaticBlockObject &blockObj = obj->asStaticBlock();
 
                 if (!GetBlockNames(cx, blockObj, &atoms) || !PushBlockNames(ss, atoms))
                     return NULL;
 
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 switch (sn ? SN_TYPE(sn) : SRC_NULL) {
 #if JS_HAS_BLOCK_SCOPE
                   case SRC_BRACE:
                     js_printf(jp, "\t{\n");
                     jp->indent += 4;
                     len = js_GetSrcNoteOffset(sn, 0);
                     if (!Decompile(ss, pc + oplen, len - oplen))
                         return NULL;
@@ -3290,17 +3290,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                     pc += oplen;
                     LOCAL_ASSERT(*pc == JSOP_EXCEPTION);
                     pc += JSOP_EXCEPTION_LENGTH;
                     todo = Sprint(&ss->sprinter, exception_cookie);
                     if (todo < 0 || !PushOff(ss, todo, JSOP_EXCEPTION))
                         return NULL;
 
                     if (*pc == JSOP_DUP) {
-                        sn2 = js_GetSrcNote(jp->script, pc);
+                        sn2 = js_GetSrcNote(cx, jp->script, pc);
                         if (!sn2 || SN_TYPE(sn2) != SRC_DESTRUCT) {
                             /*
                              * This is a dup to save the exception for later.
                              * It is emitted only when the catch head contains
                              * an exception guard.
                              */
                             LOCAL_ASSERT(js_GetSrcNoteOffset(sn, 0) != 0);
                             pc += JSOP_DUP_LENGTH;
@@ -3363,17 +3363,17 @@ Decompile(SprintStack *ss, jsbytecode *p
               }
               break;
 
               case JSOP_LEAVEBLOCK:
               case JSOP_LEAVEBLOCKEXPR:
               {
                 unsigned top, depth;
 
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 todo = -2;
                 if (op == JSOP_LEAVEBLOCKEXPR) {
                     LOCAL_ASSERT(SN_TYPE(sn) == SRC_PCBASE);
                     rval = POP_STR();
                 } else if (sn) {
                     LOCAL_ASSERT(op == JSOP_LEAVEBLOCK);
                     if (SN_TYPE(sn) == SRC_HIDDEN)
                         break;
@@ -3408,17 +3408,17 @@ Decompile(SprintStack *ss, jsbytecode *p
               {
                 obj = jp->script->getObject(GET_UINT32_INDEX(pc));
                 StaticBlockObject &blockObj = obj->asStaticBlock();
 
                 AtomVector atoms(cx);
                 if (!GetBlockNames(cx, blockObj, &atoms))
                     return NULL;
 
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 LOCAL_ASSERT(SN_TYPE(sn) == SRC_DECL);
                 ptrdiff_t letData = js_GetSrcNoteOffset(sn, 0);
                 bool groupAssign = LetDataToGroupAssign(letData);
                 unsigned letDepth = blockObj.stackDepth();
                 LOCAL_ASSERT(letDepth == (unsigned)ss->top - blockObj.slotCount());
                 LOCAL_ASSERT(atoms.length() == blockObj.slotCount());
 
                 /*
@@ -3489,17 +3489,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 if (!Dup(ss->sprinter.stringAt(headBegin), &head))
                     return NULL;
                 if (!AssignBlockNamesToPushedSlots(ss, atoms))
                     return NULL;
 
                 /* Detect 'for (let ...)' desugared into 'let (...) {for}'. */
                 jsbytecode *nextpc = pc + JSOP_ENTERLET0_LENGTH;
                 if (*nextpc == JSOP_NOP) {
-                    jssrcnote *nextsn = js_GetSrcNote(jp->script, nextpc);
+                    jssrcnote *nextsn = js_GetSrcNote(cx, jp->script, nextpc);
                     if (nextsn && SN_TYPE(nextsn) == SRC_FOR) {
                         pc = nextpc;
                         todo = SprintNormalFor(cx, jp, ss, "let ", head.begin(), pc, &pc, &len);
                         break;
                     }
                 }
 
                 /* Decompile the body and then complete the let block/expr. */
@@ -3527,21 +3527,21 @@ Decompile(SprintStack *ss, jsbytecode *p
               {
                 obj = jp->script->getObject(GET_UINT32_INDEX(pc));
                 StaticBlockObject &blockObj = obj->asStaticBlock();
 
                 AtomVector atoms(cx);
                 if (!GetBlockNames(cx, blockObj, &atoms))
                     return NULL;
 
-                LOCAL_ASSERT(js_GetSrcNote(jp->script, pc) == NULL);
+                LOCAL_ASSERT(js_GetSrcNote(cx, jp->script, pc) == NULL);
                 LOCAL_ASSERT(ss->top - 1 == blockObj.stackDepth() + blockObj.slotCount());
                 jsbytecode *nextpc = pc + JSOP_ENTERLET1_LENGTH;
                 if (*nextpc == JSOP_GOTO) {
-                    LOCAL_ASSERT(SN_TYPE(js_GetSrcNote(jp->script, nextpc)) == SRC_FOR_IN);
+                    LOCAL_ASSERT(SN_TYPE(js_GetSrcNote(cx, jp->script, nextpc)) == SRC_FOR_IN);
                 } else {
                     LOCAL_ASSERT(*nextpc == JSOP_CONDSWITCH ||
                                  *nextpc == JSOP_TABLESWITCH ||
                                  *nextpc == JSOP_LOOKUPSWITCH);
                 }
 
                 DupBuffer rhs(cx);
                 if (!Dup(PopStr(ss, JSOP_NOP), &rhs))
@@ -3556,17 +3556,17 @@ Decompile(SprintStack *ss, jsbytecode *p
 
               case JSOP_CALLALIASEDVAR:
               case JSOP_GETALIASEDVAR:
               case JSOP_CALLLOCAL:
               case JSOP_GETLOCAL:
                 if (IsVarSlot(jp, pc, &atom, &i))
                     goto do_name;
                 LOCAL_ASSERT((unsigned)i < ss->top);
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
 
 #if JS_HAS_DESTRUCTURING
                 if (sn && SN_TYPE(sn) == SRC_GROUPASSIGN) {
                     /*
                      * Distinguish a js_DecompileValueGenerator call that
                      * targets op alone, from decompilation of a full group
                      * assignment sequence, triggered by SRC_GROUPASSIGN
                      * annotating the first JSOP_GETLOCAL in the sequence.
@@ -3649,17 +3649,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                     js_printf(jp, "\t%s;\n", js_return_str);
                 }
                 todo = -2;
                 break;
 
 #if JS_HAS_GENERATORS
               case JSOP_YIELD:
 #if JS_HAS_GENERATOR_EXPRS
-                if (!ss->inGenExp || !(sn = js_GetSrcNote(jp->script, pc)))
+                if (!ss->inGenExp || !(sn = js_GetSrcNote(cx, jp->script, pc)))
 #endif
                 {
                     /* Turn off most parens. */
                     op = JSOP_SETNAME;
                     rval = POP_STR();
                     todo = (*rval != '\0')
                            ? Sprint(&ss->sprinter,
                                     (strncmp(rval, js_yield_str, 5) == 0 &&
@@ -3761,17 +3761,17 @@ Decompile(SprintStack *ss, jsbytecode *p
               }
 #endif /* JS_HAS_GENERATORS */
 
               case JSOP_THROWING:
                 todo = -2;
                 break;
 
               case JSOP_THROW:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 todo = -2;
                 if (sn && SN_TYPE(sn) == SRC_HIDDEN)
                     break;
                 rval = PopStr(ss, op, &rvalpc);
                 js_printf(jp, "\t%s ", js_throw_str);
                 SprintOpcodePermanent(jp, rval, rvalpc);
                 js_printf(jp, ";\n");
                 break;
@@ -3783,25 +3783,25 @@ Decompile(SprintStack *ss, jsbytecode *p
                 todo = -2;
                 break;
 
               case JSOP_MOREITER:
                 JS_NOT_REACHED("JSOP_MOREITER");
                 break;
 
               case JSOP_ENDITER:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 todo = -2;
                 if (sn && SN_TYPE(sn) == SRC_HIDDEN)
                     break;
                 (void) PopOff(ss, op);
                 break;
 
               case JSOP_GOTO:
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 switch (sn ? SN_TYPE(sn) : SRC_NULL) {
                   case SRC_FOR_IN:
                     /*
                      * The bytecode around pc looks like this:
                      *     <<RHS>>
                      *     iter
                      * pc: goto C               [src_for_in(B, D)]
                      *  A: loophead
@@ -3880,17 +3880,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                             return NULL;
                         DECOMPILE_CODE(pc + next + JSOP_POP_LENGTH, cond - next - JSOP_POP_LENGTH);
                     } else {
                         /*
                          * As above, rval or an extension of it must remain
                          * stacked during loop body decompilation.
                          */
                         rval = GetStr(ss, ss->top - 1);
-                        xval = VarPrefix(js_GetSrcNote(jp->script, pc + next));
+                        xval = VarPrefix(js_GetSrcNote(cx, jp->script, pc + next));
                         js_printf(jp, "\t%s (%s%s %s %s) {\n",
                                   foreach ? js_for_each_str : js_for_str,
                                   xval,
                                   lval,
                                   forOf ? "of" : "in",
                                   rval);
                         jp->indent += 4;
                         DECOMPILE_CODE(pc + next + JSOP_POP_LENGTH, cond - next - JSOP_POP_LENGTH);
@@ -3954,17 +3954,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 break;
 
               case JSOP_IFEQ:
               {
                 JSBool elseif = JS_FALSE;
 
               if_again:
                 len = GET_JUMP_OFFSET(pc);
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
 
                 switch (sn ? SN_TYPE(sn) : SRC_NULL) {
                   case SRC_IF:
                   case SRC_IF_ELSE:
                     rval = PopCondStr(ss, &rvalpc);
                     if (ss->inArrayInit || ss->inGenExp) {
                         LOCAL_ASSERT(SN_TYPE(sn) == SRC_IF);
                         ss->sprinter.setOffset(ss->sprinter.getOffset() - PAREN_SLOP);
@@ -4123,17 +4123,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 if (todo < 0 || !PushOff(ss, todo,
                                          (JSOp) ss->opcodes[ss->top-2])) {
                     return NULL;
                 }
                 /* FALL THROUGH */
 
               case JSOP_DUP:
 #if JS_HAS_DESTRUCTURING
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 if (sn) {
                     if (SN_TYPE(sn) == SRC_DESTRUCT) {
                         pc = DecompileDestructuring(ss, pc, endpc);
                         if (!pc)
                             return NULL;
 
                         /* Left-hand side never needs parens. */
                         JS_ASSERT(js_CodeSpec[JSOP_POP].prec <= 3);
@@ -4267,26 +4267,26 @@ Decompile(SprintStack *ss, jsbytecode *p
                 lval = QuoteString(&ss->sprinter, atom, 0);
                 if (!lval)
                     return NULL;
                 rval = PopStrDupe(ss, op, &rvalpc);
                 if (op == JSOP_SETNAME || op == JSOP_SETGNAME)
                     (void) PopOff(ss, op);
 
               do_setlval:
-                sn = js_GetSrcNote(jp->script, pc - 1);
+                sn = js_GetSrcNote(cx, jp->script, pc - 1);
                 todo = ss->sprinter.getOffset();
                 if (sn && SN_TYPE(sn) == SRC_ASSIGNOP) {
                     const char *token =
                         GetTokenForAssignment(jp, sn, lastop, pc, rvalpc,
                                               &lastlvalpc, &lastrvalpc);
                     Sprint(&ss->sprinter, "%s %s= ", lval, token);
                     SprintOpcode(ss, rval, rvalpc, pc, todo);
                 } else {
-                    sn = js_GetSrcNote(jp->script, pc);
+                    sn = js_GetSrcNote(cx, jp->script, pc);
                     const char *prefix = VarPrefix(sn);
                     Sprint(&ss->sprinter, "%s%s = ", prefix, lval);
                     SprintOpcode(ss, rval, rvalpc, pc, todo);
                 }
                 break;
 
               case JSOP_NEW:
               case JSOP_CALL:
@@ -4557,17 +4557,17 @@ Decompile(SprintStack *ss, jsbytecode *p
 
                 /*
                  * Force precedence below the numeric literal opcodes, so that
                  * 42..foo or 10000..toString(16), e.g., decompile with parens
                  * around the left-hand side of dot.
                  */
                 op = JSOP_GETPROP;
                 lval = PopStr(ss, op, &lvalpc);
-                sn = js_GetSrcNote(jp->script, pc - 1);
+                sn = js_GetSrcNote(cx, jp->script, pc - 1);
                 const char *token =
                     GetTokenForAssignment(jp, sn, lastop, pc, rvalpc,
                                           &lastlvalpc, &lastrvalpc);
                 todo = ss->sprinter.getOffset();
                 SprintOpcode(ss, lval, lvalpc, pc, todo);
                 Sprint(&ss->sprinter, fmt, xval, token);
                 SprintOpcode(ss, rval, rvalpc, pc, todo);
                 break;
@@ -4599,17 +4599,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 op = JSOP_NOP;          /* turn off parens */
                 xval = PopStrDupe(ss, op, &xvalpc);
                 cs = &js_CodeSpec[ss->opcodes[ss->top]];
                 op = JSOP_GETELEM;      /* lval must have high precedence */
                 lval = PopStr(ss, op, &lvalpc);
                 op = saveop;
                 if (*xval == '\0')
                     goto do_setlval;
-                sn = js_GetSrcNote(jp->script, pc - 1);
+                sn = js_GetSrcNote(cx, jp->script, pc - 1);
                 bool xml = (JOF_MODE(cs->format) == JOF_XMLNAME);
                 const char *token =
                     GetTokenForAssignment(jp, sn, lastop, pc, rvalpc,
                                           &lastlvalpc, &lastrvalpc);
                 todo = ss->sprinter.getOffset();
                 SprintOpcode(ss, lval, lvalpc, pc, todo);
                 ss->sprinter.put(xml ? "." : "[");
                 SprintOpcode(ss, xval, xvalpc, pc, todo);
@@ -4638,17 +4638,17 @@ Decompile(SprintStack *ss, jsbytecode *p
               case JSOP_GETGNAME:
               case JSOP_CALLGNAME:
                 LOAD_ATOM(0);
               do_name:
                 lval = "";
 #if JS_HAS_XML_SUPPORT
               do_qname:
 #endif
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 rval = QuoteString(&ss->sprinter, atom, inXML ? DONT_ESCAPE : 0);
                 if (!rval)
                     return NULL;
                 ss->sprinter.setOffset(rval);
                 todo = Sprint(&ss->sprinter, sss_format,
                               VarPrefix(sn), lval, rval);
                 break;
 
@@ -4682,17 +4682,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 rval = QuoteString(&ss->sprinter, atom, inXML ? DONT_ESCAPE : '"');
                 if (!rval)
                     return NULL;
                 todo = ss->sprinter.getOffsetOf(rval);
                 break;
 
               case JSOP_LAMBDA:
 #if JS_HAS_GENERATOR_EXPRS
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 if (sn && SN_TYPE(sn) == SRC_GENEXP) {
                     BindingVector *outerLocalNames;
                     JSScript *inner, *outer;
                     Vector<DecompiledOpcode> *decompiledOpcodes;
                     SprintStack ss2(cx);
                     JSFunction *outerfun;
 
                     fun = jp->script->getFunction(GET_UINT32_INDEX(pc));
@@ -4890,17 +4890,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                             len += GetBytecodeLength(pc + len);
                         LOCAL_ASSERT(pc[len] == JSOP_POP);
                         len += GetBytecodeLength(pc + len);
                     }
                     todo = -2;
                     break;
                 }
 
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
                 len = js_GetSrcNoteOffset(sn, 0);
                 off = GET_JUMP_OFFSET(pc);
                 pc2 = pc + JUMP_OFFSET_LEN;
                 low = GET_JUMP_OFFSET(pc2);
                 pc2 += JUMP_OFFSET_LEN;
                 high = GET_JUMP_OFFSET(pc2);
                 pc2 += JUMP_OFFSET_LEN;
@@ -4913,17 +4913,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 } else {
                     table = cx->pod_malloc<TableEntry>(n);
                     if (!table)
                         return NULL;
                     for (i = j = 0; i < n; i++) {
                         table[j].label = NULL;
                         off2 = GET_JUMP_OFFSET(pc2);
                         if (off2) {
-                            sn = js_GetSrcNote(jp->script, pc2);
+                            sn = js_GetSrcNote(cx, jp->script, pc2);
                             if (sn) {
                                 LOCAL_ASSERT(SN_TYPE(sn) == SRC_LABEL);
                                 GET_SOURCE_NOTE_ATOM(sn, table[j].label);
                             }
                             table[j].key = INT_TO_JSVAL(low + i);
                             table[j].offset = off2;
                             table[j].order = j;
                             j++;
@@ -4950,29 +4950,29 @@ Decompile(SprintStack *ss, jsbytecode *p
               }
 
               case JSOP_LOOKUPSWITCH:
               {
                 ptrdiff_t off, off2;
                 jsatomid npairs, k;
                 TableEntry *table;
 
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
                 len = js_GetSrcNoteOffset(sn, 0);
                 off = GET_JUMP_OFFSET(pc);
                 pc2 = pc + JUMP_OFFSET_LEN;
                 npairs = GET_UINT16(pc2);
                 pc2 += UINT16_LEN;
 
                 table = cx->pod_malloc<TableEntry>(npairs);
                 if (!table)
                     return NULL;
                 for (k = 0; k < npairs; k++) {
-                    sn = js_GetSrcNote(jp->script, pc2);
+                    sn = js_GetSrcNote(cx, jp->script, pc2);
                     if (sn) {
                         LOCAL_ASSERT(SN_TYPE(sn) == SRC_LABEL);
                         GET_SOURCE_NOTE_ATOM(sn, table[k].label);
                     } else {
                         table[k].label = NULL;
                     }
                     uint32_t constIndex = GET_UINT32_INDEX(pc2);
                     pc2 += UINT32_INDEX_LEN;
@@ -4992,17 +4992,17 @@ Decompile(SprintStack *ss, jsbytecode *p
               }
 
               case JSOP_CONDSWITCH:
               {
                 ptrdiff_t off, off2, caseOff;
                 int ncases;
                 TableEntry *table;
 
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
                 LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
                 len = js_GetSrcNoteOffset(sn, 0);
                 off = js_GetSrcNoteOffset(sn, 1);
 
                 /*
                  * Count the cases using offsets from switch to first case,
                  * and case to case, stored in srcnote immediates.
                  */
@@ -5010,17 +5010,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 off2 = off;
                 for (ncases = 0; off2 != 0; ncases++) {
                     pc2 += off2;
                     LOCAL_ASSERT(*pc2 == JSOP_CASE || *pc2 == JSOP_DEFAULT);
                     if (*pc2 == JSOP_DEFAULT) {
                         /* End of cases, but count default as a case. */
                         off2 = 0;
                     } else {
-                        sn = js_GetSrcNote(jp->script, pc2);
+                        sn = js_GetSrcNote(cx, jp->script, pc2);
                         LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_PCDELTA);
                         off2 = js_GetSrcNoteOffset(sn, 0);
                     }
                 }
 
                 /*
                  * Allocate table and rescan the cases using their srcnotes,
                  * stashing each case's delta from switch top in table[i].key,
@@ -5033,17 +5033,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 off2 = off;
                 for (i = 0; i < ncases; i++) {
                     pc2 += off2;
                     LOCAL_ASSERT(*pc2 == JSOP_CASE || *pc2 == JSOP_DEFAULT);
                     caseOff = pc2 - pc;
                     table[i].key = INT_TO_JSVAL((int32_t) caseOff);
                     table[i].offset = caseOff + GET_JUMP_OFFSET(pc2);
                     if (*pc2 == JSOP_CASE) {
-                        sn = js_GetSrcNote(jp->script, pc2);
+                        sn = js_GetSrcNote(cx, jp->script, pc2);
                         LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_PCDELTA);
                         off2 = js_GetSrcNoteOffset(sn, 0);
                     }
                 }
 
                 /*
                  * Find offset of default code by fetching the default offset
                  * from the end of table.  JSOP_CONDSWITCH always has a default
@@ -5118,17 +5118,17 @@ Decompile(SprintStack *ss, jsbytecode *p
               }
 
               case JSOP_ENDINIT:
               {
                 JSBool inArray;
 
                 op = JSOP_NOP;           /* turn off parens */
                 rval = PopStr(ss, op, &rvalpc);
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
 
                 /* Skip any #n= prefix to find the opening bracket. */
                 for (xval = rval; *xval != '[' && *xval != '{' && *xval; xval++)
                     continue;
                 inArray = (*xval == '[');
                 if (inArray)
                     --ss->inArrayInit;
                 todo = ss->sprinter.getOffset();
@@ -5151,17 +5151,17 @@ Decompile(SprintStack *ss, jsbytecode *p
                 isFirst = IsInitializerOp(ss->opcodes[ss->top - 3]);
 
                 /* Turn off most parens. */
                 rval = PopStr(ss, JSOP_SETNAME, &rvalpc);
 
                 /* Turn off all parens for xval and lval, which we control. */
                 xval = PopStr(ss, JSOP_NOP, &xvalpc);
                 lval = PopStr(ss, JSOP_NOP, &lvalpc);
-                sn = js_GetSrcNote(jp->script, pc);
+                sn = js_GetSrcNote(cx, jp->script, pc);
 
                 if (sn && SN_TYPE(sn) == SRC_INITPROP) {
                     atom = NULL;
                     goto do_initprop;
                 }
                 maybeComma = isFirst ? "" : ", ";
                 maybeSpread = op == JSOP_SPREAD ? "..." : "";
                 todo = Sprint(&ss->sprinter, "%s%s%s", lval, maybeComma, maybeSpread);
@@ -5762,17 +5762,17 @@ GetBlockChainAtPC(JSContext *cx, JSScrip
           }
           case JSOP_LEAVEBLOCK:
           case JSOP_LEAVEBLOCKEXPR:
           case JSOP_LEAVEFORLETIN: {
             // Some LEAVEBLOCK instructions are due to early exits via
             // return/break/etc. from block-scoped loops and functions.  We
             // should ignore these instructions, since they don't really signal
             // the end of the block.
-            jssrcnote *sn = js_GetSrcNote(script, p);
+            jssrcnote *sn = js_GetSrcNote(cx, script, p);
             if (!(sn && SN_TYPE(sn) == SRC_HIDDEN)) {
                 JS_ASSERT(blockChain);
                 blockChain = blockChain->asStaticBlock().enclosingBlock();
                 JS_ASSERT_IF(blockChain, blockChain->isBlock());
             }
             break;
           }
           default:
@@ -5897,17 +5897,17 @@ ExpressionDecompiler::decompilePC(jsbyte
 
     // None of these stack-writing ops generates novel values.
     JS_ASSERT(op != JSOP_CASE && op != JSOP_DUP && op != JSOP_DUP2);
 
     if (const char *token = CodeToken[op]) {
         // Handle simple cases of binary and unary operators.
         switch (js_CodeSpec[op].nuses) {
           case 2: {
-            jssrcnote *sn = js_GetSrcNote(script, pc);
+            jssrcnote *sn = js_GetSrcNote(cx, script, pc);
             if (!sn || SN_TYPE(sn) != SRC_ASSIGNOP)
                 return write("(") &&
                        decompilePC(pcstack[-2]) &&
                        write(" ") &&
                        write(token) &&
                        write(" ") &&
                        decompilePC(pcstack[-1]) &&
                        write(")");
@@ -6267,17 +6267,17 @@ DecompileExpression(JSContext *cx, JSScr
     const JSCodeSpec *cs = &js_CodeSpec[op];
     jsbytecode *begin = pc;
     jsbytecode *end = pc + cs->length;
     switch (JOF_MODE(cs->format)) {
       case JOF_PROP:
       case JOF_ELEM:
       case JOF_XMLNAME:
       case 0: {
-        jssrcnote *sn = js_GetSrcNote(script, pc);
+        jssrcnote *sn = js_GetSrcNote(cx, script, pc);
         if (!sn)
             return FAILED_EXPRESSION_DECOMPILER;
         switch (SN_TYPE(sn)) {
           case SRC_PCBASE:
             begin -= js_GetSrcNoteOffset(sn, 0);
             break;
           case SRC_PCDELTA:
             end = begin + js_GetSrcNoteOffset(sn, 0);
@@ -6476,17 +6476,17 @@ ReconstructPCStack(JSContext *cx, JSScri
 
         /*
          * A (C ? T : E) expression requires skipping either T (if target is in
          * E) or both T and E (if target is after the whole expression) before
          * adjusting pcdepth based on the JSOP_IFEQ at pc that tests condition
          * C. We know that the stack depth can't change from what it was with
          * C on top of stack.
          */
-        jssrcnote *sn = js_GetSrcNote(script, pc);
+        jssrcnote *sn = js_GetSrcNote(cx, script, pc);
         if (sn && SN_TYPE(sn) == SRC_COND) {
             ptrdiff_t jmpoff = js_GetSrcNoteOffset(sn, 0);
             if (pc + jmpoff < target) {
                 pc += jmpoff;
                 op = JSOp(*pc);
                 JS_ASSERT(op == JSOP_GOTO);
                 cs = &js_CodeSpec[op];
                 oplen = cs->length;
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1858,17 +1858,17 @@ GSNCache::purge()
     code = NULL;
     if (map.initialized())
         map.finish();
 }
 
 } /* namespace js */
 
 jssrcnote *
-js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc)
+js_GetSrcNote(JSContext *cx, JSScript *script, jsbytecode *pc)
 {
     size_t target = pc - script->code;
     if (target >= size_t(script->length))
         return NULL;
 
     GSNCache *cache = GetGSNCache(cx);
     if (cache->code == script->code) {
         JS_ASSERT(cache->map.initialized());
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1203,25 +1203,18 @@ struct ScriptAndCounts
     PCCounts &getPCCounts(jsbytecode *pc) const {
         JS_ASSERT(unsigned(pc - script->code) < script->length);
         return scriptCounts.pcCountsVector[pc - script->code];
     }
 };
 
 } /* namespace js */
 
-/*
- * To perturb as little code as possible, we introduce a js_GetSrcNote lookup
- * cache without adding an explicit cx parameter.  Thus js_GetSrcNote becomes
- * a macro that uses cx from its calls' lexical environments.
- */
-#define js_GetSrcNote(script,pc) js_GetSrcNoteCached(cx, script, pc)
-
 extern jssrcnote *
-js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc);
+js_GetSrcNote(JSContext *cx, JSScript *script, jsbytecode *pc);
 
 extern jsbytecode *
 js_LineNumberToPC(JSScript *script, unsigned lineno);
 
 extern JS_FRIEND_API(unsigned)
 js_GetScriptLineExtent(JSScript *script);
 
 namespace js {