Bug 1484605 - Tweak some lookupForAdd() uses. r=luke
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 21 Aug 2018 11:53:47 +1000
changeset 487632 dc7413a25676e83242f0d1e539bf36015bb14550
parent 487631 3aca6b42ca4efa4d5f1f08d8191e0699d4e0b86a
child 487633 e0e6b77fb800d5b81c5b68af3dde3c4beee68d7a
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1484605
milestone63.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 1484605 - Tweak some lookupForAdd() uses. r=luke These are cases where the existing code is a little dubious or sub-optimal.
dom/plugins/base/nsJSNPRuntime.cpp
js/src/frontend/Parser.cpp
js/src/gc/HashUtil.h
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1130,17 +1130,17 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS
 
   if (!sJSObjWrappers) {
     // No hash yet (or any more), initialize it.
     if (!CreateJSObjWrapperTable())
       return nullptr;
   }
   MOZ_ASSERT(sJSObjWrappersAccessible);
 
-  JSObjWrapperTable::Ptr p = sJSObjWrappers->lookupForAdd(nsJSObjWrapperKey(obj, npp));
+  JSObjWrapperTable::Ptr p = sJSObjWrappers->lookup(nsJSObjWrapperKey(obj, npp));
   if (p) {
     MOZ_ASSERT(p->value());
     // Found a live nsJSObjWrapper, return it.
 
     return _retainobject(p->value());
   }
 
   // No existing nsJSObjWrapper, create one.
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -420,17 +420,17 @@ ParseContext::init()
 
     return true;
 }
 
 bool
 UsedNameTracker::noteUse(JSContext* cx, JSAtom* name, uint32_t scriptId, uint32_t scopeId)
 {
     if (UsedNameMap::AddPtr p = map_.lookupForAdd(name)) {
-        if (!p->value().noteUsedInScope(scriptId, scopeId))
+        if (!p || !p->value().noteUsedInScope(scriptId, scopeId))
             return false;
     } else {
         UsedNameInfo info(cx);
         if (!info.noteUsedInScope(scriptId, scopeId))
             return false;
         if (!map_.add(p, name, std::move(info)))
             return false;
     }
--- a/js/src/gc/HashUtil.h
+++ b/js/src/gc/HashUtil.h
@@ -42,17 +42,18 @@ struct DependentAddPtr
             return false;
         }
         return true;
     }
 
     template <class KeyInput>
     void remove(JSContext* cx, T& table, const KeyInput& key) {
         refreshAddPtr(cx, table, key);
-        table.remove(addPtr);
+        if (addPtr)
+            table.remove(addPtr);
     }
 
     bool found() const                 { return addPtr.found(); }
     explicit operator bool() const     { return found(); }
     const Entry& operator*() const     { return *addPtr; }
     const Entry* operator->() const    { return &*addPtr; }
 
   private: