Bug 695907 - Use qualified C++ definitions in js/src/frontend instead of wrapping whole .cpp files in namespace js {...}. r=luke.
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 19 Oct 2011 16:45:12 -0500
changeset 79140 9cc812d5d96a7778bae9c130357eb006c67bca66
parent 79139 7e48b16bb2d49c132e3bf008691a2451428f7392
child 79141 58563c49a53197379a83eb81233d11b655cfd082
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersluke
bugs695907
milestone10.0a1
Bug 695907 - Use qualified C++ definitions in js/src/frontend instead of wrapping whole .cpp files in namespace js {...}. r=luke.
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/BytecodeGenerator.cpp
js/src/frontend/BytecodeGenerator.h
js/src/frontend/FoldConstants.cpp
js/src/frontend/ParseNode.cpp
js/src/frontend/Parser.cpp
js/src/frontend/TokenStream.cpp
js/src/jsreflect.cpp
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -46,18 +46,16 @@
 #include "frontend/FoldConstants.h"
 #include "vm/GlobalObject.h"
 
 #include "jsinferinlines.h"
 
 using namespace js;
 using namespace js::frontend;
 
-namespace js {
-
 /*
  * Compile a top-level script.
  */
 BytecodeCompiler::BytecodeCompiler(JSContext *cx, JSPrincipals *prin, StackFrame *cfp)
   : parser(cx, prin, cfp), globalScope(NULL)
 {}
 
 JSScript *
@@ -471,10 +469,8 @@ BytecodeCompiler::compileFunctionBody(JS
 
             if (!EmitFunctionScript(cx, &funcg, pn))
                 pn = NULL;
         }
     }
 
     return pn != NULL;
 }
-
-} /* namespace js */
--- a/js/src/frontend/BytecodeGenerator.cpp
+++ b/js/src/frontend/BytecodeGenerator.cpp
@@ -88,30 +88,28 @@
 using namespace js;
 using namespace js::gc;
 using namespace js::frontend;
 
 #ifdef JS_TRACER
 extern uint8 js_opcode2extra[];
 #endif
 
-namespace js {
-namespace frontend {
-
 static JSBool
 NewTryNote(JSContext *cx, CodeGenerator *cg, JSTryNoteKind kind, uintN stackDepth,
            size_t start, size_t end);
 
 static bool
 EmitIndexOp(JSContext *cx, JSOp op, uintN index, CodeGenerator *cg, JSOp *psuffix = NULL);
 
 static JSBool
 EmitLeaveBlock(JSContext *cx, CodeGenerator *cg, JSOp op, ObjectBox *box);
 
-} /* namespace frontend */
+static JSBool
+SetSrcNoteOffset(JSContext *cx, CodeGenerator *cg, uintN index, uintN which, ptrdiff_t offset);
 
 void
 TreeContext::trace(JSTracer *trc)
 {
     bindings.trace(trc);
 }
 
 CodeGenerator::CodeGenerator(Parser *parser, uintN lineno)
@@ -157,18 +155,16 @@ CodeGenerator::~CodeGenerator()
     cx->free_(main.base);
     cx->free_(main.notes);
 
     /* NB: non-null only after OOM. */
     if (spanDeps)
         cx->free_(spanDeps);
 }
 
