Bug 784739 - Switch from NULL to nullptr in js/ductwork/, js/ipc/, and js/public/; r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 19 Sep 2013 15:24:53 -0400
changeset 150142 a84f156f316450e40c01d8eaa78f7e47c940dd01
parent 150141 d7118589114f574ca879b9f1290be9ec40b76290
child 150143 0b174183996f6b26de2ab6ab7a74d4b0c4fabeca
push idunknown
push userunknown
push dateunknown
reviewersehsan
bugs784739
milestone27.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 784739 - Switch from NULL to nullptr in js/ductwork/, js/ipc/, and js/public/; r=ehsan
js/ductwork/debugger/JSDebugger.cpp
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptShared.cpp
js/ipc/JavaScriptShared.h
js/public/CharacterEncoding.h
js/public/Class.h
js/public/GCAPI.h
js/public/HashTable.h
js/public/Id.h
js/public/MemoryMetrics.h
js/public/OldDebugAPI.h
js/public/ProfilingStack.h
js/public/RootingAPI.h
js/public/StructuredClone.h
js/public/Tracer.h
js/public/Utility.h
--- a/js/ductwork/debugger/JSDebugger.cpp
+++ b/js/ductwork/debugger/JSDebugger.cpp
@@ -64,23 +64,23 @@ JSDebugger::AddClass(const JS::Value &gl
 }
 
 }
 }
 
 NS_DEFINE_NAMED_CID(JSDEBUGGER_CID);
 
 static const mozilla::Module::CIDEntry kJSDebuggerCIDs[] = {
-  { &kJSDEBUGGER_CID, false, NULL, mozilla::jsdebugger::JSDebuggerConstructor },
-  { NULL }
+  { &kJSDEBUGGER_CID, false, nullptr, mozilla::jsdebugger::JSDebuggerConstructor },
+  { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kJSDebuggerContracts[] = {
   { JSDEBUGGER_CONTRACTID, &kJSDEBUGGER_CID },
-  { NULL }
+  { nullptr }
 };
 
 static const mozilla::Module kJSDebuggerModule = {
   mozilla::Module::kVersion,
   kJSDebuggerCIDs,
   kJSDebuggerContracts
 };
 
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -479,17 +479,17 @@ CPOWProxyHandler::className(JSContext *c
 
 const char *
 JavaScriptParent::className(JSContext *cx, HandleObject proxy)
 {
     ObjectId objId = idOf(proxy);
 
     nsString name;
     if (!CallClassName(objId, &name))
-        return NULL;
+        return nullptr;
 
     return ToNewCString(name);
 }
 
 void
 CPOWProxyHandler::finalize(JSFreeOp *fop, JSObject *proxy)
 {
     ParentOf(proxy)->drop(proxy);
@@ -552,41 +552,41 @@ JavaScriptParent::getPropertyNames(JSCon
 }
 
 JSObject *
 JavaScriptParent::unwrap(JSContext *cx, ObjectId objId)
 {
     RootedObject obj(cx, findObject(objId));
     if (obj) {
         if (!JS_WrapObject(cx, obj.address()))
-            return NULL;
+            return nullptr;
         return obj;
     }
 
     if (objId > MAX_CPOW_IDS) {
         JS_ReportError(cx, "unusable CPOW id");
-        return NULL;
+        return nullptr;
     }
 
     bool callable = !!(objId & OBJECT_IS_CALLABLE);
 
     RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
 
     RootedValue v(cx, UndefinedValue());
     obj = NewProxyObject(cx,
                          &CPOWProxyHandler::singleton,
                          v,
-                         NULL,
+                         nullptr,
                          global,
                          callable ? ProxyIsCallable : ProxyNotCallable);
     if (!obj)
-        return NULL;
+        return nullptr;
 
     if (!objects_.add(objId, obj))
-        return NULL;
+        return nullptr;
 
     // Incref once we know the decref will be called.
     incref();
 
     SetProxyExtra(obj, 0, PrivateValue(this));
     SetProxyExtra(obj, 1, DoubleValue(BitwiseCast<double>(objId)));
     return obj;
 }
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -35,17 +35,17 @@ ObjectStore::trace(JSTracer *trc)
     }
 }
 
 JSObject *
 ObjectStore::find(ObjectId id)
 {
     ObjectTable::Ptr p = table_.lookup(id);
     if (!p)
-        return NULL;
+        return nullptr;
     return p->value;
 }
 
 bool
 ObjectStore::add(ObjectId id, JSObject *obj)
 {
     return table_.put(id, obj);
 }
@@ -419,40 +419,40 @@ bool
 CpowIdHolder::ToObject(JSContext *cx, JSObject **objp)
 {
     return js_->Unwrap(cx, cpows_, objp);
 }
 
 bool
 JavaScriptShared::Unwrap(JSContext *cx, const InfallibleTArray<CpowEntry> &aCpows, JSObject **objp)
 {
-    *objp = NULL;
+    *objp = nullptr;
 
     if (!aCpows.Length())
         return true;
 
-    RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
+    RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
     if (!obj)
         return false;
 
     RootedValue v(cx);
     RootedString str(cx);
     for (size_t i = 0; i < aCpows.Length(); i++) {
         const nsString &name = aCpows[i].name();
 
         if (!toValue(cx, aCpows[i].value(), &v))
             return false;
 
         if (!JS_DefineUCProperty(cx,
                                  obj,
                                  name.BeginReading(),
                                  name.Length(),
                                  v,
-                                 NULL,
-                                 NULL,
+                                 nullptr,
+                                 nullptr,
                                  JSPROP_ENUMERATE))
         {
             return false;
         }
     }
 
     *objp = obj;
     return true;
--- a/js/ipc/JavaScriptShared.h
+++ b/js/ipc/JavaScriptShared.h
@@ -107,17 +107,17 @@ class JavaScriptShared
         return true;
     }
 
     virtual bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp) = 0;
     virtual JSObject *unwrap(JSContext *cx, ObjectId id) = 0;
 
     bool unwrap(JSContext *cx, ObjectId id, JS::MutableHandle<JSObject*> objp) {
         if (!id) {
-            objp.set(NULL);
+            objp.set(nullptr);
             return true;
         }
 
         objp.set(unwrap(cx, id));
         return bool(objp.get());
     }
 
     static void ConvertID(const nsID &from, JSIID *to);
--- a/js/public/CharacterEncoding.h
+++ b/js/public/CharacterEncoding.h
@@ -2,16 +2,17 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef js_CharacterEncoding_h
 #define js_CharacterEncoding_h
 
+#include "mozilla/NullPtr.h"
 #include "mozilla/Range.h"
 
 #include "jspubtd.h"
 
 #include "js/Utility.h"
 
 namespace JS {
 
@@ -36,17 +37,17 @@ class Latin1Chars : public mozilla::Rang
 /*
  * A Latin1Chars, but with \0 termination for C compatibility.
  */
 class Latin1CharsZ : public mozilla::RangedPtr<unsigned char>
 {
     typedef mozilla::RangedPtr<unsigned char> Base;
 
   public:
-    Latin1CharsZ() : Base(NULL, 0) {}
+    Latin1CharsZ() : Base(nullptr, 0) {}
 
     Latin1CharsZ(char *aBytes, size_t aLength)
       : Base(reinterpret_cast<unsigned char *>(aBytes), aLength)
     {
         JS_ASSERT(aBytes[aLength] == '\0');
     }
 
     Latin1CharsZ(unsigned char *aBytes, size_t aLength)
@@ -75,17 +76,17 @@ class UTF8Chars : public mozilla::Range<
 /*
  * SpiderMonkey also deals directly with UTF-8 encoded text in some places.
  */
 class UTF8CharsZ : public mozilla::RangedPtr<unsigned char>
 {
     typedef mozilla::RangedPtr<unsigned char> Base;
 
   public:
-    UTF8CharsZ() : Base(NULL, 0) {}
+    UTF8CharsZ() : Base(nullptr, 0) {}
 
     UTF8CharsZ(char *aBytes, size_t aLength)
       : Base(reinterpret_cast<unsigned char *>(aBytes), aLength)
     {
         JS_ASSERT(aBytes[aLength] == '\0');
     }
 
     UTF8CharsZ(unsigned char *aBytes, size_t aLength)
@@ -133,33 +134,33 @@ class StableTwoByteChars : public mozill
 /*
  * A TwoByteChars, but \0 terminated for compatibility with JSFlatString.
  */
 class TwoByteCharsZ : public mozilla::RangedPtr<jschar>
 {
     typedef mozilla::RangedPtr<jschar> Base;
 
   public:
-    TwoByteCharsZ() : Base(NULL, 0) {}
+    TwoByteCharsZ() : Base(nullptr, 0) {}
 
     TwoByteCharsZ(jschar *chars, size_t length)
       : Base(chars, length)
     {
         JS_ASSERT(chars[length] == '\0');
     }
 };
 
 /*
  * Convert a 2-byte character sequence to "ISO-Latin-1". This works by
  * truncating each 2-byte pair in the sequence to a 1-byte pair. If the source
  * contains any UTF-16 extension characters, then this may give invalid Latin1
  * output. The returned string is zero terminated. The returned string or the
  * returned string's |start()| must be freed with JS_free or js_free,
  * respectively. If allocation fails, an OOM error will be set and the method
- * will return a NULL chars (which can be tested for with the ! operator).
+ * will return a nullptr chars (which can be tested for with the ! operator).
  * This method cannot trigger GC.
  */
 extern Latin1CharsZ
 LossyTwoByteCharsToNewLatin1CharsZ(js::ThreadSafeContext *cx, TwoByteChars tbchars);
 
 extern UTF8CharsZ
 TwoByteCharsToNewUTF8CharsZ(js::ThreadSafeContext *cx, TwoByteChars tbchars);
 
--- a/js/public/Class.h
+++ b/js/public/Class.h
@@ -4,16 +4,18 @@
  * 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/. */
 
 /* JSClass definition and its component types, plus related interfaces. */
 
 #ifndef js_Class_h
 #define js_Class_h
 
+#include "mozilla/NullPtr.h"
+ 
 #include "jstypes.h"
 
 #include "js/CallArgs.h"
 #include "js/Id.h"
 #include "js/TypeDecls.h"
 
 /*
  * A JSClass acts as a vtable for JS objects that allows JSAPI clients to
@@ -68,17 +70,17 @@ class SpecialId
   public:
     SpecialId() : bits_(TYPE_VOID) { }
 
     /* Object-valued */
 
     SpecialId(JSObject &obj)
       : bits_(uintptr_t(&obj) | TYPE_OBJECT)
     {
-        JS_ASSERT(&obj != NULL);
+        JS_ASSERT(&obj != nullptr);
         JS_ASSERT((uintptr_t(&obj) & TYPE_MASK) == 0);
     }
 
     bool isObject() const {
         return (bits_ & TYPE_MASK) == TYPE_OBJECT && bits_ != TYPE_OBJECT;
     }
 
     JSObject *toObject() const {
@@ -432,17 +434,17 @@ struct ClassExtension
      * that case, the wrapped object is returned by the wrapper's
      * weakmapKeyDelegateOp hook. As long as the wrapper is used as a weakmap
      * key, it will not be collected (and remain in the weakmap) until the
      * wrapped object is collected.
      */
     JSWeakmapKeyDelegateOp weakmapKeyDelegateOp;
 };
 
-#define JS_NULL_CLASS_EXT   {NULL,NULL,NULL,false,NULL}
+#define JS_NULL_CLASS_EXT   {nullptr,nullptr,nullptr,false,nullptr}
 
 struct ObjectOps
 {
     LookupGenericOp     lookupGeneric;
     LookupPropOp        lookupProperty;
     LookupElementOp     lookupElement;
     LookupSpecialOp     lookupSpecial;
     DefineGenericOp     defineGeneric;
@@ -464,18 +466,19 @@ struct ObjectOps
     DeleteElementOp     deleteElement;
     DeleteSpecialOp     deleteSpecial;
 
     JSNewEnumerateOp    enumerate;
     ObjectOp            thisObject;
 };
 
 #define JS_NULL_OBJECT_OPS                                                    \
-    {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,   \
-     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}
+    {nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, \
+     nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, \
+     nullptr,nullptr,nullptr,nullptr,nullptr,nullptr}
 
 } // namespace js
 
 // Classes, objects, and properties.
 
 typedef void (*JSClassInternal)();
 
 struct JSClass {
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -2,16 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef js_GCAPI_h
 #define js_GCAPI_h
 
+#include "mozilla/NullPtr.h"
+ 
 #include "js/HeapAPI.h"
 #include "js/RootingAPI.h"
 #include "js/Value.h"
 
 namespace JS {
 
 #define GCREASONS(D)                            \
     /* Reasons internal to the JS engine */     \
@@ -221,27 +223,27 @@ class AutoAssertNoGC {
 #endif
 };
 
 class JS_PUBLIC_API(ObjectPtr)
 {
     Heap<JSObject *> value;
 
   public:
-    ObjectPtr() : value(NULL) {}
+    ObjectPtr() : value(nullptr) {}
 
     ObjectPtr(JSObject *obj) : value(obj) {}
 
     /* Always call finalize before the destructor. */
     ~ObjectPtr() { JS_ASSERT(!value); }
 
     void finalize(JSRuntime *rt) {
         if (IsIncrementalBarrierNeeded(rt))
             IncrementalObjectBarrier(value);
-        value = NULL;
+        value = nullptr;
     }
 
     void init(JSObject *obj) { value = obj; }
 
     JSObject *get() const { return value; }
 
     void writeBarrierPre(JSRuntime *rt) {
         IncrementalObjectBarrier(value);
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/Alignment.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Casting.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Move.h"
+#include "mozilla/NullPtr.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/ReentrancyGuard.h"
 #include "mozilla/TemplateLib.h"
 #include "mozilla/TypeTraits.h"
 
 #include "js/Utility.h"
 
 namespace js {
@@ -208,17 +209,17 @@ class HashMap
 
     // If |generation()| is the same before and after a HashMap operation,
     // pointers into the table remain valid.
     unsigned generation() const                       { return impl.generation(); }
 
     /************************************************** Shorthand operations */
 
     bool has(const Lookup &l) const {
-        return impl.lookup(l) != NULL;
+        return impl.lookup(l) != nullptr;
     }
 
     // Overwrite existing value with v. Return false on oom.
     template<typename KeyInput, typename ValueInput>
     bool put(const KeyInput &k, const ValueInput &v) {
         AddPtr p = lookupForAdd(k);
         if (p) {
             p->value = v;
@@ -420,17 +421,17 @@ class HashSet
 
     // If |generation()| is the same before and after a HashSet operation,
     // pointers into the table remain valid.
     unsigned generation() const                       { return impl.generation(); }
 
     /************************************************** Shorthand operations */
 
     bool has(const Lookup &l) const {
-        return impl.lookup(l) != NULL;
+        return impl.lookup(l) != nullptr;
     }
 
     // Overwrite existing value with v. Return false on oom.
     bool put(const T &t) {
         AddPtr p = lookupForAdd(t);
         return p ? true : add(p, t);
     }
 
@@ -751,17 +752,17 @@ class HashTable : private AllocPolicy
             while (cur < end && !cur->isLive())
                 ++cur;
         }
 
         Entry *cur, *end;
         mozilla::DebugOnly<bool> validEntry;
 
       public:
-        Range() : cur(NULL), end(NULL), validEntry(false) {}
+        Range() : cur(nullptr), end(nullptr), validEntry(false) {}
 
         bool empty() const {
             return cur == end;
         }
 
         T &front() const {
             JS_ASSERT(validEntry);
             JS_ASSERT(!empty());
@@ -835,23 +836,23 @@ class HashTable : private AllocPolicy
         }
     };
 
     // HashTable is movable
     HashTable(mozilla::MoveRef<HashTable> rhs)
       : AllocPolicy(*rhs)
     {
         mozilla::PodAssign(this, &*rhs);
-        rhs->table = NULL;
+        rhs->table = nullptr;
     }
     void operator=(mozilla::MoveRef<HashTable> rhs) {
         if (table)
             destroyTable(*this, table, capacity());
         mozilla::PodAssign(this, &*rhs);
-        rhs->table = NULL;
+        rhs->table = nullptr;
     }
 
   private:
     // HashTable is not copyable or assignable
     HashTable(const HashTable &) MOZ_DELETE;
     void operator=(const HashTable &) MOZ_DELETE;
 
   private:
@@ -942,17 +943,17 @@ class HashTable : private AllocPolicy
 
   public:
     HashTable(AllocPolicy ap)
       : AllocPolicy(ap),
         hashShift(sHashBits),
         entryCount(0),
         gen(0),
         removedCount(0),
-        table(NULL),
+        table(nullptr),
         entered(false),
         mutationCount(0)
     {}
 
     MOZ_WARN_UNUSED_RESULT bool init(uint32_t length)
     {
         JS_ASSERT(!initialized());
 
@@ -1068,17 +1069,17 @@ class HashTable : private AllocPolicy
             METER(stats.hits++);
             return *entry;
         }
 
         // Collision: double hash.
         DoubleHash dh = hash2(keyHash);
 
         // Save the first removed entry pointer so we can recycle later.
-        Entry *firstRemoved = NULL;
+        Entry *firstRemoved = nullptr;
 
         while(true) {
             if (JS_UNLIKELY(entry->isRemoved())) {
                 if (!firstRemoved)
                     firstRemoved = entry;
             } else {
                 entry->setCollision(collisionBit);
             }
@@ -1308,17 +1309,17 @@ class HashTable : private AllocPolicy
     void finish()
     {
         JS_ASSERT(!entered);
 
         if (!table)
             return;
 
         destroyTable(*this, table, capacity());
-        table = NULL;
+        table = nullptr;
         gen++;
         entryCount = 0;
         removedCount = 0;
         mutationCount++;
     }
 
     Range all() const
     {
--- a/js/public/Id.h
+++ b/js/public/Id.h
@@ -15,16 +15,18 @@
 // jsid is not a valid id and only arises as an exceptional API return value,
 // such as in JS_NextProperty. Embeddings must not pass JSID_VOID into JSAPI
 // entry points expecting a jsid and do not need to handle JSID_VOID in hooks
 // receiving a jsid except when explicitly noted in the API contract.
 //
 // A jsid is not implicitly convertible to or from a jsval; JS_ValueToId or
 // JS_IdToValue must be used instead.
 
+#include "mozilla/NullPtr.h"
+ 
 #include "jstypes.h"
 
 #include "js/RootingAPI.h"
 #include "js/TypeDecls.h"
 #include "js/Utility.h"
 
 #ifdef JS_USE_JSID_STRUCT_TYPES
 struct jsid
@@ -111,17 +113,17 @@ JSID_TO_OBJECT(jsid id)
     JS_ASSERT(JSID_IS_OBJECT(id));
     return (JSObject *)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK);
 }
 
 static JS_ALWAYS_INLINE jsid
 OBJECT_TO_JSID(JSObject *obj)
 {
     jsid id;
-    JS_ASSERT(obj != NULL);
+    JS_ASSERT(obj != nullptr);
     JS_ASSERT(((size_t)obj & JSID_TYPE_MASK) == 0);
     JSID_BITS(id) = ((size_t)obj | JSID_TYPE_OBJECT);
     return id;
 }
 
 static JS_ALWAYS_INLINE bool
 JSID_IS_GCTHING(jsid id)
 {
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -6,16 +6,17 @@
 
 #ifndef js_MemoryMetrics_h
 #define js_MemoryMetrics_h
 
 // These declarations are not within jsapi.h because they are highly likely to
 // change in the future. Depend on them at your own risk.
 
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/NullPtr.h"
 #include "mozilla/PodOperations.h"
 
 #include <string.h>
 
 #include "jsalloc.h"
 #include "jspubtd.h"
 
 #include "js/HashTable.h"
@@ -313,17 +314,17 @@ struct ZoneStats : js::ZoneStatsPod
     // The size of all the live things in the GC heap that don't belong to any
     // compartment.
     size_t GCHeapThingsSize();
 };
 
 struct CompartmentStats
 {
     CompartmentStats()
-      : extra(NULL),
+      : extra(nullptr),
         gcHeapObjectsOrdinary(0),
         gcHeapObjectsFunction(0),
         gcHeapObjectsDenseArray(0),
         gcHeapObjectsSlowArray(0),
         gcHeapObjectsCrossCompartmentWrapper(0),
         gcHeapShapesTreeGlobalParented(0),
         gcHeapShapesTreeNonGlobalParented(0),
         gcHeapShapesDict(0),
@@ -458,17 +459,17 @@ struct RuntimeStats
         gcHeapUnusedArenas(0),
         gcHeapUnusedGcThings(0),
         gcHeapChunkAdmin(0),
         gcHeapGcThings(0),
         cTotals(),
         zTotals(),
         compartmentStatsVector(),
         zoneStatsVector(),
-        currZoneStats(NULL),
+        currZoneStats(nullptr),
         mallocSizeOf_(mallocSizeOf)
     {}
 
     RuntimeSizes runtime;
 
     // If you add a new number, remember to update the constructor!
 
     // Here's a useful breakdown of the GC heap.
--- a/js/public/OldDebugAPI.h
+++ b/js/public/OldDebugAPI.h
@@ -6,16 +6,18 @@
 
 #ifndef js_OldDebugAPI_h
 #define js_OldDebugAPI_h
 
 /*
  * JS debugger API.
  */
 
+#include "mozilla/NullPtr.h"
+ 
 #include "jsbytecode.h"
 
 #include "js/CallArgs.h"
 #include "js/TypeDecls.h"
 
 class JSAtom;
 class JSFreeOp;
 
@@ -45,17 +47,17 @@ FreeStackDescription(JSContext *cx, Stac
 extern JS_PUBLIC_API(char *)
 FormatStackDump(JSContext *cx, char *buf, bool showArgs, bool showLocals, bool showThisProps);
 
 }
 
 # ifdef DEBUG
 JS_FRIEND_API(void) js_DumpValue(const JS::Value &val);
 JS_FRIEND_API(void) js_DumpId(jsid id);
-JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = NULL);
+JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = nullptr);
 # endif
 
 JS_FRIEND_API(void)
 js_DumpBacktrace(JSContext *cx);
 
 typedef enum JSTrapStatus {
     JSTRAP_ERROR,
     JSTRAP_CONTINUE,
@@ -420,17 +422,17 @@ class JS_PUBLIC_API(JSBrokenFrameIterato
  * for the 'before'invocation, but is whatever value is returned from that
  * invocation for the 'after' invocation. Thus, the hook implementor *could*
  * allocate a structure in the 'before' invocation and return a pointer to that
  * structure. The pointer would then be handed to the hook for the 'after'
  * invocation. Alternately, the 'before' could just return the same value as
  * in 'closure' to cause the 'after' invocation to be called with the same
  * 'closure' value as the 'before'.
  *
- * Returning NULL in the 'before' hook will cause the 'after' hook *not* to
+ * Returning nullptr in the 'before' hook will cause the 'after' hook *not* to
  * be called.
  */
 typedef void *
 (* JSInterpreterHook)(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing,
                       bool before, bool *ok, void *closure);
 
 typedef bool
 (* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report,
--- a/js/public/ProfilingStack.h
+++ b/js/public/ProfilingStack.h
@@ -2,16 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef js_ProfilingStack_h
 #define js_ProfilingStack_h
 
+#include "mozilla/NullPtr.h"
+ 
 #include "jsbytecode.h"
 #include "jstypes.h"
 
 #include "js/Utility.h"
 
 struct JSRuntime;
 
 namespace js {
@@ -28,34 +30,34 @@ class ProfileEntry
     //
     //    entry[size] = ...;
     //    size++;
     //
     // If the size modification were somehow reordered before the stores, then
     // if a sample were taken it would be examining bogus information.
     //
     // A ProfileEntry represents both a C++ profile entry and a JS one. Both use
-    // the string as a description, but JS uses the sp as NULL to indicate that
-    // it is a JS entry. The script_ is then only ever examined for a JS entry,
-    // and the idx is used by both, but with different meanings.
+    // the string as a description, but JS uses the sp as nullptr to indicate
+    // that it is a JS entry. The script_ is then only ever examined for a JS
+    // entry, and the idx is used by both, but with different meanings.
     //
     const char * volatile string; // Descriptive string of this entry
     void * volatile sp;           // Relevant stack pointer for the entry
     JSScript * volatile script_;  // if js(), non-null script which is running
     int32_t volatile idx;         // if js(), idx of pc, otherwise line number
 
   public:
     // All of these methods are marked with the 'volatile' keyword because SPS's
     // representation of the stack is stored such that all ProfileEntry
     // instances are volatile. These methods would not be available unless they
     // were marked as volatile as well.
 
     bool js() volatile {
-        JS_ASSERT_IF(sp == NULL, script_ != NULL);
-        return sp == NULL;
+        JS_ASSERT_IF(sp == nullptr, script_ != nullptr);
+        return sp == nullptr;
     }
 
     uint32_t line() volatile { JS_ASSERT(!js()); return idx; }
     JSScript *script() volatile { JS_ASSERT(js()); return script_; }
     void *stackAddress() volatile { return sp; }
     const char *label() volatile { return string; }
 
     void setLine(uint32_t aLine) volatile { JS_ASSERT(!js()); idx = aLine; }
@@ -68,18 +70,18 @@ class ProfileEntry
     JS_FRIEND_API(void) setPC(jsbytecode *pc) volatile;
 
     static size_t offsetOfString() { return offsetof(ProfileEntry, string); }
     static size_t offsetOfStackAddress() { return offsetof(ProfileEntry, sp); }
     static size_t offsetOfPCIdx() { return offsetof(ProfileEntry, idx); }
     static size_t offsetOfScript() { return offsetof(ProfileEntry, script_); }
 
     // The index used in the entry can either be a line number or the offset of
-    // a pc into a script's code. To signify a NULL pc, use a -1 index. This is
-    // checked against in pc() and setPC() to set/get the right pc.
+    // a pc into a script's code. To signify a nullptr pc, use a -1 index. This
+    // is checked against in pc() and setPC() to set/get the right pc.
     static const int32_t NullPCIndex = -1;
 };
 
 JS_FRIEND_API(void)
 SetRuntimeProfilingStack(JSRuntime *rt, ProfileEntry *stack, uint32_t *size,
                          uint32_t max);
 
 JS_FRIEND_API(void)
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -3,16 +3,17 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef js_RootingAPI_h
 #define js_RootingAPI_h
 
 #include "mozilla/GuardObjects.h"
+#include "mozilla/NullPtr.h"
 #include "mozilla/TypeTraits.h"
 
 #include "jspubtd.h"
 
 #include "js/TypeDecls.h"
 #include "js/Utility.h"
 
 /*
@@ -111,23 +112,23 @@ class HandleBase {};
 
 template <typename T>
 class MutableHandleBase {};
 
 template <typename T>
 class HeapBase {};
 
 /*
- * js::NullPtr acts like a NULL pointer in contexts that require a Handle.
+ * js::NullPtr acts like a nullptr pointer in contexts that require a Handle.
  *
  * Handle provides an implicit constructor for js::NullPtr so that, given:
  *   foo(Handle<JSObject*> h);
  * callers can simply write:
  *   foo(js::NullPtr());
- * which avoids creating a Rooted<JSObject*> just to pass NULL.
+ * which avoids creating a Rooted<JSObject*> just to pass nullptr.
  *
  * This is the SpiderMonkey internal variant. js::NullPtr should be used in
  * preference to JS::NullPtr to avoid the GOT access required for JS_PUBLIC_API
  * symbols.
  */
 struct NullPtr
 {
     static void * const constNullValue;
@@ -147,23 +148,23 @@ template <typename T> class Rooted;
 JS_FRIEND_API(bool) isGCEnabled();
 
 #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
 extern void
 CheckStackRoots(JSContext *cx);
 #endif
 
 /*
- * JS::NullPtr acts like a NULL pointer in contexts that require a Handle.
+ * JS::NullPtr acts like a nullptr pointer in contexts that require a Handle.
  *
  * Handle provides an implicit constructor for JS::NullPtr so that, given:
  *   foo(Handle<JSObject*> h);
  * callers can simply write:
  *   foo(JS::NullPtr());
- * which avoids creating a Rooted<JSObject*> just to pass NULL.
+ * which avoids creating a Rooted<JSObject*> just to pass nullptr.
  */
 struct JS_PUBLIC_API(NullPtr)
 {
     static void * const constNullValue;
 };
 
 /*
  * The Heap<T> class is a C/C++ heap-stored reference to a JS GC thing.  All
@@ -382,24 +383,24 @@ class MOZ_NONHEAP_CLASS Handle : public 
     Handle(Handle<S> handle,
            typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0)
     {
         static_assert(sizeof(Handle<T>) == sizeof(T *),
                       "Handle must be binary compatible with T*.");
         ptr = reinterpret_cast<const T *>(handle.address());
     }
 
-    /* Create a handle for a NULL pointer. */
+    /* Create a handle for a nullptr pointer. */
     Handle(js::NullPtr) {
         static_assert(mozilla::IsPointer<T>::value,
                       "js::NullPtr overload not valid for non-pointer types");
         ptr = reinterpret_cast<const T *>(&js::NullPtr::constNullValue);
     }
 
-    /* Create a handle for a NULL pointer. */
+    /* Create a handle for a nullptr pointer. */
     Handle(JS::NullPtr) {
         static_assert(mozilla::IsPointer<T>::value,
                       "JS::NullPtr overload not valid for non-pointer types");
         ptr = reinterpret_cast<const T *>(&JS::NullPtr::constNullValue);
     }
 
     Handle(MutableHandle<T> handle) {
         ptr = handle.address();
@@ -590,17 +591,17 @@ template <typename T>
 struct RootKind<T *>
 {
     static ThingRootKind rootKind() { return T::rootKind(); }
 };
 
 template <typename T>
 struct GCMethods<T *>
 {
-    static T *initial() { return NULL; }
+    static T *initial() { return nullptr; }
     static ThingRootKind kind() { return RootKind<T *>::rootKind(); }
     static bool poisoned(T *v) { return JS::IsPoisonedPtr(v); }
     static bool needsPostBarrier(T *v) { return v; }
 #ifdef JSGC_GENERATIONAL
     static void postBarrier(T **vp) {
         JS::HeapCellPostBarrier(reinterpret_cast<js::gc::Cell **>(vp));
     }
     static void relocate(T **vp) {
@@ -1040,17 +1041,17 @@ inline void MaybeCheckStackRoots(JSConte
     JS::CheckStackRoots(cx);
 #endif
 }
 
 /* Base class for automatic read-only object rooting during compilation. */
 class CompilerRootNode
 {
   protected:
-    CompilerRootNode(js::gc::Cell *ptr) : next(NULL), ptr_(ptr) {}
+    CompilerRootNode(js::gc::Cell *ptr) : next(nullptr), ptr_(ptr) {}
 
   public:
     void **address() { return (void **)&ptr_; }
 
   public:
     CompilerRootNode *next;
 
   protected:
--- a/js/public/StructuredClone.h
+++ b/js/public/StructuredClone.h
@@ -2,16 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef js_StructuredClone_h
 #define js_StructuredClone_h
 
+#include "mozilla/NullPtr.h"
+
 #include <stdint.h>
 
 #include "jstypes.h"
 
 #include "js/TypeDecls.h"
 
 struct JSRuntime;
 struct JSStructuredCloneReader;
@@ -20,17 +22,17 @@ struct JSStructuredCloneWriter;
 // API for the HTML5 internal structured cloning algorithm.
 
 // Read structured data from the reader r. This hook is used to read a value
 // previously serialized by a call to the WriteStructuredCloneOp hook.
 //
 // tag and data are the pair of uint32_t values from the header. The callback
 // may use the JS_Read* APIs to read any other relevant parts of the object
 // from the reader r. closure is any value passed to the JS_ReadStructuredClone
-// function. Return the new object on success, NULL on error/exception.
+// function. Return the new object on success, nullptr on error/exception.
 typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r,
                                            uint32_t tag, uint32_t data, void *closure);
 
 // Structured data serialization hook. The engine can write primitive values,
 // Objects, Arrays, Dates, RegExps, TypedArrays, and ArrayBuffers. Any other
 // type of object requires application support. This callback must first use
 // the JS_WriteUint32Pair API to write an object header, passing a value
 // greater than JS_SCTAG_USER to the tag parameter. Then it can use the
@@ -81,17 +83,17 @@ JS_StructuredClone(JSContext *cx, JS::Va
 // RAII sugar for JS_WriteStructuredClone.
 class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) {
     uint64_t *data_;
     size_t nbytes_;
     uint32_t version_;
 
   public:
     JSAutoStructuredCloneBuffer()
-        : data_(NULL), nbytes_(0), version_(JS_STRUCTURED_CLONE_VERSION) {}
+        : data_(nullptr), nbytes_(0), version_(JS_STRUCTURED_CLONE_VERSION) {}
 
     ~JSAutoStructuredCloneBuffer() { clear(); }
 
     uint64_t *data() const { return data_; }
     size_t nbytes() const { return nbytes_; }
 
     void clear();
 
@@ -101,26 +103,26 @@ class JS_PUBLIC_API(JSAutoStructuredClon
     // Adopt some memory. It will be automatically freed by the destructor.
     // data must have been allocated by the JS engine (e.g., extracted via
     // JSAutoStructuredCloneBuffer::steal).
     void adopt(uint64_t *data, size_t nbytes, uint32_t version=JS_STRUCTURED_CLONE_VERSION);
 
     // Remove the buffer so that it will not be automatically freed.
     // After this, the caller is responsible for feeding the memory back to
     // JSAutoStructuredCloneBuffer::adopt.
-    void steal(uint64_t **datap, size_t *nbytesp, uint32_t *versionp=NULL);
+    void steal(uint64_t **datap, size_t *nbytesp, uint32_t *versionp=nullptr);
 
     bool read(JSContext *cx, JS::Value *vp,
-              const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL);
+              const JSStructuredCloneCallbacks *optionalCallbacks=nullptr, void *closure=nullptr);
 
     bool write(JSContext *cx, JS::Value v,
-               const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL);
+               const JSStructuredCloneCallbacks *optionalCallbacks=nullptr, void *closure=nullptr);
 
     bool write(JSContext *cx, JS::Value v, JS::Value transferable,
-               const JSStructuredCloneCallbacks *optionalCallbacks=NULL, void *closure=NULL);
+               const JSStructuredCloneCallbacks *optionalCallbacks=nullptr, void *closure=nullptr);
 
     // Swap ownership with another JSAutoStructuredCloneBuffer.
     void swap(JSAutoStructuredCloneBuffer &other);
 
   private:
     // Copy and assignment are not supported.
     JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other);
     JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other);
--- a/js/public/Tracer.h
+++ b/js/public/Tracer.h
@@ -2,16 +2,18 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef js_Tracer_h
 #define js_Tracer_h
 
+#include "mozilla/NullPtr.h"
+ 
 #include "jspubtd.h"
 
 struct JSTracer;
 
 namespace JS {
 template <typename T> class Heap;
 template <typename T> class TenuredHeap;
 }
@@ -88,35 +90,35 @@ struct JSTracer {
 #ifdef JS_GC_ZEAL
 # define JS_SET_TRACING_LOCATION(trc, location)                               \
     JS_BEGIN_MACRO                                                            \
         if (!(trc)->realLocation || !(location))                              \
             (trc)->realLocation = (location);                                 \
     JS_END_MACRO
 # define JS_UNSET_TRACING_LOCATION(trc)                                       \
     JS_BEGIN_MACRO                                                            \
-        (trc)->realLocation = NULL;                                           \
+        (trc)->realLocation = nullptr;                                        \
     JS_END_MACRO
 #else
 # define JS_SET_TRACING_LOCATION(trc, location)                               \
     JS_BEGIN_MACRO                                                            \
     JS_END_MACRO
 # define JS_UNSET_TRACING_LOCATION(trc)                                       \
     JS_BEGIN_MACRO                                                            \
     JS_END_MACRO
 #endif
 
 // Convenience macro to describe the argument of JS_CallTracer using C string
 // and index.
 # define JS_SET_TRACING_INDEX(trc, name, index)                               \
-    JS_SET_TRACING_DETAILS(trc, NULL, name, index)
+    JS_SET_TRACING_DETAILS(trc, nullptr, name, index)
 
 // Convenience macro to describe the argument of JS_CallTracer using C string.
 # define JS_SET_TRACING_NAME(trc, name)                                       \
-    JS_SET_TRACING_DETAILS(trc, NULL, name, (size_t)-1)
+    JS_SET_TRACING_DETAILS(trc, nullptr, name, (size_t)-1)
 
 // The JS_Call*Tracer family of functions traces the given GC thing reference.
 // This performs the tracing action configured on the given JSTracer:
 // typically calling the JSTracer::callback or marking the thing as live.
 //
 // The argument to JS_Call*Tracer is an in-out param: when the function
 // returns, the garbage collector might have moved the GC thing. In this case,
 // the reference passed to JS_Call*Tracer will be updated to the object's new
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -6,16 +6,17 @@
 
 #ifndef js_Utility_h
 #define js_Utility_h
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Compiler.h"
 #include "mozilla/Move.h"
+#include "mozilla/NullPtr.h"
 #include "mozilla/Scoped.h"
 #include "mozilla/TemplateLib.h"
 
 #include <stdlib.h>
 #include <string.h>
 
 #ifdef JS_OOM_DO_BACKTRACES
 #include <execinfo.h>
@@ -81,17 +82,17 @@ extern JS_PUBLIC_DATA(uint32_t) OOM_maxA
 extern JS_PUBLIC_DATA(uint32_t) OOM_counter; /* data race, who cares. */
 
 #ifdef JS_OOM_DO_BACKTRACES
 #define JS_OOM_BACKTRACE_SIZE 32
 static JS_ALWAYS_INLINE void
 PrintBacktrace()
 {
     void* OOM_trace[JS_OOM_BACKTRACE_SIZE];
-    char** OOM_traceSymbols = NULL;
+    char** OOM_traceSymbols = nullptr;
     int32_t OOM_traceSize = 0;
     int32_t OOM_traceIdx = 0;
     OOM_traceSize = backtrace(OOM_trace, JS_OOM_BACKTRACE_SIZE);
     OOM_traceSymbols = backtrace_symbols(OOM_trace, OOM_traceSize);
 
     if (!OOM_traceSymbols)
         return;
 
@@ -111,27 +112,27 @@ PrintBacktrace()
 #  define JS_OOM_EMIT_BACKTRACE() do {} while(0)
 #endif /* JS_OOM_DO_BACKTRACES */
 
 #  define JS_OOM_POSSIBLY_FAIL() \
     do \
     { \
         if (++OOM_counter > OOM_maxAllocations) { \
             JS_OOM_EMIT_BACKTRACE();\
-            return NULL; \
+            return nullptr; \
         } \
     } while (0)
 
 #  define JS_OOM_POSSIBLY_FAIL_REPORT(cx) \
     do \
     { \
         if (++OOM_counter > OOM_maxAllocations) { \
             JS_OOM_EMIT_BACKTRACE();\
             js_ReportOutOfMemory(cx);\
-            return NULL; \
+            return nullptr; \
         } \
     } while (0)
 
 # else
 #  define JS_OOM_POSSIBLY_FAIL() do {} while(0)
 #  define JS_OOM_POSSIBLY_FAIL_REPORT(cx) do {} while(0)
 # endif /* DEBUG */
 
@@ -220,17 +221,17 @@ static JS_INLINE void js_free(void* p)
  *     FreeOp::{free_,delete_}
  *
  *   The advantage of these operations is that the memory is batched and freed
  *   on another thread.
  */
 
 #define JS_NEW_BODY(allocator, t, parms)                                       \
     void *memory = allocator(sizeof(t));                                       \
-    return memory ? new(memory) t parms : NULL;
+    return memory ? new(memory) t parms : nullptr;
 
 /*
  * Given a class which should provide 'new' methods, add
  * JS_DECLARE_NEW_METHODS (see JSContext for a usage example). This
  * adds news with up to 12 parameters. Add more versions of new below if
  * you need more than 12 parameters.
  *
  * Note: Do not add a ; at the end of a use of JS_DECLARE_NEW_METHODS,
@@ -339,36 +340,36 @@ js_pod_calloc()
     return (T *)js_calloc(sizeof(T));
 }
 
 template <class T>
 static JS_ALWAYS_INLINE T *
 js_pod_malloc(size_t numElems)
 {
     if (numElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value)
-        return NULL;
+        return nullptr;
     return (T *)js_malloc(numElems * sizeof(T));
 }
 
 template <class T>
 static JS_ALWAYS_INLINE T *
 js_pod_calloc(size_t numElems)
 {
     if (numElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value)
-        return NULL;
+        return nullptr;
     return (T *)js_calloc(numElems * sizeof(T));
 }
 
 namespace js {
 
 template<typename T>
 struct ScopedFreePtrTraits
 {
     typedef T* type;
-    static T* empty() { return NULL; }
+    static T* empty() { return nullptr; }
     static void release(T* ptr) { js_free(ptr); }
 };
 SCOPED_TEMPLATE(ScopedJSFreePtr, ScopedFreePtrTraits)
 
 template <typename T>
 struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T>
 {
     static void release(T *ptr) { js_delete(ptr); }