Backed out changeset 716ba77a9d0a (bug 967005) for ASAN m-4 failures
authorWes Kocher <wkocher@mozilla.com>
Tue, 11 Mar 2014 17:23:35 -0700
changeset 191317 0a70c0402338931c5c98ede826e8738cf7d00296
parent 191316 53ce2fc68c7ea96cf06b9ff19c2faa260b9353ce
child 191318 8086940542db577d848d9d9bb62b50efd297aff6
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs967005
milestone30.0a1
backs out716ba77a9d0a8d72fe8c4e3273bdcf0d5b57fe47
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
Backed out changeset 716ba77a9d0a (bug 967005) for ASAN m-4 failures
dom/promise/Promise.cpp
dom/promise/Promise.h
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -180,20 +180,21 @@ public:
   }
 };
 
 // Promise
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Promise)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Promise)
-  tmp->MaybeReportRejectedOnce();
+  tmp->MaybeReportRejected();
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mGlobal)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mResolveCallbacks);
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mRejectCallbacks);
+  tmp->mResult = JS::UndefinedValue();
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Promise)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGlobal)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mResolveCallbacks);
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRejectCallbacks);
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
@@ -223,17 +224,18 @@ Promise::Promise(nsIGlobalObject* aGloba
   MOZ_ASSERT(mGlobal);
 
   mozilla::HoldJSObjects(this);
   SetIsDOMBinding();
 }
 
 Promise::~Promise()
 {
-  MaybeReportRejectedOnce();
+  MaybeReportRejected();
+  mResult = JS::UndefinedValue();
   mozilla::DropJSObjects(this);
 }
 
 JSObject*
 Promise::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return PromiseBinding::Wrap(aCx, aScope, this);
 }
@@ -815,19 +817,16 @@ Promise::AppendCallbacks(PromiseCallback
 {
   if (aResolveCallback) {
     mResolveCallbacks.AppendElement(aResolveCallback);
   }
 
   if (aRejectCallback) {
     mHadRejectCallback = true;
     mRejectCallbacks.AppendElement(aRejectCallback);
-
-    // Now that there is a callback, we don't need to report anymore.
-    RemoveFeature();
   }
 
   // If promise's state is resolved, queue a task to process our resolve
   // callbacks with promise's result. If promise's state is rejected, queue a
   // task to process our reject callbacks with promise's result.
   if (mState != Pending && !mTaskPending) {
     if (MOZ_LIKELY(NS_IsMainThread())) {
       nsRefPtr<PromiseTask> task = new PromiseTask(this);
@@ -1054,57 +1053,19 @@ Promise::RunResolveTask(JS::Handle<JS::V
   // Resolve/RejectInternal rather than using the Maybe... forms. Stop SetState
   // from asserting.
   if (mState != Pending) {
     return;
   }
 
   SetResult(aValue);
   SetState(aState);
-
-  // If the Promise was rejected, and there is no reject handler already setup,
-  // watch for thread shutdown.
-  if (aState == PromiseState::Rejected &&
-      !mHadRejectCallback &&
-      !NS_IsMainThread()) {
-    WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
-    MOZ_ASSERT(worker);
-    worker->AssertIsOnWorkerThread();
-
-    mFeature = new PromiseReportRejectFeature(this);
-    if (NS_WARN_IF(!worker->AddFeature(worker->GetJSContext(), mFeature))) {
-      // Worker is shutting down, report rejection immediately since it is
-      // unlikely that reject callbacks will be added after this point.
-      MaybeReportRejected();
-    }
-  }
-
   RunTask();
 }
 
-void
-Promise::RemoveFeature()
-{
-  if (mFeature) {
-    WorkerPrivate* worker = GetCurrentThreadWorkerPrivate();
-    MOZ_ASSERT(worker);
-    worker->RemoveFeature(worker->GetJSContext(), mFeature);
-    mFeature = nullptr;
-  }
-}
-
-bool
-PromiseReportRejectFeature::Notify(JSContext* aCx, workers::Status aStatus)
-{
-  MOZ_ASSERT(aStatus > workers::Running);
-  mPromise->MaybeReportRejectedOnce();
-  mPromise = nullptr;
-  return true;
-}
-
 bool
 Promise::ArgumentToJSValue(const nsAString& aArgument,
                            JSContext* aCx,
                            JSObject* aScope,
                            JS::MutableHandle<JS::Value> aValue)
 {
   // XXXkhuey I'd love to use xpc::NonVoidStringToJsval here, but it requires
   // a non-const nsAString for silly reasons.
--- a/dom/promise/Promise.h
+++ b/dom/promise/Promise.h
@@ -13,53 +13,33 @@
 #include "mozilla/dom/BindingDeclarations.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/dom/PromiseBinding.h"
 #include "mozilla/dom/TypedArray.h"
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
 #include "js/TypeDecls.h"
 
-#include "mozilla/dom/workers/bindings/WorkerFeature.h"
-
 class nsIGlobalObject;
 
 namespace mozilla {
 namespace dom {
 
 class AnyCallback;
 class PromiseCallback;
 class PromiseInit;
 class PromiseNativeHandler;
 
-class Promise;
-class PromiseReportRejectFeature : public workers::WorkerFeature
-{
-  // The Promise that owns this feature.
-  Promise* mPromise;
-
-public:
-  PromiseReportRejectFeature(Promise* aPromise)
-    : mPromise(aPromise)
-  {
-    MOZ_ASSERT(mPromise);
-  }
-
-  virtual bool
-  Notify(JSContext* aCx, workers::Status aStatus) MOZ_OVERRIDE;
-};
-
 class Promise MOZ_FINAL : public nsISupports,
                           public nsWrapperCache
 {
   friend class NativePromiseCallback;
   friend class PromiseResolverMixin;
   friend class PromiseResolverTask;
   friend class PromiseTask;
-  friend class PromiseReportRejectFeature;
   friend class RejectPromiseCallback;
   friend class ResolvePromiseCallback;
   friend class WorkerPromiseResolverTask;
   friend class WorkerPromiseTask;
   friend class WrapperPromiseCallback;
 
   ~Promise();
 
@@ -172,25 +152,18 @@ private:
                       Promise::PromiseState aState,
                       PromiseTaskSync aAsynchronous);
 
   void AppendCallbacks(PromiseCallback* aResolveCallback,
                        PromiseCallback* aRejectCallback);
 
   // If we have been rejected and our mResult is a JS exception,
   // report it to the error console.
-  // Use MaybeReportRejectedOnce() for actual calls.
   void MaybeReportRejected();
 
-  void MaybeReportRejectedOnce() {
-    MaybeReportRejected();
-    RemoveFeature();
-    mResult = JS::UndefinedValue();
-  }
-
   void MaybeResolveInternal(JSContext* aCx,
                             JS::Handle<JS::Value> aValue,
                             PromiseTaskSync aSync = AsyncTask);
   void MaybeRejectInternal(JSContext* aCx,
                            JS::Handle<JS::Value> aValue,
                            PromiseTaskSync aSync = AsyncTask);
 
   void ResolveInternal(JSContext* aCx,
@@ -293,33 +266,25 @@ private:
   CreateFunction(JSContext* aCx, JSObject* aParent, Promise* aPromise,
                 int32_t aTask);
 
   static JSObject*
   CreateThenableFunction(JSContext* aCx, Promise* aPromise, uint32_t aTask);
 
   void HandleException(JSContext* aCx);
 
-  void RemoveFeature();
-
   nsRefPtr<nsIGlobalObject> mGlobal;
 
   nsTArray<nsRefPtr<PromiseCallback> > mResolveCallbacks;
   nsTArray<nsRefPtr<PromiseCallback> > mRejectCallbacks;
 
   JS::Heap<JS::Value> mResult;
   PromiseState mState;
   bool mTaskPending;
   bool mHadRejectCallback;
 
   bool mResolvePending;
-
-  // If a rejected promise on a worker has no reject callbacks attached, it
-  // needs to know when the worker is shutting down, to report the error on the
-  // console before the worker's context is deleted. This feature is used for
-  // that purpose.
-  nsAutoPtr<PromiseReportRejectFeature> mFeature;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_Promise_h