-namespace frontend {
-
 static ptrdiff_t
 EmitCheck(JSContext *cx, CodeGenerator *cg, ptrdiff_t delta)
 {
     jsbytecode *base = CG_BASE(cg);
     jsbytecode *newbase;
     jsbytecode *next = CG_NEXT(cg);
     jsbytecode *limit = CG_LIMIT(cg);
     ptrdiff_t offset = next - base;
@@ -264,61 +260,61 @@ static inline void
 UpdateDecomposeLength(CodeGenerator *cg, uintN start)
 {
     uintN end = CG_OFFSET(cg);
     JS_ASSERT(uintN(end - start) < 256);
     CG_CODE(cg, start)[-1] = end - start;
 }
 
 ptrdiff_t
-Emit1(JSContext *cx, CodeGenerator *cg, JSOp op)
+frontend::Emit1(JSContext *cx, CodeGenerator *cg, JSOp op)
 {
     ptrdiff_t offset = EmitCheck(cx, cg, 1);
 
     if (offset >= 0) {
         *CG_NEXT(cg)++ = (jsbytecode)op;
         UpdateDepth(cx, cg, offset);
     }
     return offset;
 }
 
 ptrdiff_t
-Emit2(JSContext *cx, CodeGenerator *cg, JSOp op, jsbytecode op1)
+frontend::Emit2(JSContext *cx, CodeGenerator *cg, JSOp op, jsbytecode op1)
 {
     ptrdiff_t offset = EmitCheck(cx, cg, 2);
 
     if (offset >= 0) {
         jsbytecode *next = CG_NEXT(cg);
         next[0] = (jsbytecode)op;
         next[1] = op1;
         CG_NEXT(cg) = next + 2;
         UpdateDepth(cx, cg, offset);
     }
     return offset;
 }
 
 ptrdiff_t
-Emit3(JSContext *cx, CodeGenerator *cg, JSOp op, jsbytecode op1,
-         jsbytecode op2)
+frontend::Emit3(JSContext *cx, CodeGenerator *cg, JSOp op, jsbytecode op1,
+                    jsbytecode op2)
 {
     ptrdiff_t offset = EmitCheck(cx, cg, 3);
 
     if (offset >= 0) {
         jsbytecode *next = CG_NEXT(cg);
         next[0] = (jsbytecode)op;
         next[1] = op1;
         next[2] = op2;
         CG_NEXT(cg) = next + 3;
         UpdateDepth(cx, cg, offset);
     }
     return offset;
 }
 
 ptrdiff_t
-Emit5(JSContext *cx, CodeGenerator *cg, JSOp op, uint16 op1, uint16 op2)
+frontend::Emit5(JSContext *cx, CodeGenerator *cg, JSOp op, uint16 op1, uint16 op2)
 {
     ptrdiff_t offset = EmitCheck(cx, cg, 5);
 
     if (offset >= 0) {
         jsbytecode *next = CG_NEXT(cg);
         next[0] = (jsbytecode)op;
         next[1] = UINT16_HI(op1);
         next[2] = UINT16_LO(op1);
@@ -326,17 +322,17 @@ Emit5(JSContext *cx, CodeGenerator *cg, 
         next[4] = UINT16_LO(op2);
         CG_NEXT(cg) = next + 5;
         UpdateDepth(cx, cg, offset);
     }
     return offset;
 }
 
 ptrdiff_t
-EmitN(JSContext *cx, CodeGenerator *cg, JSOp op, size_t extra)
+frontend::EmitN(JSContext *cx, CodeGenerator *cg, JSOp op, size_t extra)
 {
     ptrdiff_t length = 1 + (ptrdiff_t)extra;
     ptrdiff_t offset = EmitCheck(cx, cg, length);
 
     if (offset >= 0) {
         jsbytecode *next = CG_NEXT(cg);
         *next = (jsbytecode)op;
         memset(next + 1, 0, BYTECODE_SIZE(extra));
@@ -553,17 +549,18 @@ AddJumpTarget(AddJumpTargetArgs *args, J
 
     jt->balance += balanceDelta;
     return (balanceDelta && jt->balance)
            ? 1 - BalanceJumpTargets(jtp)
            : 0;
 }
 
 #ifdef DEBUG_brendan
-static int AVLCheck(JumpTarget *jt)
+static int
+AVLCheck(JumpTarget *jt)
 {
     int lh, rh;
 
     if (!jt) return 0;
     JS_ASSERT(-1 <= jt->balance && jt->balance <= 1);
     lh = AVLCheck(jt->kids[JT_LEFT]);
     rh = AVLCheck(jt->kids[JT_RIGHT]);
     JS_ASSERT(jt->balance == rh - lh);
@@ -1262,33 +1259,31 @@ GetJumpOffset(CodeGenerator *cg, jsbytec
     ptrdiff_t top = sd->top;
     while (--sd >= cg->spanDeps && sd->top == top)
         continue;
     sd++;
     return JT_CLR_TAG(jt)->offset - sd->offset;
 }
 
 JSBool
-SetJumpOffset(JSContext *cx, CodeGenerator *cg, jsbytecode *pc, ptrdiff_t off)
+frontend::SetJumpOffset(JSContext *cx, CodeGenerator *cg, jsbytecode *pc, ptrdiff_t off)
 {
     if (!cg->spanDeps) {
         if (JUMP_OFFSET_MIN <= off && off <= JUMP_OFFSET_MAX) {
             SET_JUMP_OFFSET(pc, off);
             return JS_TRUE;
         }
 
         if (!BuildSpanDepTable(cx, cg))
             return JS_FALSE;
     }
 
     return SetSpanDepTarget(cx, cg, GetSpanDep(cg, pc), off);
 }
 
-} /* namespace frontend */
-
 bool
 TreeContext::inStatement(StmtType type)
 {
     for (StmtInfo *stmt = topStmt; stmt; stmt = stmt->down) {
         if (stmt->type == type)
             return true;
     }
     return false;
@@ -1339,48 +1334,46 @@ TreeContext::skipSpansGenerator(unsigned
         if (!tc)
             return false;
         if (tc->flags & TCF_FUN_IS_GENERATOR)
             return true;
     }
     return false;
 }
 
-namespace frontend {
-
 bool
-SetStaticLevel(TreeContext *tc, uintN staticLevel)
+frontend::SetStaticLevel(TreeContext *tc, uintN staticLevel)
 {
     /*
      * This is a lot simpler than error-checking every UpvarCookie::set, and
      * practically speaking it leaves more than enough room for upvars.
      */
     if (UpvarCookie::isLevelReserved(staticLevel)) {
         JS_ReportErrorNumber(tc->parser->context, js_GetErrorMessage, NULL,
                              JSMSG_TOO_DEEP, js_function_str);
         return false;
     }
     tc->staticLevel = staticLevel;
     return true;
 }
 
 bool
-GenerateBlockId(TreeContext *tc, uint32& blockid)
+frontend::GenerateBlockId(TreeContext *tc, uint32& blockid)
 {
     if (tc->blockidGen == JS_BIT(20)) {
         JS_ReportErrorNumber(tc->parser->context, js_GetErrorMessage, NULL,
                              JSMSG_NEED_DIET, "program");
         return false;
     }
     blockid = tc->blockidGen++;
     return true;
 }
 
 void
-PushStatement(TreeContext *tc, StmtInfo *stmt, StmtType type, ptrdiff_t top)
+frontend::PushStatement(TreeContext *tc, StmtInfo *stmt, StmtType type, ptrdiff_t top)
 {
     stmt->type = type;
     stmt->flags = 0;
     stmt->blockid = tc->blockid();
     SET_STATEMENT_TOP(stmt, top);
     stmt->label = NULL;
     JS_ASSERT(!stmt->blockBox);
     stmt->down = tc->topStmt;
@@ -1389,17 +1382,17 @@ PushStatement(TreeContext *tc, StmtInfo 
         stmt->downScope = tc->topScopeStmt;
         tc->topScopeStmt = stmt;
     } else {
         stmt->downScope = NULL;
     }
 }
 
 void
-PushBlockScope(TreeContext *tc, StmtInfo *stmt, ObjectBox *blockBox, ptrdiff_t top)
+frontend::PushBlockScope(TreeContext *tc, StmtInfo *stmt, ObjectBox *blockBox, ptrdiff_t top)
 {
     PushStatement(tc, stmt, STMT_BLOCK, top);
     stmt->flags |= SIF_SCOPE;
     blockBox->parent = tc->blockChainBox;
     blockBox->object->setParent(tc->blockChain());
     stmt->downScope = tc->topScopeStmt;
     tc->topScopeStmt = stmt;
     tc->blockChainBox = blockBox;
@@ -1675,55 +1668,55 @@ BackPatch(JSContext *cx, CodeGenerator *
          */
         *pc = op;
         pc -= delta;
     }
     return JS_TRUE;
 }
 
 void
-PopStatementTC(TreeContext *tc)
+frontend::PopStatementTC(TreeContext *tc)
 {
     StmtInfo *stmt = tc->topStmt;
     tc->topStmt = stmt->down;
     if (STMT_LINKS_SCOPE(stmt)) {
         tc->topScopeStmt = stmt->downScope;
         if (stmt->flags & SIF_SCOPE) {
             tc->blockChainBox = stmt->blockBox->parent;
         }
     }
 }
 
 JSBool
-PopStatementCG(JSContext *cx, CodeGenerator *cg)
+frontend::PopStatementCG(JSContext *cx, CodeGenerator *cg)
 {
     StmtInfo *stmt = cg->topStmt;
     if (!STMT_IS_TRYING(stmt) &&
         (!BackPatch(cx, cg, stmt->breaks, CG_NEXT(cg), JSOP_GOTO) ||
          !BackPatch(cx, cg, stmt->continues, CG_CODE(cg, stmt->update),
                     JSOP_GOTO))) {
         return JS_FALSE;
     }
     PopStatementTC(cg);
     return JS_TRUE;
 }
 
 JSBool
-DefineCompileTimeConstant(JSContext *cx, CodeGenerator *cg, JSAtom *atom, ParseNode *pn)
+frontend::DefineCompileTimeConstant(JSContext *cx, CodeGenerator *cg, JSAtom *atom, ParseNode *pn)
 {
     /* XXX just do numbers for now */
     if (pn->isKind(TOK_NUMBER)) {
         if (!cg->constMap.put(atom, NumberValue(pn->pn_dval)))
             return JS_FALSE;
     }
     return JS_TRUE;
 }
 
 StmtInfo *
-LexicalLookup(TreeContext *tc, JSAtom *atom, jsint *slotp, StmtInfo *stmt)
+frontend::LexicalLookup(TreeContext *tc, JSAtom *atom, jsint *slotp, StmtInfo *stmt)
 {
     if (!stmt)
         stmt = tc->topScopeStmt;
     for (; stmt; stmt = stmt->downScope) {
         if (stmt->type == STMT_WITH)
             break;
 
         /* Skip "maybe scope" statements that don't contain let bindings. */
@@ -1955,26 +1948,22 @@ EmitSlotIndexOp(JSContext *cx, JSOp op, 
         return JS_FALSE;
     pc = CG_CODE(cg, off);
     SET_UINT16(pc, slot);
     pc += 2;
     SET_INDEX(pc, index);
     return bigSuffix == JSOP_NOP || Emit1(cx, cg, bigSuffix) >= 0;
 }
 
-} /* namespace frontend */
-
 bool
 CodeGenerator::shouldNoteClosedName(ParseNode *pn)
 {
     return !callsEval() && pn->isDefn() && pn->isClosed();
 }
 
-namespace frontend {
-
 /*
  * Adjust the slot for a block local to account for the number of variables
  * that share the same index space with locals. Due to the incremental code
  * generation for top-level script, we do the adjustment via code patching in
  * BytecodeCompiler::compileScript; see comments there.
  *
  * The function returns -1 on failures.
  */
@@ -2518,18 +2507,16 @@ BindNameToSlot(JSContext *cx, CodeGenera
 
     JS_ASSERT(!pn->isOp(op));
     pn->setOp(op);
     pn->pn_cookie.set(0, cookie.slot());
     pn->pn_dflags |= PND_BOUND;
     return JS_TRUE;
 }
 
-} /* namespace frontend */
-
 bool
 CodeGenerator::addGlobalUse(JSAtom *atom, uint32 slot, UpvarCookie *cookie)
 {
     if (!globalMap.ensureMap(context()))
         return false;
 
     AtomIndexAddPtr p = globalMap->lookupForAdd(atom);
     if (p) {
@@ -2554,18 +2541,16 @@ CodeGenerator::addGlobalUse(JSAtom *atom
 
     GlobalSlotArray::Entry entry = { allAtomIndex, slot };
     if (!globalUses.append(entry))
         return false;
 
     return globalMap->add(p, atom, globalUseIndex);
 }
 
-namespace frontend {
-
 /*
  * If pn contains a useful expression, return true with *answer set to true.
  * If pn contains a useless expression, return true with *answer set to false.
  * Return false on error.
  *
  * The caller should initialize *answer to false and invoke this function on
  * an expression statement or similar subtree to decide whether the tree could
  * produce code that has any side effects.  For an expression statement, we
@@ -3914,17 +3899,17 @@ out:
     return ok;
 
 bad:
     ok = JS_FALSE;
     goto out;
 }
 
 JSBool
-EmitFunctionScript(JSContext *cx, CodeGenerator *cg, ParseNode *body)
+frontend::EmitFunctionScript(JSContext *cx, CodeGenerator *cg, ParseNode *body)
 {
     /*
      * The decompiler has assumptions about what may occur immediately after
      * script->main (e.g., in the case of destructuring params). Thus, put the
      * following ops into the range [script->code, script->main). Note:
      * execution starts from script->code, so this has no semantic effect.
      */
 
@@ -4810,18 +4795,16 @@ EmitEndInit(JSContext *cx, CodeGenerator
 #if JS_HAS_SHARP_VARS
     /* Emit an op for sharp array cleanup and decompilation. */
     if (cg->hasSharps() && count != 0)
         EMIT_UINT16_IMM_OP(JSOP_SHARPINIT, cg->sharpSlotBase);
 #endif
     return Emit1(cx, cg, JSOP_ENDINIT) >= 0;
 }
 
-} /* namespace frontend */
-
 bool
 ParseNode::getConstantValue(JSContext *cx, bool strictChecks, Value *vp)
 {
     switch (getKind()) {
       case TOK_NUMBER:
         vp->setNumber(pn_dval);
         return true;
       case TOK_STRING:
@@ -4903,18 +4886,16 @@ ParseNode::getConstantValue(JSContext *c
         return true;
       }
       default:
         JS_NOT_REACHED("Unexpected node");
     }
     return false;
 }
 
-namespace frontend {
-
 static bool
 EmitSingletonInitialiser(JSContext *cx, CodeGenerator *cg, ParseNode *pn)
 {
     Value value;
     if (!pn->getConstantValue(cx, cg->needStrictChecks(), &value))
         return false;
 
     JS_ASSERT(value.isObject());
@@ -5840,17 +5821,17 @@ static inline bool
 EmitFor(JSContext *cx, CodeGenerator *cg, ParseNode *pn, ptrdiff_t top)
 {
     return pn->pn_left->isKind(TOK_IN)
            ? EmitForIn(cx, cg, pn, top)
            : EmitNormalFor(cx, cg, pn, top);
 }
 
 JSBool
-EmitTree(JSContext *cx, CodeGenerator *cg, ParseNode *pn)
+frontend::EmitTree(JSContext *cx, CodeGenerator *cg, ParseNode *pn)
 {
     JSBool useful, wantval;
     StmtInfo stmtInfo;
     StmtInfo *stmt;
     ptrdiff_t top, off, tmp, beq, jmp;
     ParseNode *pn2, *pn3;
     JSAtom *atom;
     jsatomid atomIndex;
@@ -7434,17 +7415,17 @@ AllocSrcNote(JSContext *cx, CodeGenerato
         CG_NOTE_LIMIT(cg) = newlength;
     }
 
     CG_NOTE_COUNT(cg) = index + 1;
     return (intN)index;
 }
 
 intN
-NewSrcNote(JSContext *cx, CodeGenerator *cg, SrcNoteType type)
+frontend::NewSrcNote(JSContext *cx, CodeGenerator *cg, SrcNoteType type)
 {
     intN index, n;
     jssrcnote *sn;
     ptrdiff_t offset, delta, xdelta;
 
     /*
      * Claim a note slot in CG_NOTES(cg) by growing it if necessary and then
      * incrementing CG_NOTE_COUNT(cg).
@@ -7482,30 +7463,30 @@ NewSrcNote(JSContext *cx, CodeGenerator 
     for (n = (intN)js_SrcNoteSpec[type].arity; n > 0; n--) {
         if (NewSrcNote(cx, cg, SRC_NULL) < 0)
             return -1;
     }
     return index;
 }
 
 intN
-NewSrcNote2(JSContext *cx, CodeGenerator *cg, SrcNoteType type, ptrdiff_t offset)
+frontend::NewSrcNote2(JSContext *cx, CodeGenerator *cg, SrcNoteType type, ptrdiff_t offset)
 {
     intN index;
 
     index = NewSrcNote(cx, cg, type);
     if (index >= 0) {
         if (!SetSrcNoteOffset(cx, cg, index, 0, offset))
             return -1;
     }
     return index;
 }
 
 intN
-NewSrcNote3(JSContext *cx, CodeGenerator *cg, SrcNoteType type, ptrdiff_t offset1,
+frontend::NewSrcNote3(JSContext *cx, CodeGenerator *cg, SrcNoteType type, ptrdiff_t offset1,
             ptrdiff_t offset2)
 {
     intN index;
 
     index = NewSrcNote(cx, cg, type);
     if (index >= 0) {
         if (!SetSrcNoteOffset(cx, cg, index, 0, offset1))
             return -1;
@@ -7525,17 +7506,17 @@ GrowSrcNotes(JSContext *cx, CodeGenerato
         return JS_FALSE;
     }
     CG_NOTES(cg) = newnotes;
     CG_NOTE_LIMIT(cg) = newlength;
     return JS_TRUE;
 }
 
 jssrcnote *
-AddToSrcNoteDelta(JSContext *cx, CodeGenerator *cg, jssrcnote *sn, ptrdiff_t delta)
+frontend::AddToSrcNoteDelta(JSContext *cx, CodeGenerator *cg, jssrcnote *sn, ptrdiff_t delta)
 {
     ptrdiff_t base, limit, newdelta, diff;
     intN index;
 
     /*
      * Called only from OptimizeSpanDeps and FinishTakingSrcNotes to add to
      * main script note deltas, and only by a small positive amount.
      */
@@ -7558,17 +7539,17 @@ AddToSrcNoteDelta(JSContext *cx, CodeGen
         cg->main.noteCount++;
         memmove(sn + 1, sn, SRCNOTE_SIZE(diff));
         SN_MAKE_XDELTA(sn, delta);
         sn++;
     }
     return sn;
 }
 
-JSBool
+static JSBool
 SetSrcNoteOffset(JSContext *cx, CodeGenerator *cg, uintN index, uintN which, ptrdiff_t offset)
 {
     jssrcnote *sn;
     ptrdiff_t diff;
 
     if ((jsuword)offset >= (jsuword)((ptrdiff_t)SN_3BYTE_OFFSET_FLAG << 16)) {
         ReportStatementTooLarge(cx, cg);
         return JS_FALSE;
@@ -7617,17 +7598,18 @@ SetSrcNoteOffset(JSContext *cx, CodeGene
 #ifdef DEBUG_notme
 #define DEBUG_srcnotesize
 #endif
 
 #ifdef DEBUG_srcnotesize
 #define NBINS 10
 static uint32 hist[NBINS];
 
-static void DumpSrcNoteSizeHist()
+static void
+DumpSrcNoteSizeHist()
 {
     static FILE *fp;
     int i, n;
 
     if (!fp) {
         fp = fopen("/tmp/srcnotes.hist", "w");
         if (!fp)
             return;
@@ -7647,17 +7629,17 @@ static void DumpSrcNoteSizeHist()
 /*
  * Fill in the storage at notes with prolog and main srcnotes; the space at
  * notes was allocated using the CG_COUNT_FINAL_SRCNOTES macro from
  * BytecodeGenerator.h.  SO DON'T CHANGE THIS FUNCTION WITHOUT AT LEAST
  * CHECKING WHETHER BytecodeGenerator.h's CG_COUNT_FINAL_SRCNOTES MACRO NEEDS
  * CORRESPONDING CHANGES!
  */
 JSBool
-FinishTakingSrcNotes(JSContext *cx, CodeGenerator *cg, jssrcnote *notes)
+frontend::FinishTakingSrcNotes(JSContext *cx, CodeGenerator *cg, jssrcnote *notes)
 {
     uintN prologCount, mainCount, totalCount;
     ptrdiff_t offset, delta;
     jssrcnote *sn;
 
     JS_ASSERT(cg->current == &cg->main);
 
     prologCount = cg->prolog.noteCount;
@@ -7728,32 +7710,30 @@ NewTryNote(JSContext *cx, CodeGenerator 
     tryNode->note.length = (uint32)(end - start);
     tryNode->prev = cg->lastTryNode;
     cg->lastTryNode = tryNode;
     cg->ntrynotes++;
     return JS_TRUE;
 }
 
 void
-FinishTakingTryNotes(CodeGenerator *cg, JSTryNoteArray *array)
+frontend::FinishTakingTryNotes(CodeGenerator *cg, JSTryNoteArray *array)
 {
     TryNode *tryNode;
     JSTryNote *tn;
 
     JS_ASSERT(array->length > 0 && array->length == cg->ntrynotes);
     tn = array->vector + array->length;
     tryNode = cg->lastTryNode;
     do {
         *--tn = tryNode->note;
     } while ((tryNode = tryNode->prev) != NULL);
     JS_ASSERT(tn == array->vector);
 }
 
-} /* namespace frontend */
-
 /*
  * Find the index of the given object for code generator.
  *
  * Since the emitter refers to each parsed object only once, for the index we
  * use the number of already indexes objects. We also add the object to a list
  * to convert the list to a fixed-size array when we complete code generation,
  * see js::CGObjectList::finish below.
  *
@@ -7822,18 +7802,16 @@ GCConstList::finish(JSConstArray *array)
 {
     JS_ASSERT(array->length == list.length());
     Value *src = list.begin(), *srcend = list.end();
     Value *dst = array->vector;
     for (; src != srcend; ++src, ++dst)
         *dst = *src;
 }
 
-} /* namespace js */
-
 /*
  * 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.
  */
 JS_FRIEND_DATA(JSSrcNoteSpec) js_SrcNoteSpec[] = {
     {"null",            0,      0,      0},
     {"if",              0,      0,      0},
     {"if-else",         2,      0,      1},
--- a/js/src/frontend/BytecodeGenerator.h
+++ b/js/src/frontend/BytecodeGenerator.h
@@ -1072,19 +1072,16 @@ NewSrcNote3(JSContext *cx, CodeGenerator
                ptrdiff_t offset2);
 
 /*
  * NB: this function can add at most one extra extended delta note.
  */
 jssrcnote *
 AddToSrcNoteDelta(JSContext *cx, CodeGenerator *cg, jssrcnote *sn, ptrdiff_t delta);
 
-JSBool
-SetSrcNoteOffset(JSContext *cx, CodeGenerator *cg, uintN index, uintN which, ptrdiff_t offset);
-
 /*
  * Finish taking source notes in cx's notePool, copying final notes to the new
  * stable store allocated by the caller and passed in via notes. Return false
  * on malloc failure, which means this function reported an error.
  *
  * To compute the number of jssrcnotes to allocate and pass in via notes, use
  * the CG_COUNT_FINAL_SRCNOTES macro. This macro knows a lot about details of
  * FinishTakingSrcNotes, so DON'T CHANGE js::frontend::FinishTakingSrcNotes
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -429,20 +429,18 @@ Boolish(ParseNode *pn)
       case JSOP_FALSE:
         return Falsy;
 
       default:
         return Unknown;
     }
 }
 
-namespace js {
-
 bool
-FoldConstants(JSContext *cx, ParseNode *pn, TreeContext *tc, bool inCond)
+js::FoldConstants(JSContext *cx, ParseNode *pn, TreeContext *tc, bool inCond)
 {
     ParseNode *pn1 = NULL, *pn2 = NULL, *pn3 = NULL;
 
     JS_CHECK_RECURSION(cx, return false);
 
     switch (pn->getArity()) {
       case PN_FUNC:
       {
@@ -903,10 +901,8 @@ FoldConstants(JSContext *cx, ParseNode *
             pn->setKind(TOK_PRIMARY);
             pn->setOp(t == Truthy ? JSOP_TRUE : JSOP_FALSE);
             pn->setArity(PN_NULLARY);
         }
     }
 
     return true;
 }
-
-} /* namespace js */
--- a/js/src/frontend/ParseNode.cpp
+++ b/js/src/frontend/ParseNode.cpp
@@ -51,18 +51,16 @@ using namespace js;
  * Asserts to verify assumptions behind pn_ macros.
  */
 #define pn_offsetof(m)  offsetof(ParseNode, m)
 
 JS_STATIC_ASSERT(pn_offsetof(pn_link) == pn_offsetof(dn_uses));
 
 #undef pn_offsetof
 
-namespace js {
-
 void
 ParseNode::become(ParseNode *pn2)
 {
     JS_ASSERT(!pn_defn);
     JS_ASSERT(!pn2->isDefn());
 
     JS_ASSERT(!pn_used);
     if (pn2->isUsed()) {
@@ -460,24 +458,20 @@ NameNode::create(JSAtom *atom, TreeConte
     ParseNode *pn = ParseNode::create(PN_NAME, tc);
     if (pn) {
         pn->pn_atom = atom;
         ((NameNode *)pn)->initCommon(tc);
     }
     return (NameNode *)pn;
 }
 
-} /* namespace js */
-
 const char js_argument_str[] = "argument";
 const char js_variable_str[] = "variable";
 const char js_unknown_str[]  = "unknown";
 
-namespace js {
-
 const char *
 Definition::kindString(Kind kind)
 {
     static const char *table[] = {
         js_var_str, js_const_str, js_let_str,
         js_function_str, js_argument_str, js_unknown_str
     };
 
@@ -597,17 +591,17 @@ CloneParseTree(ParseNode *opn, TreeConte
  *
  * opn must be the pn_head of a node produced by Parser::variables, so its form
  * is known to be LHS = NAME | [LHS] | {id:LHS}.
  *
  * The cloned tree is for use only in the same statement and binding context as
  * the original tree.
  */
 ParseNode *
-CloneLeftHandSide(ParseNode *opn, TreeContext *tc)
+js::CloneLeftHandSide(ParseNode *opn, TreeContext *tc)
 {
     ParseNode *pn = tc->parser->new_<ParseNode>(opn->getKind(), opn->getOp(), opn->getArity(),
                                                 opn->pn_pos);
     if (!pn)
         return NULL;
     pn->setInParens(opn->isInParens());
     pn->setDefn(opn->isDefn());
     pn->setUsed(opn->isUsed());
@@ -665,10 +659,8 @@ CloneLeftHandSide(ParseNode *opn, TreeCo
             pn->pn_dflags &= ~PND_BOUND;
             pn->setDefn(false);
 
             LinkUseToDef(pn, (Definition *) opn, tc);
         }
     }
     return pn;
 }
-
-} /* namespace js */
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -581,26 +581,24 @@ static bool
 ReportBadParameter(JSContext *cx, TreeContext *tc, JSAtom *name, uintN errorNumber)
 {
     Definition *dn = tc->decls.lookupFirst(name);
     JSAutoByteString bytes;
     return js_AtomToPrintableString(cx, name, &bytes) &&
            ReportStrictModeError(cx, TS(tc->parser), tc, dn, errorNumber, bytes.ptr());
 }
 
-namespace js {
-
 /*
  * In strict mode code, all parameter names must be distinct, must not be
  * strict mode reserved keywords, and must not be 'eval' or 'arguments'.  We
  * must perform these checks here, and not eagerly during parsing, because a
  * function's body may turn on strict mode for the function head.
  */
 bool
-CheckStrictParameters(JSContext *cx, TreeContext *tc)
+js::CheckStrictParameters(JSContext *cx, TreeContext *tc)
 {
     JS_ASSERT(tc->inFunction());
 
     if (!tc->needStrictChecks() || tc->bindings.countArgs() == 0)
         return true;
 
     JSAtom *argumentsAtom = cx->runtime->atomState.argumentsAtom;
     JSAtom *evalAtom = cx->runtime->atomState.evalAtom;
@@ -644,18 +642,16 @@ CheckStrictParameters(JSContext *cx, Tre
             if (!parameters.add(p, name, false))
                 return false;
         }
     }
 
     return true;
 }
 
-} /* namespace js */
-
 ParseNode *
 Parser::functionBody()
 {
     JS_ASSERT(tc->inFunction());
 
     StmtInfo stmtInfo;
     PushStatement(tc, &stmtInfo, STMT_BLOCK, -1);
     stmtInfo.flags = SIF_BODY_BLOCK;
@@ -860,20 +856,18 @@ MakeDefIntoUse(Definition *dn, ParseNode
     dn->setDefn(false);
     dn->setUsed(true);
     dn->pn_lexdef = (Definition *) pn;
     dn->pn_cookie.makeFree();
     dn->pn_dflags &= ~PND_BOUND;
     return dn;
 }
 
-namespace js {
-
 bool
-DefineArg(ParseNode *pn, JSAtom *atom, uintN i, TreeContext *tc)
+js::DefineArg(ParseNode *pn, JSAtom *atom, uintN i, TreeContext *tc)
 {
     ParseNode *argpn, *argsbody;
 
     /* Flag tc so we don't have to lookup arguments on every use. */
     if (atom == tc->parser->context->runtime->atomState.argumentsAtom)
         tc->flags |= TCF_FUN_PARAM_ARGUMENTS;
 
     /*
@@ -904,18 +898,16 @@ DefineArg(ParseNode *pn, JSAtom *atom, u
     argsbody->append(argpn);
 
     argpn->setOp(JSOP_GETARG);
     argpn->pn_cookie.set(tc->staticLevel, i);
     argpn->pn_dflags |= PND_BOUND;
     return true;
 }
 
-} /* namespace js */
-
 /*
  * Parameter block types for the several Binder functions.  We use a common
  * helper function signature in order to share code among destructuring and
  * simple variable declaration parsers.  In the destructuring case, the binder
  * function is called indirectly from the variable declaration parser by way
  * of CheckDestructuring and its friends.
  */
 typedef JSBool
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -86,20 +86,18 @@ using namespace js::unicode;
 
 static const KeywordInfo keywords[] = {
 #define JS_KEYWORD(keyword, type, op, version) \
     {js_##keyword##_str, type, op, version},
 #include "jskeyword.tbl"
 #undef JS_KEYWORD
 };
 
-namespace js {
-
 const KeywordInfo *
-FindKeyword(const jschar *s, size_t length)
+js::FindKeyword(const jschar *s, size_t length)
 {
     JS_ASSERT(length != 0);
 
     register size_t i;
     const struct KeywordInfo *kw;
     const char *chars;
 
 #define JSKW_LENGTH()           length
@@ -126,17 +124,17 @@ FindKeyword(const jschar *s, size_t leng
     } while (--length != 0);
     return kw;
 
   no_match:
     return NULL;
 }
 
 JSBool
-IsIdentifier(JSLinearString *str)
+js::IsIdentifier(JSLinearString *str)
 {
     const jschar *chars = str->chars();
     size_t length = str->length();
 
     if (length == 0)
         return JS_FALSE;
     jschar c = *chars;
     if (!IsIdentifierStart(c))
@@ -543,18 +541,18 @@ TokenStream::reportCompileErrorNumberVA(
         }
         cx->free_((void *)report.messageArgs);
     }
 
     return warning;
 }
 
 bool
-ReportStrictModeError(JSContext *cx, TokenStream *ts, TreeContext *tc, ParseNode *pn,
-                      uintN errorNumber, ...)
+js::ReportStrictModeError(JSContext *cx, TokenStream *ts, TreeContext *tc, ParseNode *pn,
+                          uintN errorNumber, ...)
 {
     JS_ASSERT(ts || tc);
     JS_ASSERT(cx == ts->getContext());
 
     /* In strict mode code, this is an error, not merely a warning. */
     uintN flags;
     if ((ts && ts->isStrictMode()) || (tc && (tc->flags & TCF_STRICT_MODE_CODE))) {
         flags = JSREPORT_ERROR;
@@ -568,18 +566,18 @@ ReportStrictModeError(JSContext *cx, Tok
     va_start(ap, errorNumber);
     bool result = ts->reportCompileErrorNumberVA(pn, flags, errorNumber, ap);
     va_end(ap);
 
     return result;
 }
 
 bool
-ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, ParseNode *pn, uintN flags,
-                         uintN errorNumber, ...)
+js::ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, ParseNode *pn, uintN flags,
+                             uintN errorNumber, ...)
 {
     va_list ap;
 
     /*
      * We don't accept a TreeContext argument, so we can't implement
      * JSREPORT_STRICT_MODE_ERROR here.  Use ReportStrictModeError instead,
      * or do the checks in the caller and pass plain old JSREPORT_ERROR.
      */
@@ -2123,18 +2121,16 @@ TokenStream::getTokenInternal()
      * call will immediately return the just-gotten TOK_ERROR token again
      * without consulting userbuf, thanks to the lookahead buffer.
      */
     userbuf.poison();
 #endif
     return TOK_ERROR;
 }
 
-} /* namespace js */
-
 JS_FRIEND_API(int)
 js_fgets(char *buf, int size, FILE *file)
 {
     int n, i, c;
     JSBool crflag;
 
     n = size - 1;
     if (n < 0)
--- a/js/src/jsreflect.cpp
+++ b/js/src/jsreflect.cpp
@@ -2349,17 +2349,17 @@ ASTSerializer::comprehension(ParseNode *
 
     Value filter = MagicValue(JS_SERIALIZE_NO_NODE);
 
     if (next->isKind(TOK_IF)) {
         if (!optExpression(next->pn_kid1, &filter))
             return false;
         next = next->pn_kid2;
     } else if (next->isKind(TOK_LC) && next->pn_count == 0) {
-        /* js_FoldConstants optimized away the push. */
+        /* FoldConstants optimized away the push. */
         NodeVector empty(cx);
         return builder.arrayExpression(empty, &pn->pn_pos, dst);
     }
 
     LOCAL_ASSERT(next->isKind(TOK_ARRAYPUSH));
 
     Value body;