Merging backout
authorBlake Kaplan <mrbkap@gmail.com>
Wed, 23 Jul 2008 13:20:41 -0400
changeset 16148 403582828a52ea820cc2128b023efa2c163ae77d
parent 16146 41d5a8915ca2c03a0b1255b3f8ff13215e67b154 (diff)
parent 16147 0e003f43fcfd75f085581d20d05db977cd2c1573 (current diff)
child 16149 7afdded71629633aafc53e73766a6a98c34172cd
child 16155 abd8bf7d25ca78c8915fac8623044e576d5977e5
push idunknown
push userunknown
push dateunknown
milestone1.9.1a2pre
Merging backout
--- a/js/src/xpconnect/src/XPCWrapper.h
+++ b/js/src/xpconnect/src/XPCWrapper.h
@@ -79,21 +79,33 @@ XPC_XOW_WrapperMoved(JSContext *cx, XPCW
                      XPCWrappedNativeScope *newScope);
 
 nsresult
 CanAccessWrapper(JSContext *cx, JSObject *wrappedObj);
 
 inline JSBool
 XPC_XOW_ClassNeedsXOW(const char *name)
 {
-  // TODO Make a perfect hash of these and use that?
-  return !strcmp(name, "Window")            ||
-         !strcmp(name, "Location")          ||
-         !strcmp(name, "HTMLIFrameElement") ||
-         !strcmp(name, "HTMLFrameElement");
+  switch (*name) {
+    case 'W':
+      return strcmp(++name, "indow") == 0;
+    case 'L':
+      return strcmp(++name, "ocation") == 0;
+    case 'H':
+      if (strncmp(++name, "TML", 3))
+        break;
+      name += 3;
+      if (*name == 'I')
+        ++name;
+      return strcmp(name, "FrameElement") == 0;
+    default:
+      break;
+  }
+
+  return JS_FALSE;
 }
 
 extern JSExtendedClass sXPC_XOW_JSClass;
 extern JSExtendedClass sXPC_SJOW_JSClass;
 
 // This class wraps some common functionality between the three existing
 // wrappers. Its main purpose is to allow XPCCrossOriginWrapper to act both
 // as an XPCSafeSJSObjectWrapper and as an XPCNativeWrapper when required to
--- a/modules/plugin/base/src/nsJSNPRuntime.cpp
+++ b/modules/plugin/base/src/nsJSNPRuntime.cpp
@@ -1712,20 +1712,32 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
     return entry->mJSObj;
   }
 
   entry->mNPObj = npobj;
   entry->mNpp = npp;
 
   JSAutoRequest ar(cx);
 
+  PRUint32 generation = sNPObjWrappers.generation;
+
   // No existing JSObject, create one.
 
   JSObject *obj = ::JS_NewObject(cx, &sNPObjectJSWrapperClass, nsnull, nsnull);
 
+  if (generation != sNPObjWrappers.generation) {
+      // Reload entry if the JS_NewObject call caused a GC and reallocated
+      // the table (see bug 445229). This is guaranteed to succeed.
+
+      entry = static_cast<NPObjWrapperHashEntry *>
+        (PL_DHashTableOperate(&sNPObjWrappers, npobj, PL_DHASH_LOOKUP));
+      NS_ASSERTION(entry && PL_DHASH_ENTRY_IS_BUSY(entry),
+                   "Hashtable didn't find what we just added?");
+  }
+
   if (!obj) {
     // OOM? Remove the stale entry from the hash.
 
     PL_DHashTableRawRemove(&sNPObjWrappers, entry);
 
     return nsnull;
   }