Backout 19165f7c1d53 & a923d1c4ecab (bug 827274) for mochitest-chrome crashes
authorEd Morley <emorley@mozilla.com>
Mon, 07 Jan 2013 18:33:37 +0000
changeset 122534 fc44cc7dd21ed8c44f02546b68885229b7d6f055
parent 122533 19165f7c1d5369532493b532bffcd52937b3db2f
child 122535 09dd216e6408b96c19faf366f767874e25fa6e40
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)
bugs827274
milestone19.0a2
backs out19165f7c1d5369532493b532bffcd52937b3db2f
Backout 19165f7c1d53 & a923d1c4ecab (bug 827274) for mochitest-chrome crashes
dom/workers/RuntimeService.cpp
dom/workers/WorkerPrivate.h
js/src/ctypes/CTypes.cpp
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -384,24 +384,16 @@ CTypesActivityCallback(JSContext* aCx,
     case js::CTYPES_CALL_BEGIN:
       worker->BeginCTypesCall();
       break;
 
     case js::CTYPES_CALL_END:
       worker->EndCTypesCall();
       break;
 
-    case js::CTYPES_CALLBACK_BEGIN:
-      worker->BeginCTypesCallback();
-      break;
-
-    case js::CTYPES_CALLBACK_END:
-      worker->EndCTypesCallback();
-      break;
-
     default:
       MOZ_NOT_REACHED("Unknown type flag!");
   }
 }
 
 JSContext*
 CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate)
 {
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -766,32 +766,16 @@ public:
   // This may block!
   void
   BeginCTypesCall();
 
   // This may block!
   void
   EndCTypesCall();
 
-  void
-  BeginCTypesCallback()
-  {
-    // If a callback is beginning then we need to do the exact same thing as
-    // when a ctypes call ends.
-    EndCTypesCall();
-  }
-
-  void
-  EndCTypesCallback()
-  {
-    // If a callback is ending then we need to do the exact same thing as
-    // when a ctypes call begins.
-    BeginCTypesCall();
-  }
-
 private:
   WorkerPrivate(JSContext* aCx, JSObject* aObject, WorkerPrivate* aParent,
                 JSContext* aParentJSContext, const nsAString& aScriptURL,
                 bool aIsChromeWorker, const nsACString& aDomain,
                 nsCOMPtr<nsPIDOMWindow>& aWindow,
                 nsCOMPtr<nsIScriptContext>& aScriptContext,
                 nsCOMPtr<nsIURI>& aBaseURI, nsCOMPtr<nsIPrincipal>& aPrincipal,
                 nsCOMPtr<nsIContentSecurityPolicy>& aCSP, bool aEvalAllowed,
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -5763,17 +5763,19 @@ FunctionType::Call(JSContext* cx,
   TypeCode typeCode = CType::GetTypeCode(fninfo->mReturnType);
   if (typeCode != TYPE_void_t &&
       !returnValue.SizeToType(cx, fninfo->mReturnType)) {
     JS_ReportAllocationOverflow(cx);
     return false;
   }
 
   // Let the runtime callback know that we are about to call into C.
-  js::AutoCTypesActivityCallback autoCallback(cx, js::CTYPES_CALL_BEGIN, js::CTYPES_CALL_END);
+  js::CTypesActivityCallback activityCallback = cx->runtime->ctypesActivityCallback;
+  if (activityCallback)
+    activityCallback(cx, js::CTYPES_CALL_BEGIN);
 
   uintptr_t fn = *reinterpret_cast<uintptr_t*>(CData::GetData(obj));
 
 #if defined(XP_WIN)
   int32_t lastErrorStatus; // The status as defined by |GetLastError|
   int32_t savedLastError = GetLastError();
   SetLastError(0);
 #endif //defined(XP_WIN)
@@ -5792,18 +5794,18 @@ FunctionType::Call(JSContext* cx,
   errnoStatus = errno;
 #if defined(XP_WIN)
   lastErrorStatus = GetLastError();
   SetLastError(savedLastError);
 #endif // defined(XP_WIN)
 
   errno = savedErrno;
 
-  // We're no longer calling into C.
-  autoCallback.DoEndCallback();
+  if (activityCallback)
+    activityCallback(cx, js::CTYPES_CALL_END);
 
   // Store the error value for later consultation with |ctypes.getStatus|
   JSObject *objCTypes = CType::GetGlobalCTypes(cx, typeObj);
   if (!objCTypes)
     return false;
 
   JS_SetReservedSlot(objCTypes, SLOT_ERRNO, INT_TO_JSVAL(errnoStatus));
 #if defined(XP_WIN)
@@ -6076,22 +6078,16 @@ CClosure::ClosureStub(ffi_cif* cif, void
   JS_ASSERT(cif);
   JS_ASSERT(result);
   JS_ASSERT(args);
   JS_ASSERT(userData);
 
   // Retrieve the essentials from our closure object.
   ClosureInfo* cinfo = static_cast<ClosureInfo*>(userData);
   JSContext* cx = cinfo->cx;
-
-  // Let the runtime callback know that we are about to call into JS again. The end callback will
-  // fire automatically when we exit this function.
-  js::AutoCTypesActivityCallback autoCallback(cx, js::CTYPES_CALLBACK_BEGIN,
-                                              js::CTYPES_CALLBACK_END);
-
   RootedObject typeObj(cx, cinfo->typeObj);
   RootedObject thisObj(cx, cinfo->thisObj);
   RootedObject jsfnObj(cx, cinfo->jsfnObj);
 
   JS_AbortIfWrongThread(JS_GetRuntime(cx));
 
   JSAutoRequest ar(cx);
   JSAutoCompartment ac(cx, jsfnObj);
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -1003,21 +1003,9 @@ GetListBaseExpandoSlot()
 }
 
 JS_FRIEND_API(void)
 SetCTypesActivityCallback(JSRuntime *rt, CTypesActivityCallback cb)
 {
     rt->ctypesActivityCallback = cb;
 }
 
-AutoCTypesActivityCallback::AutoCTypesActivityCallback(JSContext *cx,
-                                                       CTypesActivityType beginType,
-                                                       CTypesActivityType endType
-                                                       MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
-  : cx(cx), callback(cx->runtime->ctypesActivityCallback), beginType(beginType), endType(endType)
-{
-    MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-
-    if (callback)
-        callback(cx, beginType);
-}
-
 } // namespace js
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -1542,49 +1542,24 @@ IdToValue(jsid id)
 static JS_ALWAYS_INLINE jsval
 IdToJsval(jsid id)
 {
     return IdToValue(id);
 }
 
 enum CTypesActivityType {
     CTYPES_CALL_BEGIN,
-    CTYPES_CALL_END,
-    CTYPES_CALLBACK_BEGIN,
-    CTYPES_CALLBACK_END
+    CTYPES_CALL_END
 };
 
 typedef void
 (* CTypesActivityCallback)(JSContext *cx, CTypesActivityType type);
 
 /*
  * Sets a callback that is run whenever js-ctypes is about to be used when
  * calling into C.
  */
 JS_FRIEND_API(void)
 SetCTypesActivityCallback(JSRuntime *rt, CTypesActivityCallback cb);
 
-class JS_FRIEND_API(AutoCTypesActivityCallback) {
-  private:
-    JSContext *cx;
-    CTypesActivityCallback callback;
-    CTypesActivityType beginType;
-    CTypesActivityType endType;
-    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-
-  public:
-    AutoCTypesActivityCallback(JSContext *cx, CTypesActivityType beginType,
-                               CTypesActivityType endType
-                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
-    ~AutoCTypesActivityCallback() {
-        DoEndCallback();
-    }
-    void DoEndCallback() {
-        if (callback) {
-            callback(cx, endType);
-            callback = NULL;
-        }
-    }
-};
-
 } /* namespace js */
 
 #endif /* jsfriendapi_h___ */
\ No newline at end of file