Bug 807151 - Unexport |mozilla| from the |js| namespace; r=Waldo
authorTerrence Cole <terrence@mozilla.com>
Tue, 06 Nov 2012 17:35:18 -0800
changeset 120538 13cf8566804c43365ae71b9e1a0f10350ccefad0
parent 120537 2e6726f79a3b8de41d680715561c4db117df73cb
child 120539 c0893be94207fd073d202015673b585ddea33b27
push id1997
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 21:25:26 +0000
treeherdermozilla-beta@4baf45cdcf21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs807151
milestone19.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 807151 - Unexport |mozilla| from the |js| namespace; r=Waldo Clang does not want to allow js::ion::Range and mozilla::Range simultaneously when we have a |namespace js { using namespace mozilla; }| declaration.
js/public/HashTable.h
js/public/Utility.h
js/public/Vector.h
js/src/assembler/assembler/MacroAssemblerX86_64.h
js/src/builtin/Eval.cpp
js/src/builtin/Profilers.cpp
js/src/builtin/RegExp.cpp
js/src/builtin/TestingFunctions.cpp
js/src/ds/LifoAlloc.h
js/src/frontend/BytecodeEmitter.cpp
js/src/gc/Marking.cpp
js/src/gc/Root.h
js/src/ion/Bailouts.h
js/src/ion/CodeGenerator.cpp
js/src/ion/InlineList.h
js/src/ion/IonBuilder.cpp
js/src/ion/IonCaches.cpp
js/src/ion/IonCaches.h
js/src/ion/IonFrames.h
js/src/ion/IonMacroAssembler.h
js/src/ion/LinearScan.cpp
js/src/ion/LinearScan.h
js/src/ion/RegisterSets.h
js/src/ion/arm/MacroAssembler-arm.h
js/src/ion/shared/Assembler-shared.h
js/src/ion/shared/CodeGenerator-shared.cpp
js/src/ion/shared/MacroAssembler-x86-shared.h
js/src/ion/x86/CodeGenerator-x86.cpp
js/src/jsanalyze.cpp
js/src/jsapi-tests/testIndexToString.cpp
js/src/jsapi-tests/testIntern.cpp
js/src/jsapi.cpp
js/src/jsarray.cpp
js/src/jsatom.cpp
js/src/jsatom.h
js/src/jscntxt.cpp
js/src/jscntxtinlines.h
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsdate.cpp
js/src/jsdbgapi.cpp
js/src/jsexn.cpp
js/src/jsfun.cpp
js/src/jsfuninlines.h
js/src/jsgc.cpp
js/src/jsgc.h
js/src/jsgcinlines.h
js/src/jsinfer.cpp
js/src/jsinterp.cpp
js/src/jsiter.cpp
js/src/jsnum.cpp
js/src/jsobj.cpp
js/src/json.cpp
js/src/jsonparser.cpp
js/src/jsopcode.cpp
js/src/jsreflect.cpp
js/src/jsscope.cpp
js/src/jsscope.h
js/src/jsscopeinlines.h
js/src/jstypedarray.cpp
js/src/jsworkers.cpp
js/src/jsxml.cpp
js/src/methodjit/BaseAssembler.h
js/src/methodjit/Compiler.cpp
js/src/methodjit/FastBuiltins.cpp
js/src/methodjit/InvokeHelpers.cpp
js/src/methodjit/Retcon.cpp
js/src/methodjit/StubCalls.cpp
js/src/shell/js.cpp
js/src/vm/Debugger.cpp
js/src/vm/Debugger.h
js/src/vm/SPSProfiler.cpp
js/src/vm/SPSProfiler.h
js/src/vm/Stack.cpp
js/src/vm/String.cpp
js/src/vm/StringBuffer.h
js/src/vm/Xdr.cpp
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -117,17 +117,17 @@ class HashTable : private AllocPolicy
         T *operator->() const                 { return &entry->t; }
     };
 
     /* A Ptr that can be used to add a key after a failed lookup. */
     class AddPtr : public Ptr
     {
         friend class HashTable;
         HashNumber keyHash;
-        DebugOnly<uint64_t> mutationCount;
+        mozilla::DebugOnly<uint64_t> mutationCount;
 
         AddPtr(Entry &entry, HashNumber hn) : Ptr(entry), keyHash(hn) {}
       public:
         /* Leaves AddPtr uninitialized. */
         AddPtr() {}
     };
 
     /*
@@ -142,17 +142,17 @@ class HashTable : private AllocPolicy
         friend class HashTable;
 
         Range(Entry *c, Entry *e) : cur(c), end(e), validEntry(true) {
             while (cur < end && !cur->isLive())
                 ++cur;
         }
 
         Entry *cur, *end;
-        DebugOnly<bool> validEntry;
+        mozilla::DebugOnly<bool> validEntry;
 
       public:
         Range() : cur(NULL), end(NULL), validEntry(false) {}
 
         bool empty() const {
             return cur == end;
         }
 
@@ -263,18 +263,18 @@ class HashTable : private AllocPolicy
         uint32_t        rehashes;       /* tombstone decontaminations */
     } stats;
 #   define METER(x) x
 #else
 #   define METER(x)
 #endif
 
     friend class js::ReentrancyGuard;
-    mutable DebugOnly<bool> entered;
-    DebugOnly<uint64_t>     mutationCount;
+    mutable mozilla::DebugOnly<bool> entered;
+    mozilla::DebugOnly<uint64_t>     mutationCount;
 
     /* The default initial capacity is 16, but you can ask for as small as 4. */
     static const unsigned sMinSizeLog2  = 2;
     static const unsigned sMinSize      = 1 << sMinSizeLog2;
     static const unsigned sDefaultInitSizeLog2 = 4;
   public:
     static const unsigned sDefaultInitSize = 1 << sDefaultInitSizeLog2;
   private:
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -30,17 +30,16 @@ namespace JS {}
 /* The mozilla-shared reusable template/utility namespace. */
 namespace mozilla {}
 
 /* The private JS engine namespace. */
 namespace js {
 
 /* The private namespace is a superset of the public/shared namespaces. */
 using namespace JS;
-using namespace mozilla;
 
 }  /* namespace js */
 
 /*
  * Pattern used to overwrite freed memory. If you are accessing an object with
  * this pattern, you probably have a dangling pointer.
  */
 #define JS_FREE_PATTERN 0xDA
--- a/js/public/Vector.h
+++ b/js/public/Vector.h
@@ -237,17 +237,17 @@ class Vector : private AllocPolicy
      */
     T *mBegin;
     size_t mLength;     /* Number of elements in the Vector. */
     size_t mCapacity;   /* Max number of elements storable in the Vector without resizing. */
 #ifdef DEBUG
     size_t mReserved;   /* Max elements of reserved or used space in this vector. */
 #endif
 
-    AlignedStorage<sInlineBytes> storage;
+    mozilla::AlignedStorage<sInlineBytes> storage;
 
 #ifdef DEBUG
     friend class ReentrancyGuard;
     bool entered;
 #endif
 
     Vector(const Vector &) MOZ_DELETE;
     Vector &operator=(const Vector &) MOZ_DELETE;
@@ -426,17 +426,17 @@ class Vector : private AllocPolicy
      */
     void infallibleAppend(const T &t) {
         internalAppend(t);
     }
     void infallibleAppendN(const T &t, size_t n) {
         internalAppendN(t, n);
     }
     template <class U> void infallibleAppend(const U *begin, const U *end) {
-        internalAppend(begin, PointerRangeSize(begin, end));
+        internalAppend(begin, mozilla::PointerRangeSize(begin, end));
     }
     template <class U> void infallibleAppend(const U *begin, size_t length) {
         internalAppend(begin, length);
     }
     template <class U, size_t O, class BP> void infallibleAppend(const Vector<U,O,BP> &other) {
         internalAppend(other);
     }
 
@@ -857,17 +857,17 @@ Vector<T,N,AP>::erase(T *it)
 }
 
 template <class T, size_t N, class AP>
 template <class U>
 JS_ALWAYS_INLINE bool
 Vector<T,N,AP>::append(const U *insBegin, const U *insEnd)
 {
     REENTRANCY_GUARD_ET_AL;
-    size_t needed = PointerRangeSize(insBegin, insEnd);
+    size_t needed = mozilla::PointerRangeSize(insBegin, insEnd);
     if (mLength + needed > mCapacity && !growStorageBy(needed))
         return false;
 
 #ifdef DEBUG
     if (mLength + needed > mReserved)
         mReserved = mLength + needed;
 #endif
     internalAppend(insBegin, needed);
--- a/js/src/assembler/assembler/MacroAssemblerX86_64.h
+++ b/js/src/assembler/assembler/MacroAssemblerX86_64.h
@@ -121,34 +121,34 @@ public:
         move(X86Registers::eax, scratchRegister);
         move(imm, X86Registers::eax);
         m_assembler.movl_EAXm(address);
         move(scratchRegister, X86Registers::eax);
     }
 
     Call call()
     {
-        js::DebugOnly<DataLabelPtr> label = moveWithPatch(ImmPtr(0), scratchRegister);
+        mozilla::DebugOnly<DataLabelPtr> label = moveWithPatch(ImmPtr(0), scratchRegister);
         Call result = Call(m_assembler.call(scratchRegister), Call::Linkable);
         ASSERT(differenceBetween(label, result) == REPTACH_OFFSET_CALL_R11);
         return result;
     }
 
     Call tailRecursiveCall()
     {
-        js::DebugOnly<DataLabelPtr> label = moveWithPatch(ImmPtr(0), scratchRegister);
+        mozilla::DebugOnly<DataLabelPtr> label = moveWithPatch(ImmPtr(0), scratchRegister);
         Jump newJump = Jump(m_assembler.jmp_r(scratchRegister));
         ASSERT(differenceBetween(label, newJump) == REPTACH_OFFSET_CALL_R11);
         return Call::fromTailJump(newJump);
     }
 
     Call makeTailRecursiveCall(Jump oldJump)
     {
         oldJump.link(this);
-        js::DebugOnly<DataLabelPtr> label = moveWithPatch(ImmPtr(0), scratchRegister);
+        mozilla::DebugOnly<DataLabelPtr> label = moveWithPatch(ImmPtr(0), scratchRegister);
         Jump newJump = Jump(m_assembler.jmp_r(scratchRegister));
         ASSERT(differenceBetween(label, newJump) == REPTACH_OFFSET_CALL_R11);
         return Call::fromTailJump(newJump);
     }
 
 
     void addPtr(RegisterID src, RegisterID dest)
     {
--- a/js/src/builtin/Eval.cpp
+++ b/js/src/builtin/Eval.cpp
@@ -12,16 +12,19 @@
 #include "frontend/BytecodeCompiler.h"
 #include "mozilla/HashFunctions.h"
 #include "vm/GlobalObject.h"
 
 #include "jsinterpinlines.h"
 
 using namespace js;
 
+using mozilla::AddToHash;
+using mozilla::HashString;
+
 // We should be able to assert this for *any* fp->scopeChain().
 static void
 AssertInnerizedScopeChain(JSContext *cx, JSObject &scopeobj)
 {
 #ifdef DEBUG
     for (JSObject *o = &scopeobj; o; o = o->enclosingScope()) {
         if (JSObjectOp op = o->getClass()->ext.innerObject) {
             Rooted<JSObject*> obj(cx, o);
--- a/js/src/builtin/Profilers.cpp
+++ b/js/src/builtin/Profilers.cpp
@@ -20,16 +20,18 @@
 #endif
 
 #ifdef __APPLE__
 #include "devtools/sharkctl.h"
 #endif
 
 using namespace js;
 
+using mozilla::ArrayLength;
+
 /* Thread-unsafe error management */
 
 static char gLastError[2000];
 
 static void
 #ifdef __GNUC__
 __attribute__((unused,format(printf,1,2)))
 #endif
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -12,16 +12,18 @@
 #include "builtin/RegExp.h"
 
 #include "vm/RegExpObject-inl.h"
 #include "vm/RegExpStatics-inl.h"
 
 using namespace js;
 using namespace js::types;
 
+using mozilla::ArrayLength;
+
 class RegExpMatchBuilder
 {
     JSContext   * const cx;
     RootedObject array;
 
     bool setProperty(Handle<PropertyName*> name, HandleValue v) {
         return !!baseops::DefineProperty(cx, array, name, v,
                                          JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE);
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -16,16 +16,18 @@
 
 #include "methodjit/MethodJIT.h"
 
 #include "vm/Stack-inl.h"
 
 using namespace js;
 using namespace JS;
 
+using mozilla::ArrayLength;
+
 static JSBool
 GetBuildConfiguration(JSContext *cx, unsigned argc, jsval *vp)
 {
     RootedObject info(cx, JS_NewObject(cx, NULL, NULL, NULL));
     if (!info)
         return false;
     Value value;
 
--- a/js/src/ds/LifoAlloc.h
+++ b/js/src/ds/LifoAlloc.h
@@ -59,17 +59,17 @@ class BumpChunk
         next_(NULL), bumpSpaceSize(bumpSpaceSize)
     {
         JS_ASSERT(bump == AlignPtr(bump));
     }
 
     void setBump(void *ptr) {
         JS_ASSERT(bumpBase() <= ptr);
         JS_ASSERT(ptr <= limit);
-        DebugOnly<char *> prevBump = bump;
+        mozilla::DebugOnly<char *> prevBump = bump;
         bump = static_cast<char *>(ptr);
 #ifdef DEBUG
         JS_ASSERT(contains(prevBump));
 
         /* Clobber the now-free space. */
         if (prevBump > bump)
             memset(bump, 0xcd, prevBump - bump);
 #endif
@@ -220,17 +220,17 @@ class LifoAlloc
     }
 
     JS_ALWAYS_INLINE
     void *allocInfallible(size_t n) {
         void *result;
         if (latest && (result = latest->tryAlloc(n)))
             return result;
 
-        DebugOnly<BumpChunk *> chunk = getOrCreateChunk(n);
+        mozilla::DebugOnly<BumpChunk *> chunk = getOrCreateChunk(n);
         JS_ASSERT(chunk);
 
         return latest->allocInfallible(n);
     }
 
     // Ensures that enough space exists to satisfy N bytes worth of
     // allocation requests, not necessarily contiguous. Note that this does
     // not guarantee a successful single allocation of N bytes.
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -52,16 +52,18 @@
 /* Macros to compute byte sizes from typed element counts. */
 #define BYTECODE_SIZE(n)        ((n) * sizeof(jsbytecode))
 #define SRCNOTE_SIZE(n)         ((n) * sizeof(jssrcnote))
 
 using namespace js;
 using namespace js::gc;
 using namespace js::frontend;
 
+using mozilla::DebugOnly;
+
 static bool
 SetSrcNoteOffset(JSContext *cx, BytecodeEmitter *bce, unsigned index, unsigned which, ptrdiff_t offset);
 
 struct frontend::StmtInfoBCE : public StmtInfoBase
 {
     StmtInfoBCE     *down;          /* info for enclosing statement */
     StmtInfoBCE     *downScope;     /* next enclosing lexical scope */
 
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -14,16 +14,18 @@
 #include "methodjit/MethodJIT.h"
 
 #include "jsobjinlines.h"
 #include "jsscopeinlines.h"
 
 #include "ion/IonCode.h"
 #include "vm/String-inl.h"
 
+using mozilla::DebugOnly;
+
 void * const js::NullPtr::constNullValue = NULL;
 
 /*
  * There are two mostly separate mark paths. The first is a fast path used
  * internally in the GC. The second is a slow path used for root marking and
  * for API consumers like the cycle collector or Class::trace implementations.
  *
  * The fast path uses explicit stacks. The basic marking process during a GC is
--- a/js/src/gc/Root.h
+++ b/js/src/gc/Root.h
@@ -796,25 +796,21 @@ public:
         LeaveAssertNoGCScope();
 #endif
     }
 };
 
 /*
  * AssertCanGC will assert if it is called inside of an AutoAssertNoGC region.
  */
-#ifdef DEBUG
 JS_ALWAYS_INLINE void
 AssertCanGC()
 {
     JS_ASSERT(!InNoGCScope());
 }
-#else
-# define AssertCanGC()
-#endif
 
 #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
 extern void
 CheckStackRoots(JSContext *cx);
 #endif
 
 JS_FRIEND_API(bool) NeedRelaxedRootChecks();
 
--- a/js/src/ion/Bailouts.h
+++ b/js/src/ion/Bailouts.h
@@ -118,17 +118,17 @@ class BailoutClosure
     // declaration is used by the destructor to restore the stack in the
     // expected order when classes are created. This class is only created
     // when we need a new stack frame.
     struct Guards {
         InvokeArgsGuard iag;
         BailoutFrameGuard bfg;
     };
 
-    Maybe<Guards> guards_;
+    mozilla::Maybe<Guards> guards_;
 
     StackFrame *entryfp_;
     jsbytecode *bailoutPc_;
 
   public:
     BailoutClosure()
       : bailoutPc_(NULL)
     { }
--- a/js/src/ion/CodeGenerator.cpp
+++ b/js/src/ion/CodeGenerator.cpp
@@ -14,16 +14,18 @@
 #include "jsmath.h"
 #include "jsinterpinlines.h"
 
 #include "vm/StringObject-inl.h"
 
 using namespace js;
 using namespace js::ion;
 
+using mozilla::DebugOnly;
+
 namespace js {
 namespace ion {
 
 StringObject *
 MNewStringObject::templateObj() const {
     return &templateObj_->asString();
 }
 
--- a/js/src/ion/InlineList.h
+++ b/js/src/ion/InlineList.h
@@ -36,17 +36,17 @@ class InlineForwardListNode
 template <typename T>
 class InlineForwardList : protected InlineForwardListNode<T>
 {
     friend class InlineForwardListIterator<T>;
 
     typedef InlineForwardListNode<T> Node;
 
     Node *tail_;
-    DebugOnly<int> modifyCount_;
+    mozilla::DebugOnly<int> modifyCount_;
 
     InlineForwardList<T> *thisFromConstructor() {
         return this;
     }
 
   public:
     InlineForwardList()
       : tail_(thisFromConstructor())
@@ -178,17 +178,17 @@ public:
 
 private:
     Node *prev;
     Node *iter;
 
 #ifdef DEBUG
     const InlineForwardList<T> *owner_;
 #endif
-    DebugOnly<int> modifyCount_;
+    mozilla::DebugOnly<int> modifyCount_;
 };
 
 template <typename T> class InlineList;
 template <typename T> class InlineListIterator;
 template <typename T> class InlineListReverseIterator;
 
 template <typename T>
 class InlineListNode : public InlineForwardListNode<T>
--- a/js/src/ion/IonBuilder.cpp
+++ b/js/src/ion/IonBuilder.cpp
@@ -18,16 +18,18 @@
 
 #ifdef JS_THREADSAFE
 # include "prthread.h"
 #endif
 
 using namespace js;
 using namespace js::ion;
 
+using mozilla::DebugOnly;
+
 IonBuilder::IonBuilder(JSContext *cx, TempAllocator *temp, MIRGraph *graph,
                        TypeOracle *oracle, CompileInfo *info, size_t inliningDepth, uint32 loopDepth)
   : MIRGenerator(cx->compartment, temp, graph, info),
     recompileInfo(cx->compartment->types.compiledInfo),
     backgroundCompiledLir(NULL),
     cx(cx),
     loopDepth_(loopDepth),
     callerResumePoint_(NULL),
--- a/js/src/ion/IonCaches.cpp
+++ b/js/src/ion/IonCaches.cpp
@@ -17,16 +17,18 @@
 #include "jsinterpinlines.h"
 
 #include "vm/Stack.h"
 #include "IonFrames-inl.h"
 
 using namespace js;
 using namespace js::ion;
 
+using mozilla::DebugOnly;
+
 void
 CodeLocationJump::repoint(IonCode *code, MacroAssembler *masm)
 {
     JS_ASSERT(!absolute_);
     size_t new_off = (size_t)raw_;
 #ifdef JS_SMALL_BRANCH
     size_t jumpTableEntryOffset = reinterpret_cast<size_t>(jumpTableEntry_);
 #endif
--- a/js/src/ion/IonCaches.h
+++ b/js/src/ion/IonCaches.h
@@ -52,28 +52,28 @@ class IonCacheName;
 //
 // Similarly, despite the presence of functions and multiple stubs generated
 // for a cache, the cache itself may be marked as idempotent and become hoisted
 // or coalesced by LICM or GVN. This also constrains the stubs which can be
 // generated for the cache.
 
 struct TypedOrValueRegisterSpace
 {
-    AlignedStorage2<TypedOrValueRegister> data_;
+    mozilla::AlignedStorage2<TypedOrValueRegister> data_;
     TypedOrValueRegister &data() {
         return *data_.addr();
     }
     const TypedOrValueRegister &data() const {
         return *data_.addr();
     }
 };
 
 struct ConstantOrRegisterSpace
 {
-    AlignedStorage2<ConstantOrRegister> data_;
+    mozilla::AlignedStorage2<ConstantOrRegister> data_;
     ConstantOrRegister &data() {
         return *data_.addr();
     }
     const ConstantOrRegister &data() const {
         return *data_.addr();
     }
 };
 
--- a/js/src/ion/IonFrames.h
+++ b/js/src/ion/IonFrames.h
@@ -102,17 +102,17 @@ class SafepointIndex
 
     union {
         LSafepoint *safepoint_;
 
         // Offset to the start of the encoded safepoint in the safepoint stream.
         uint32 safepointOffset_;
     };
 
-    DebugOnly<bool> resolved;
+    mozilla::DebugOnly<bool> resolved;
 
   public:
     SafepointIndex(uint32 displacement, LSafepoint *safepoint)
       : displacement_(displacement),
         safepoint_(safepoint),
         resolved(false)
     { }
 
--- a/js/src/ion/IonMacroAssembler.h
+++ b/js/src/ion/IonMacroAssembler.h
@@ -20,17 +20,17 @@
 #include "ion/TypeOracle.h"
 
 #include "jsscope.h"
 #include "jstypedarray.h"
 #include "jscompartment.h"
 
 namespace js {
 namespace ion {
- 
+
 // The public entrypoint for emitting assembly. Note that a MacroAssembler can
 // use cx->lifoAlloc, so take care not to interleave masm use with other
 // lifoAlloc use if one will be destroyed before the other.
 class MacroAssembler : public MacroAssemblerSpecific
 {
     MacroAssembler *thisFromCtor() {
         return this;
     }
@@ -47,18 +47,18 @@ class MacroAssembler : public MacroAssem
         { }
 
         MacroAssembler *masm() const {
             return masm_;
         }
     };
 
     AutoRooter autoRooter_;
-    Maybe<IonContext> ionContext_;
-    Maybe<AutoIonContextAlloc> alloc_;
+    mozilla::Maybe<IonContext> ionContext_;
+    mozilla::Maybe<AutoIonContextAlloc> alloc_;
     bool enoughMemory_;
 
   private:
     // This field is used to manage profiling instrumentation output. If
     // provided and enabled, then instrumentation will be emitted around call
     // sites. The IonInstrumentation instance is hosted inside of
     // CodeGeneratorShared and is the manager of when instrumentation is
     // actually emitted or not. If NULL, then no instrumentation is emitted.
--- a/js/src/ion/LinearScan.cpp
+++ b/js/src/ion/LinearScan.cpp
@@ -10,16 +10,18 @@
 #include "LinearScan.h"
 #include "IonBuilder.h"
 #include "IonSpewer.h"
 #include "LIR-inl.h"
 
 using namespace js;
 using namespace js::ion;
 
+using mozilla::DebugOnly;
+
 static bool
 UseCompatibleWith(const LUse *use, LAllocation alloc)
 {
     switch (use->policy()) {
       case LUse::ANY:
       case LUse::KEEPALIVE:
         return alloc.isRegister() || alloc.isMemory();
       case LUse::REGISTER:
--- a/js/src/ion/LinearScan.h
+++ b/js/src/ion/LinearScan.h
@@ -264,17 +264,17 @@ class LiveInterval
     }
 
     size_t numRanges() const {
         return ranges_.length();
     }
     const Range *getRange(size_t i) const {
         return &ranges_[i];
     }
-    void setLastProcessedRange(size_t range, DebugOnly<CodePosition> pos) {
+    void setLastProcessedRange(size_t range, mozilla::DebugOnly<CodePosition> pos) {
         // If the range starts after pos, we may not be able to use
         // it in the next lastProcessedRangeIfValid call.
         JS_ASSERT(ranges_[range].from <= pos);
         lastProcessedRange_ = range;
     }
     size_t lastProcessedRangeIfValid(CodePosition pos) const {
         if (lastProcessedRange_ < ranges_.length() && ranges_[lastProcessedRange_].from <= pos)
             return lastProcessedRange_;
--- a/js/src/ion/RegisterSets.h
+++ b/js/src/ion/RegisterSets.h
@@ -132,18 +132,18 @@ class ValueOperand
 // Registers to hold either either a typed or untyped value.
 class TypedOrValueRegister
 {
     // Type of value being stored.
     MIRType type_;
 
     // Space to hold either an AnyRegister or a ValueOperand.
     union U {
-        AlignedStorage2<AnyRegister> typed;
-        AlignedStorage2<ValueOperand> value;
+        mozilla::AlignedStorage2<AnyRegister> typed;
+        mozilla::AlignedStorage2<ValueOperand> value;
     } data;
 
     AnyRegister &dataTyped() {
         JS_ASSERT(hasTyped());
         return *data.typed.addr();
     }
     ValueOperand &dataValue() {
         JS_ASSERT(hasValue());
@@ -192,18 +192,18 @@ class TypedOrValueRegister
 // A constant value, or registers to hold a typed/untyped value.
 class ConstantOrRegister
 {
     // Whether a constant value is being stored.
     bool constant_;
 
     // Space to hold either a Value or a TypedOrValueRegister.
     union U {
-        AlignedStorage2<Value> constant;
-        AlignedStorage2<TypedOrValueRegister> reg;
+        mozilla::AlignedStorage2<Value> constant;
+        mozilla::AlignedStorage2<TypedOrValueRegister> reg;
     } data;
 
     Value &dataValue() {
         JS_ASSERT(constant());
         return *data.constant.addr();
     }
     TypedOrValueRegister &dataReg() {
         JS_ASSERT(!constant());
--- a/js/src/ion/arm/MacroAssembler-arm.h
+++ b/js/src/ion/arm/MacroAssembler-arm.h
@@ -9,16 +9,18 @@
 #define jsion_macro_assembler_arm_h__
 
 #include "ion/arm/Assembler-arm.h"
 #include "ion/IonCaches.h"
 #include "ion/IonFrames.h"
 #include "ion/MoveResolver.h"
 #include "jsopcode.h"
 
+using mozilla::DebugOnly;
+
 namespace js {
 namespace ion {
 
 static Register CallReg = ip;
 static const int defaultShift = 3;
 JS_STATIC_ASSERT(1 << defaultShift == sizeof(jsval));
 
 // MacroAssemblerARM is inheriting form Assembler defined in Assembler-arm.{h,cpp}
--- a/js/src/ion/shared/Assembler-shared.h
+++ b/js/src/ion/shared/Assembler-shared.h
@@ -158,17 +158,17 @@ struct LabelBase
     // uses and needs to be bound.
     int32 offset_ : 31;
     bool bound_   : 1;
 
     // Disallow assignment.
     void operator =(const LabelBase &label);
     static int id_count;
   public:
-    DebugOnly <int> id;
+    mozilla::DebugOnly <int> id;
     static const int32 INVALID_OFFSET = -1;
 
     LabelBase() : offset_(INVALID_OFFSET), bound_(false), id(id_count++)
     { }
     LabelBase(const LabelBase &label)
       : offset_(label.offset_),
         bound_(label.bound_),
         id(id_count++)
@@ -404,17 +404,17 @@ class CodeOffsetLabel
 // Absolute location of a jump or a label in some generated IonCode block.
 // Can also encode a CodeOffset{Jump,Label}, such that the offset is initially
 // set and the absolute location later filled in after the final IonCode is
 // allocated.
 
 class CodeLocationJump
 {
     uint8 *raw_;
-    DebugOnly<bool> absolute_;
+    mozilla::DebugOnly<bool> absolute_;
 
 #ifdef JS_SMALL_BRANCH
     uint8 *jumpTableEntry_;
 #endif
 
   public:
     CodeLocationJump() {}
     CodeLocationJump(IonCode *code, CodeOffsetJump base) {
@@ -447,17 +447,17 @@ class CodeLocationJump
         return jumpTableEntry_;
     }
 #endif
 };
 
 class CodeLocationLabel
 {
     uint8 *raw_;
-    DebugOnly<bool> absolute_;
+    mozilla::DebugOnly<bool> absolute_;
 
   public:
     CodeLocationLabel() {}
     CodeLocationLabel(IonCode *code, CodeOffsetLabel base) {
         *this = base;
         repoint(code);
     }
     CodeLocationLabel(IonCode *code) {
--- a/js/src/ion/shared/CodeGenerator-shared.cpp
+++ b/js/src/ion/shared/CodeGenerator-shared.cpp
@@ -7,19 +7,22 @@
 
 #include "CodeGenerator-shared.h"
 #include "ion/MIRGenerator.h"
 #include "ion/IonFrames-inl.h"
 #include "ion/MIR.h"
 #include "CodeGenerator-shared-inl.h"
 #include "ion/IonSpewer.h"
 #include "ion/IonMacroAssembler.h"
+
 using namespace js;
 using namespace js::ion;
 
+using mozilla::DebugOnly;
+
 namespace js {
 namespace ion {
 
 CodeGeneratorShared::CodeGeneratorShared(MIRGenerator *gen, LIRGraph &graph)
   : oolIns(NULL),
     masm(&sps_),
     gen(gen),
     graph(graph),
--- a/js/src/ion/shared/MacroAssembler-x86-shared.h
+++ b/js/src/ion/shared/MacroAssembler-x86-shared.h
@@ -352,17 +352,17 @@ class MacroAssemblerX86Shared : public A
     template <typename T>
     void computeEffectiveAddress(const T &address, Register dest) {
         lea(Operand(address), dest);
     }
 
     // Builds an exit frame on the stack, with a return address to an internal
     // non-function. Returns offset to be passed to markSafepointAt().
     bool buildFakeExitFrame(const Register &scratch, uint32 *offset) {
-        DebugOnly<uint32> initialDepth = framePushed();
+        mozilla::DebugOnly<uint32> initialDepth = framePushed();
 
         CodeLabel *cl = new CodeLabel();
         if (!addCodeLabel(cl))
             return false;
         mov(cl->dest(), scratch);
 
         uint32 descriptor = MakeFrameDescriptor(framePushed(), IonFrame_OptimizedJS);
         Push(Imm32(descriptor));
--- a/js/src/ion/x86/CodeGenerator-x86.cpp
+++ b/js/src/ion/x86/CodeGenerator-x86.cpp
@@ -11,16 +11,18 @@
 #include "ion/MIRGraph.h"
 #include "jsnum.h"
 #include "jsscope.h"
 #include "jsscriptinlines.h"
 
 using namespace js;
 using namespace js::ion;
 
+using mozilla::DebugOnly;
+
 CodeGeneratorX86::CodeGeneratorX86(MIRGenerator *gen, LIRGraph &graph)
   : CodeGeneratorX86Shared(gen, graph)
 {
 }
 
 // The first two size classes are 128 and 256 bytes respectively. After that we
 // increment by 512.
 static const uint32 LAST_FRAME_SIZE = 512;
--- a/js/src/jsanalyze.cpp
+++ b/js/src/jsanalyze.cpp
@@ -7,16 +7,18 @@
 #include "jsanalyze.h"
 #include "jsautooplen.h"
 #include "jscompartment.h"
 #include "jscntxt.h"
 
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 
+using mozilla::DebugOnly;
+
 namespace js {
 namespace analyze {
 
 /////////////////////////////////////////////////////////////////////
 // Bytecode
 /////////////////////////////////////////////////////////////////////
 
 #ifdef DEBUG
--- a/js/src/jsapi-tests/testIndexToString.cpp
+++ b/js/src/jsapi-tests/testIndexToString.cpp
@@ -10,17 +10,17 @@
 
 #include "jscntxt.h"
 #include "jscompartment.h"
 #include "jsnum.h"
 #include "jsstr.h"
 
 #include "vm/String-inl.h"
 
-using namespace mozilla;
+using mozilla::ArrayLength;
 
 template<size_t N> JSFlatString *
 NewString(JSContext *cx, const jschar (&chars)[N])
 {
     return js_NewStringCopyN(cx, chars, N);
 }
 
 static const struct TestPair {
--- a/js/src/jsapi-tests/testIntern.cpp
+++ b/js/src/jsapi-tests/testIntern.cpp
@@ -2,17 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "tests.h"
 #include "jsatom.h"
 
 #include "vm/String.h"
 
-using namespace mozilla;
+using mozilla::ArrayLength;
 
 BEGIN_TEST(testAtomizedIsNotInterned)
 {
     /* Try to pick a string that won't be interned by other tests in this runtime. */
     static const char someChars[] = "blah blah blah? blah blah blah";
     JSAtom *atom = js::Atomize(cx, someChars, ArrayLength(someChars));
     CHECK(!JS_StringHasBeenInterned(cx, atom));
     CHECK(JS_InternJSString(cx, atom));
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -89,16 +89,19 @@
 
 #ifdef JS_METHODJIT
 #include "ion/Ion.h"
 #endif
 
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
+
+using mozilla::Maybe;
+
 using js::frontend::Parser;
 
 bool
 JS::detail::CallMethodIfWrapped(JSContext *cx, IsAcceptableThis test, NativeImpl impl,
                                CallArgs args)
 {
     const Value &thisv = args.thisv();
     JS_ASSERT(!test(thisv));
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -107,21 +107,24 @@
 #include "jsobjinlines.h"
 #include "jsscopeinlines.h"
 #include "jsstrinlines.h"
 
 #include "vm/ArgumentsObject-inl.h"
 #include "vm/ObjectImpl-inl.h"
 #include "vm/Stack-inl.h"
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 
+using mozilla::ArrayLength;
+using mozilla::DebugOnly;
+using mozilla::PointerRangeSize;
+
 namespace js {
 
 JSBool
 GetLengthProperty(JSContext *cx, HandleObject obj, uint32_t *lengthp)
 {
     if (obj->isArray()) {
         *lengthp = obj->getArrayLength();
         return true;
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -31,20 +31,23 @@
 #include "vm/Xdr.h"
 
 #include "jsstrinlines.h"
 #include "jsatominlines.h"
 #include "jsobjinlines.h"
 
 #include "vm/String-inl.h"
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 
+using mozilla::ArrayEnd;
+using mozilla::ArrayLength;
+using mozilla::RangedPtr;
+
 const char *
 js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes)
 {
     return js_ValueToPrintable(cx, StringValue(atom), bytes);
 }
 
 const char * js::TypeStrings[] = {
     js_undefined_str,
--- a/js/src/jsatom.h
+++ b/js/src/jsatom.h
@@ -30,17 +30,17 @@ struct JSIdArray {
 
 namespace js {
 
 JS_STATIC_ASSERT(sizeof(HashNumber) == 4);
 
 static JS_ALWAYS_INLINE js::HashNumber
 HashId(jsid id)
 {
-    return HashGeneric(JSID_BITS(id));
+    return mozilla::HashGeneric(JSID_BITS(id));
 }
 
 template<>
 struct DefaultHasher<jsid>
 {
     typedef jsid Lookup;
     static HashNumber hash(const Lookup &l) {
         return HashNumber(JSID_BITS(l));
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -62,16 +62,18 @@
 #include "jscompartment.h"
 #include "jsobjinlines.h"
 
 #include "selfhosted.out.h"
 
 using namespace js;
 using namespace js::gc;
 
+using mozilla::DebugOnly;
+
 bool
 js::AutoCycleDetector::init()
 {
     ObjectSet &set = cx->cycleDetectorSet;
     hashsetAddPointer = set.lookupForAdd(obj);
     if (!hashsetAddPointer) {
         if (!set.add(hashsetAddPointer, obj))
             return false;
--- a/js/src/jscntxtinlines.h
+++ b/js/src/jscntxtinlines.h
@@ -29,17 +29,17 @@ NewObjectCache::staticAsserts()
     JS_STATIC_ASSERT(NewObjectCache::MAX_OBJ_SIZE == sizeof(JSObject_Slots16));
     JS_STATIC_ASSERT(gc::FINALIZE_OBJECT_LAST == gc::FINALIZE_OBJECT16_BACKGROUND);
 }
 
 inline bool
 NewObjectCache::lookup(Class *clasp, gc::Cell *key, gc::AllocKind kind, EntryIndex *pentry)
 {
     uintptr_t hash = (uintptr_t(clasp) ^ uintptr_t(key)) + kind;
-    *pentry = hash % js::ArrayLength(entries);
+    *pentry = hash % mozilla::ArrayLength(entries);
 
     Entry *entry = &entries[*pentry];
 
     /* N.B. Lookups with the same clasp/key but different kinds map to different entries. */
     return (entry->clasp == clasp && entry->key == key);
 }
 
 inline bool
@@ -59,17 +59,17 @@ inline bool
 NewObjectCache::lookupType(Class *clasp, js::types::TypeObject *type, gc::AllocKind kind, EntryIndex *pentry)
 {
     return lookup(clasp, type, kind, pentry);
 }
 
 inline void
 NewObjectCache::fill(EntryIndex entry_, Class *clasp, gc::Cell *key, gc::AllocKind kind, JSObject *obj)
 {
-    JS_ASSERT(unsigned(entry_) < ArrayLength(entries));
+    JS_ASSERT(unsigned(entry_) < mozilla::ArrayLength(entries));
     Entry *entry = &entries[entry_];
 
     JS_ASSERT(!obj->hasDynamicSlots() && !obj->hasDynamicElements());
 
     entry->clasp = clasp;
     entry->key = key;
     entry->kind = kind;
 
@@ -97,17 +97,17 @@ NewObjectCache::fillType(EntryIndex entr
 {
     JS_ASSERT(obj->type() == type);
     return fill(entry, clasp, type, kind, obj);
 }
 
 inline JSObject *
 NewObjectCache::newObjectFromHit(JSContext *cx, EntryIndex entry_)
 {
-    JS_ASSERT(unsigned(entry_) < ArrayLength(entries));
+    JS_ASSERT(unsigned(entry_) < mozilla::ArrayLength(entries));
     Entry *entry = &entries[entry_];
 
     JSObject *obj = js_TryNewGCObject(cx, entry->kind);
     if (obj) {
         copyCachedToObject(obj, reinterpret_cast<JSObject *>(&entry->templateObject));
         Probes::createObject(cx, obj);
         return obj;
     }
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -33,20 +33,21 @@
 #include "ion/IonCompartment.h"
 #include "ion/Ion.h"
 #endif
 
 #if ENABLE_YARR_JIT
 #include "assembler/jit/ExecutableAllocator.h"
 #endif
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 
+using mozilla::DebugOnly;
+
 JSCompartment::JSCompartment(JSRuntime *rt)
   : rt(rt),
     principals(NULL),
     global_(NULL),
 #ifdef JSGC_GENERATIONAL
     gcStoreBuffer(&gcNursery),
 #endif
     needsBarrier_(false),
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -566,21 +566,21 @@ class AutoEnterAtomsCompartment
 
 /*
  * Use this to change the behavior of an AutoCompartment slightly on error. If
  * the exception happens to be an Error object, copy it to the origin compartment
  * instead of wrapping it.
  */
 class ErrorCopier
 {
-    Maybe<AutoCompartment> &ac;
+    mozilla::Maybe<AutoCompartment> &ac;
     RootedObject scope;
 
   public:
-    ErrorCopier(Maybe<AutoCompartment> &ac, JSObject *scope)
+    ErrorCopier(mozilla::Maybe<AutoCompartment> &ac, JSObject *scope)
       : ac(ac), scope(ac.ref().context(), scope) {}
     ~ErrorCopier();
 };
 
 class CompartmentsIter {
   private:
     JSCompartment **it, **end;
 
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -45,20 +45,21 @@
 #include "vm/NumericConversions.h"
 #include "vm/StringBuffer.h"
 
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 
 #include "vm/Stack-inl.h"
 
-using namespace mozilla;
 using namespace js;
 using namespace js::types;
 
+using mozilla::ArrayLength;
+
 /*
  * The JS 'Date' object is patterned after the Java 'Date' object.
  * Here is an script:
  *
  *    today = new Date();
  *
  *    print(today.toLocaleString());
  *
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -44,17 +44,18 @@
 
 #include "vm/Stack-inl.h"
 
 #include "jsautooplen.h"
 #include "mozilla/Util.h"
 
 using namespace js;
 using namespace js::gc;
-using namespace mozilla;
+
+using mozilla::DebugOnly;
 
 JS_PUBLIC_API(JSBool)
 JS_GetDebugMode(JSContext *cx)
 {
     return cx->compartment->debugMode();
 }
 
 JS_PUBLIC_API(JSBool)
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -35,21 +35,22 @@
 #include "vm/StringBuffer.h"
 
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 
 #include "vm/Stack-inl.h"
 #include "vm/String-inl.h"
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 
+using mozilla::ArrayLength;
+
 /* Forward declarations for ErrorClass's initializer. */
 static JSBool
 Exception(JSContext *cx, unsigned argc, Value *vp);
 
 static void
 exn_trace(JSTracer *trc, RawObject obj);
 
 static void
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -60,22 +60,23 @@
 #include "vm/Stack-inl.h"
 
 #ifdef JS_ION
 #include "ion/Ion.h"
 #include "ion/IonFrameIterator.h"
 #include "ion/IonFrameIterator-inl.h"
 #endif
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 using namespace js::frontend;
 
+using mozilla::ArrayLength;
+
 static JSBool
 fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValue vp)
 {
     RootedObject obj(cx, obj_);
     while (!obj->isFunction()) {
         if (!JSObject::getProto(cx, obj, &obj))
             return false;
         if (!obj)
--- a/js/src/jsfuninlines.h
+++ b/js/src/jsfuninlines.h
@@ -81,32 +81,32 @@ JSFunction::setJitInfo(const JSJitInfo *
     u.n.jitinfo = data;
 }
 
 inline void
 JSFunction::initializeExtended()
 {
     JS_ASSERT(isExtended());
 
-    JS_ASSERT(js::ArrayLength(toExtended()->extendedSlots) == 2);
+    JS_ASSERT(mozilla::ArrayLength(toExtended()->extendedSlots) == 2);
     toExtended()->extendedSlots[0].init(js::UndefinedValue());
     toExtended()->extendedSlots[1].init(js::UndefinedValue());
 }
 
 inline void
 JSFunction::setExtendedSlot(size_t which, const js::Value &val)
 {
-    JS_ASSERT(which < js::ArrayLength(toExtended()->extendedSlots));
+    JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
     toExtended()->extendedSlots[which] = val;
 }
 
 inline const js::Value &
 JSFunction::getExtendedSlot(size_t which) const
 {
-    JS_ASSERT(which < js::ArrayLength(toExtended()->extendedSlots));
+    JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
     return toExtended()->extendedSlots[which];
 }
 
 namespace js {
 
 static JS_ALWAYS_INLINE bool
 IsFunctionObject(const js::Value &v)
 {
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -103,20 +103,23 @@
 #else
 # include <unistd.h>
 #endif
 
 #if JS_TRACE_LOGGING
 #include "TraceLogging.h"
 #endif
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 
+using mozilla::ArrayEnd;
+using mozilla::DebugOnly;
+using mozilla::Maybe;
+
 namespace js {
 
 namespace gc {
 
 /* Perform a Full GC every 20 seconds if MaybeGC is called */
 static const uint64_t GC_IDLE_FULL_SPAN = 20 * 1000 * 1000;
 
 /* Increase the IGC marking slice time if we are in highFrequencyGC mode. */
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -1032,22 +1032,22 @@ struct GCMarker : public JSTracer {
     inline void processMarkStackTop(SliceBudget &budget);
     void processMarkStackOther(SliceBudget &budget, uintptr_t tag, uintptr_t addr);
 
     void appendGrayRoot(void *thing, JSGCTraceKind kind);
 
     /* The color is only applied to objects, functions and xml. */
     uint32_t color;
 
-    DebugOnly<bool> started;
+    mozilla::DebugOnly<bool> started;
 
     /* Pointer to the top of the stack of arenas we are delaying marking on. */
     js::gc::ArenaHeader *unmarkedArenaStackTop;
     /* Count of arenas that are currently in the stack. */
-    DebugOnly<size_t> markLaterArenas;
+    mozilla::DebugOnly<size_t> markLaterArenas;
 
     struct GrayRoot {
         void *thing;
         JSGCTraceKind kind;
 #ifdef DEBUG
         JSTraceNamePrinter debugPrinter;
         const void *debugPrintArg;
         size_t debugPrintIndex;
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -9,19 +9,21 @@
 
 #include "jsgc.h"
 #include "jscntxt.h"
 #include "jscompartment.h"
 #include "jslock.h"
 #include "jsscope.h"
 #include "jsxml.h"
 
+#include "gc/Root.h"
+
 #include "js/TemplateLib.h"
 
-using namespace JS;
+using JS::AssertCanGC;
 
 namespace js {
 
 struct Shape;
 
 namespace gc {
 
 inline JSGCTraceKind
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -49,16 +49,18 @@
 #ifdef __SUNPRO_CC
 #include <alloca.h>
 #endif
 
 using namespace js;
 using namespace js::types;
 using namespace js::analyze;
 
+using mozilla::DebugOnly;
+
 static inline jsid
 id_prototype(JSContext *cx) {
     return NameToId(cx->names().classPrototype);
 }
 
 static inline jsid
 id_length(JSContext *cx) {
     return NameToId(cx->names().length);
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -77,16 +77,18 @@
 #if JS_TRACE_LOGGING
 #include "TraceLogging.h"
 #endif
 
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 
+using mozilla::DebugOnly;
+
 /* Some objects (e.g., With) delegate 'this' to another object. */
 static inline JSObject *
 CallThisObjectHook(JSContext *cx, HandleObject obj, Value *argv)
 {
     JSObject *thisp = JSObject::thisObject(cx, obj);
     if (!thisp)
         return NULL;
     argv[-1].setObject(*thisp);
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -45,20 +45,21 @@
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 
 #include "builtin/ParallelArray-inl.h"
 #include "builtin/Iterator-inl.h"
 #include "vm/Stack-inl.h"
 #include "vm/String-inl.h"
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 
+using mozilla::ArrayLength;
+
 static const gc::AllocKind ITERATOR_FINALIZE_KIND = gc::FINALIZE_OBJECT2;
 
 void
 NativeIterator::mark(JSTracer *trc)
 {
     for (HeapPtr<JSFlatString> *str = begin(); str < end(); str++)
         MarkString(trc, str, "prop");
     if (obj)
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -53,16 +53,18 @@
 #include "jsobjinlines.h"
 
 #include "vm/NumberObject-inl.h"
 #include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::types;
 
+using mozilla::RangedPtr;
+
 /*
  * If we're accumulating a decimal number and the number is >= 2^53, then the
  * fast result from the loop in GetPrefixInteger may be inaccurate. Call
  * js_strtod_harder to get the correct answer.
  */
 static bool
 ComputeAccurateDecimalInteger(JSContext *cx, const jschar *start, const jschar *end, double *dp)
 {
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -63,21 +63,22 @@
 #include "jsscriptinlines.h"
 
 #include "vm/BooleanObject-inl.h"
 #include "vm/NumberObject-inl.h"
 #include "vm/StringObject-inl.h"
 
 #include "jsautooplen.h"
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
+
 using js::frontend::IsIdentifier;
+using mozilla::ArrayLength;
 
 JS_STATIC_ASSERT(int32_t((JSObject::NELEMENTS_LIMIT - 1) * sizeof(Value)) == int64_t((JSObject::NELEMENTS_LIMIT - 1) * sizeof(Value)));
 
 Class js::ObjectClass = {
     js_Object_str,
     JSCLASS_HAS_CACHED_PROTO(JSProto_Object),
     JS_PropertyStub,         /* addProperty */
     JS_PropertyStub,         /* delProperty */
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -35,16 +35,18 @@
 #include "jsobjinlines.h"
 
 #include "vm/Stack-inl.h"
 
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 
+using mozilla::Maybe;
+
 Class js::JSONClass = {
     js_JSON_str,
     JSCLASS_HAS_CACHED_PROTO(JSProto_JSON),
     JS_PropertyStub,        /* addProperty */
     JS_PropertyStub,        /* delProperty */
     JS_PropertyStub,        /* getProperty */
     JS_StrictPropertyStub,  /* setProperty */
     JS_EnumerateStub,
--- a/js/src/jsonparser.cpp
+++ b/js/src/jsonparser.cpp
@@ -10,16 +10,18 @@
 #include "jsonparser.h"
 
 #include "vm/StringBuffer.h"
 
 #include "jsobjinlines.h"
 
 using namespace js;
 
+using mozilla::RangedPtr;
+
 void
 JSONParser::error(const char *msg)
 {
     if (errorHandling == RaiseError)
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE, msg);
 }
 
 bool
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -47,22 +47,23 @@
 #include "jscntxtinlines.h"
 #include "jsobjinlines.h"
 #include "jsopcodeinlines.h"
 
 #include "jsautooplen.h"
 
 #include "vm/RegExpObject-inl.h"
 
-using namespace mozilla;
 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. */
 #define OPDEF(op,val,name,token,length,nuses,ndefs,prec,format)               \
--- a/js/src/jsreflect.cpp
+++ b/js/src/jsreflect.cpp
@@ -26,20 +26,22 @@
 #include "jsnum.h"
 
 #include "frontend/Parser.h"
 #include "frontend/TokenStream.h"
 #include "vm/RegExpObject.h"
 
 #include "jsscriptinlines.h"
 
-using namespace mozilla;
 using namespace js;
 using namespace js::frontend;
 
+using mozilla::DebugOnly;
+using mozilla::ArrayLength;
+
 namespace js {
 
 char const *aopNames[] = {
     "=",    /* AOP_ASSIGN */
     "+=",   /* AOP_PLUS */
     "-=",   /* AOP_MINUS */
     "*=",   /* AOP_STAR */
     "/=",   /* AOP_DIV */
--- a/js/src/jsscope.cpp
+++ b/js/src/jsscope.cpp
@@ -29,16 +29,18 @@
 #include "jsatominlines.h"
 #include "jscntxtinlines.h"
 #include "jsobjinlines.h"
 #include "jsscopeinlines.h"
 
 using namespace js;
 using namespace js::gc;
 
+using mozilla::DebugOnly;
+
 bool
 ShapeTable::init(JSRuntime *rt, Shape *lastProp)
 {
     /*
      * Either we're creating a table for a large scope that was populated
      * via property cache hit logic under JSOP_INITPROP, JSOP_SETNAME, or
      * JSOP_SETPROP; or else calloc failed at least once already. In any
      * event, let's try to grow, overallocating to hold at least twice the
--- a/js/src/jsscope.h
+++ b/js/src/jsscope.h
@@ -889,17 +889,17 @@ class AutoRooterGetterSetter
         if (attrs & (JSPROP_GETTER | JSPROP_SETTER))
             inner.construct(cx, attrs, pgetter, psetter);
         JS_GUARD_OBJECT_NOTIFIER_INIT;
     }
 
     friend void AutoGCRooter::trace(JSTracer *trc);
 
   private:
-    Maybe<Inner> inner;
+    mozilla::Maybe<Inner> inner;
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 struct EmptyShape : public js::Shape
 {
     EmptyShape(UnownedBaseShape *base, uint32_t nfixed);
 
     /*
--- a/js/src/jsscopeinlines.h
+++ b/js/src/jsscopeinlines.h
@@ -154,17 +154,17 @@ StackBaseShape::updateGetterSetter(uint8
 inline void
 BaseShape::adoptUnowned(UnownedBaseShape *other)
 {
     /*
      * This is a base shape owned by a dictionary object, update it to reflect the
      * unowned base shape of a new last property.
      */
     JS_ASSERT(isOwned());
-    DebugOnly<uint32_t> flags = getObjectFlags();
+    mozilla::DebugOnly<uint32_t> flags = getObjectFlags();
     JS_ASSERT((flags & other->getObjectFlags()) == flags);
 
     uint32_t span = slotSpan();
     ShapeTable *table = &this->table();
 
     *this = *other;
     setOwned(other);
     setTable(table);
--- a/js/src/jstypedarray.cpp
+++ b/js/src/jstypedarray.cpp
@@ -35,21 +35,22 @@
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 #include "jstypedarrayinlines.h"
 
 #include "vm/GlobalObject-inl.h"
 
 #define ENABLE_TYPEDARRAY_MOVE
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 
+using mozilla::DebugOnly;
+
 /*
  * Allocate array buffers with the maximum number of fixed slots marked as
  * reserved, so that the fixed slots may be used for the buffer's contents.
  * The last fixed slot is kept for the object's private data.
  */
 static const uint8_t ARRAYBUFFER_RESERVED_SLOTS = JSObject::MAX_FIXED_SLOTS - 1;
 
 static bool
--- a/js/src/jsworkers.cpp
+++ b/js/src/jsworkers.cpp
@@ -7,16 +7,18 @@
 #include "jsworkers.h"
 
 #if JS_ION
 # include "ion/IonBuilder.h"
 #endif
 
 using namespace js;
 
+using mozilla::DebugOnly;
+
 #ifdef JS_PARALLEL_COMPILATION
 
 bool
 js::OffThreadCompilationAvailable(JSContext *cx)
 {
     WorkerThreadState &state = *cx->runtime->workerThreadState;
     return state.numThreads > 0;
 }
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -49,22 +49,23 @@ size_t sE4XObjectsCreated = 0;
 
 #include "vm/Stack-inl.h"
 #include "vm/String-inl.h"
 
 #ifdef DEBUG
 #include <string.h>     /* for #ifdef DEBUG memset calls */
 #endif
 
-using namespace mozilla;
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 using namespace js::frontend;
 
+using mozilla::ArrayLength;
+
 template<class T, class U>
 struct IdentityOp
 {
     typedef JSBool (* compare)(const T *a, const U *b);
 };
 
 template<class T>
 static JSBool
--- a/js/src/methodjit/BaseAssembler.h
+++ b/js/src/methodjit/BaseAssembler.h
@@ -15,16 +15,18 @@
 #include "assembler/moco/MocoStubs.h"
 #include "methodjit/MethodJIT.h"
 #include "methodjit/MachineRegs.h"
 #include "CodeGenIncludes.h"
 #include "jsobjinlines.h"
 #include "jsscopeinlines.h"
 #include "jstypedarrayinlines.h"
 
+using mozilla::DebugOnly;
+
 namespace js {
 namespace mjit {
 
 class Assembler;
 
 // Represents an int32_t property name in generated code, which must be either
 // a RegisterID or a constant value.
 struct Int32Key {
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -40,16 +40,18 @@
 
 using namespace js;
 using namespace js::mjit;
 #if defined(JS_POLYIC) || defined(JS_MONOIC)
 using namespace js::mjit::ic;
 #endif
 using namespace js::analyze;
 
+using mozilla::DebugOnly;
+
 #define RETURN_IF_OOM(retval)                                   \
     JS_BEGIN_MACRO                                              \
         if (oomInVector || masm.oom() || stubcc.masm.oom())     \
             return retval;                                      \
     JS_END_MACRO
 
 static inline bool IsIonEnabled(JSContext *cx)
 {
--- a/js/src/methodjit/FastBuiltins.cpp
+++ b/js/src/methodjit/FastBuiltins.cpp
@@ -12,16 +12,18 @@
 #include "methodjit/Compiler.h"
 #include "methodjit/StubCalls.h"
 #include "methodjit/FrameState-inl.h"
 
 using namespace js;
 using namespace js::mjit;
 using namespace JSC;
 
+using mozilla::DebugOnly;
+
 typedef JSC::MacroAssembler::FPRegisterID FPRegisterID;
 
 CompileStatus
 mjit::Compiler::compileMathAbsInt(FrameEntry *arg)
 {
     RegisterID reg;
     if (arg->isConstant()) {
         reg = frame.allocReg();
--- a/js/src/methodjit/InvokeHelpers.cpp
+++ b/js/src/methodjit/InvokeHelpers.cpp
@@ -37,16 +37,18 @@
 #include "jsautooplen.h"
 
 #include "ion/Ion.h"
 
 using namespace js;
 using namespace js::mjit;
 using namespace JSC;
 
+using mozilla::DebugOnly;
+
 using ic::Repatcher;
 
 static jsbytecode *
 FindExceptionHandler(JSContext *cx)
 {
     StackFrame *fp = cx->fp();
     RootedScript script(cx, fp->script());
 
--- a/js/src/methodjit/Retcon.cpp
+++ b/js/src/methodjit/Retcon.cpp
@@ -17,16 +17,18 @@
 #include "assembler/assembler/RepatchBuffer.h"
 
 #include "jscntxtinlines.h"
 #include "jsinterpinlines.h"
 
 using namespace js;
 using namespace js::mjit;
 
+using mozilla::DebugOnly;
+
 namespace js {
 namespace mjit {
 
 static inline void
 SetRejoinState(StackFrame *fp, const CallSite &site, void **location)
 {
     if (site.rejoin == REJOIN_SCRIPTED) {
         fp->setRejoin(ScriptedRejoin(site.pcOffset));
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -50,16 +50,18 @@
 
 #include "jsautooplen.h"
 
 using namespace js;
 using namespace js::mjit;
 using namespace js::types;
 using namespace JSC;
 
+using mozilla::DebugOnly;
+
 void JS_FASTCALL
 stubs::BindName(VMFrame &f, PropertyName *name_)
 {
     RootedPropertyName name(f.cx, name_);
     RootedObject scope(f.cx);
     if (!LookupNameWithGlobalDefault(f.cx, name, f.fp()->scopeChain(), &scope))
         THROW();
     f.regs.sp[0].setObject(*scope);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -72,20 +72,22 @@
 #ifdef XP_WIN
 #include "jswin.h"
 #endif
 
 #if JS_TRACE_LOGGING
 #include "TraceLogging.h"
 #endif
 
-using namespace mozilla;
 using namespace js;
 using namespace js::cli;
 
+using mozilla::ArrayLength;
+using mozilla::Maybe;
+
 typedef enum JSShellExitCode {
     EXITCODE_RUNTIME_ERROR      = 3,
     EXITCODE_FILE_NOT_FOUND     = 4,
     EXITCODE_OUT_OF_MEMORY      = 5,
     EXITCODE_TIMEOUT            = 6
 } JSShellExitCode;
 
 size_t gStackChunkSize = 8192;
@@ -2795,17 +2797,17 @@ WatchdogMain(void *arg)
             PR_Lock(gWatchdogLock);
 
             /* Wake up any threads doing sleep. */
             PR_NotifyAllCondVar(gSleepWakeup);
         } else {
             int64_t sleepDuration = gWatchdogHasTimeout
                                     ? gWatchdogTimeout - now
                                     : PR_INTERVAL_NO_TIMEOUT;
-            DebugOnly<PRStatus> status =
+            mozilla::DebugOnly<PRStatus> status =
                 PR_WaitCondVar(gWatchdogWakeup, sleepDuration);
             JS_ASSERT(status == PR_SUCCESS);
         }
     }
     PR_Unlock(gWatchdogLock);
 }
 
 static bool
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -22,17 +22,19 @@
 #include "frontend/BytecodeEmitter.h"
 #include "gc/Marking.h"
 #include "methodjit/Retcon.h"
 #include "js/Vector.h"
 
 #include "vm/Stack-inl.h"
 
 using namespace js;
+
 using js::frontend::IsIdentifier;
+using mozilla::Maybe;
 
 
 /*** Forward declarations ************************************************************************/
 
 extern Class DebuggerFrame_class;
 
 enum {
     JSSLOT_DEBUGFRAME_OWNER,
--- a/js/src/vm/Debugger.h
+++ b/js/src/vm/Debugger.h
@@ -113,17 +113,17 @@ class Debugger {
      *
      * If there is no uncaughtExceptionHook, or if it fails, report and clear
      * the pending exception on ac.context and return JSTRAP_ERROR.
      *
      * This always calls ac.leave(); ac is a parameter because this method must
      * do some things in the debugger compartment and some things in the
      * debuggee compartment.
      */
-    JSTrapStatus handleUncaughtException(Maybe<AutoCompartment> &ac, Value *vp, bool callHook);
+    JSTrapStatus handleUncaughtException(mozilla::Maybe<AutoCompartment> &ac, Value *vp, bool callHook);
 
     /*
      * Handle the result of a hook that is expected to return a resumption
      * value <https://wiki.mozilla.org/Debugger#Resumption_Values>. This is called
      * when we return from a debugging hook to debuggee code. The interpreter wants
      * a (JSTrapStatus, Value) pair telling it how to proceed.
      *
      * Precondition: ac is entered. We are in the debugger compartment.
@@ -140,17 +140,17 @@ class Debugger {
      *         unwrap value. Store the result in *vp and return JSTRAP_RETURN
      *         or JSTRAP_THROW. The interpreter will force the current frame to
      *         return or throw an exception.
      *     null - Return JSTRAP_ERROR to terminate the debuggee with an
      *         uncatchable error.
      *     anything else - Make a new TypeError the pending exception and
      *         return handleUncaughtException(ac, vp, callHook).
      */
-    JSTrapStatus parseResumptionValue(Maybe<AutoCompartment> &ac, bool ok, const Value &rv,
+    JSTrapStatus parseResumptionValue(mozilla::Maybe<AutoCompartment> &ac, bool ok, const Value &rv,
                                       Value *vp, bool callHook = true);
 
     GlobalObject *unwrapDebuggeeArgument(JSContext *cx, const Value &v);
 
     static void traceObject(JSTracer *trc, RawObject obj);
     void trace(JSTracer *trc);
     static void finalize(FreeOp *fop, RawObject obj);
     void markKeysInCompartment(JSTracer *tracer);
@@ -346,17 +346,17 @@ class Debugger {
      *
      * Postcondition: we are in the debugger compartment, having called
      * ac.leave() even if an error occurred.
      *
      * On success, a completion value is in vp and ac.context does not have a
      * pending exception. (This ordinarily returns true even if the ok argument
      * is false.)
      */
-    bool receiveCompletionValue(Maybe<AutoCompartment> &ac, bool ok, Value val, Value *vp);
+    bool receiveCompletionValue(mozilla::Maybe<AutoCompartment> &ac, bool ok, Value val, Value *vp);
 
     /*
      * Return the Debugger.Script object for |script|, or create a new one if
      * needed. The context |cx| must be in the debugger compartment; |script|
      * must be a script in a debuggee compartment.
      */
     JSObject *wrapScript(JSContext *cx, HandleScript script);
 
--- a/js/src/vm/SPSProfiler.cpp
+++ b/js/src/vm/SPSProfiler.cpp
@@ -11,16 +11,18 @@
 #include "methodjit/MethodJIT.h"
 #include "methodjit/Compiler.h"
 
 #include "vm/SPSProfiler.h"
 #include "vm/StringBuffer.h"
 
 using namespace js;
 
+using mozilla::DebugOnly;
+
 SPSProfiler::SPSProfiler(JSRuntime *rt)
   : rt(rt),
     stack_(NULL),
     size_(NULL),
     max_(0),
     slowAssertions(false),
     enabled_(false)
 {
--- a/js/src/vm/SPSProfiler.h
+++ b/js/src/vm/SPSProfiler.h
@@ -256,17 +256,17 @@ class SPSProfiler
 /*
  * This class is used in RunScript() to push the marker onto the sampling stack
  * that we're about to enter JS function calls. This is the only time in which a
  * valid stack pointer is pushed to the sampling stack.
  */
 class SPSEntryMarker
 {
     SPSProfiler *profiler;
-    DebugOnly<uint32_t> size_before;
+    mozilla::DebugOnly<uint32_t> size_before;
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
   public:
     SPSEntryMarker(JSRuntime *rt JS_GUARD_OBJECT_NOTIFIER_PARAM);
     ~SPSEntryMarker();
 };
 
 /*
  * SPS is the profiling backend used by the JS engine to enable time profiling.
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -38,16 +38,18 @@
 #  else
 #   define MAP_ANONYMOUS 0
 #  endif
 # endif
 #endif
 
 using namespace js;
 
+using mozilla::DebugOnly;
+
 /*****************************************************************************/
 
 void
 StackFrame::initExecuteFrame(JSScript *script, StackFrame *prev, FrameRegs *regs,
                              const Value &thisv, JSObject &scopeChain, ExecuteType type)
 {
     /*
      * See encoding of ExecuteType. When GLOBAL isn't set, we are executing a
--- a/js/src/vm/String.cpp
+++ b/js/src/vm/String.cpp
@@ -9,19 +9,20 @@
 
 #include "gc/Marking.h"
 
 #include "String.h"
 #include "String-inl.h"
 
 #include "jsobjinlines.h"
 
-using namespace mozilla;
 using namespace js;
 
+using mozilla::RangedPtr;
+
 bool
 JSString::isShort() const
 {
     // It's possible for short strings to be converted to flat strings;  as a
     // result, checking just for the arena isn't enough to determine if a
     // string is short.  Hence the isInline() check.
     bool is_short = (getAllocKind() == gc::FINALIZE_SHORT_STRING) && isInline();
     JS_ASSERT_IF(is_short, isFlat());
--- a/js/src/vm/StringBuffer.h
+++ b/js/src/vm/StringBuffer.h
@@ -116,19 +116,19 @@ StringBuffer::append(JSString *str)
 }
 
 inline bool
 StringBuffer::appendInflated(const char *cstr, size_t cstrlen)
 {
     size_t lengthBefore = length();
     if (!cb.growByUninitialized(cstrlen))
         return false;
-    DebugOnly<size_t> oldcstrlen = cstrlen;
-    DebugOnly<bool> ok = InflateStringToBuffer(context(), cstr, cstrlen,
-                                               begin() + lengthBefore, &cstrlen);
+    mozilla::DebugOnly<size_t> oldcstrlen = cstrlen;
+    mozilla::DebugOnly<bool> ok = InflateStringToBuffer(context(), cstr, cstrlen,
+                                                        begin() + lengthBefore, &cstrlen);
     JS_ASSERT(ok && oldcstrlen == cstrlen);
     return true;
 }
 
 /* ES5 9.8 ToString, appending the result to the string buffer. */
 extern bool
 ValueToStringBufferSlow(JSContext *cx, const Value &v, StringBuffer &sb);
 
--- a/js/src/vm/Xdr.cpp
+++ b/js/src/vm/Xdr.cpp
@@ -19,19 +19,20 @@
 #include "jsscript.h"
 #include "jsstr.h"
 
 #include "Xdr.h"
 #include "Debugger.h"
 
 #include "jsobjinlines.h"
 
-using namespace mozilla;
 using namespace js;
 
+using mozilla::DebugOnly;
+
 namespace js {
 
 void
 XDRBuffer::freeBuffer()
 {
     js_free(base);
 #ifdef DEBUG
     memset(this, 0xe2, sizeof *this);