From 9ed8b208a7bab45ce12bba2518571fba79eeb7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Thu, 15 Mar 2018 03:41:23 -0700 Subject: [PATCH] Bug 1442599 - Part 1: Replace AutoScopedAssign with MakeScopeExit. r=jorendorff --HG-- extra : rebase_source : 15f362a6976aedea503a983f14acfc6c626914f8 --- js/src/jsexn.cpp | 7 ++++++- js/src/jsutil.h | 21 --------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index c6151f030ff1..836ad17eae5a 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -10,6 +10,7 @@ #include "jsexn.h" +#include "mozilla/ScopeExit.h" #include "mozilla/Sprintf.h" #include @@ -667,7 +668,11 @@ js::ErrorToException(JSContext* cx, JSErrorReport* reportp, // Prevent infinite recursion. if (cx->generatingError) return; - AutoScopedAssign asa(&cx->generatingError.ref(), true); + + cx->generatingError = true; + auto restore = mozilla::MakeScopeExit([cx] { + cx->generatingError = false; + }); // Create an exception object. RootedString messageStr(cx, reportp->newMessageString(cx)); diff --git a/js/src/jsutil.h b/js/src/jsutil.h index 1ece05df3d7f..9c9fd902f1e0 100644 --- a/js/src/jsutil.h +++ b/js/src/jsutil.h @@ -13,7 +13,6 @@ #include "mozilla/Assertions.h" #include "mozilla/Compiler.h" -#include "mozilla/GuardObjects.h" #include "mozilla/HashFunctions.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/PodOperations.h" @@ -156,26 +155,6 @@ Max(T t1, T t2) return t1 > t2 ? t1 : t2; } -template -class MOZ_RAII AutoScopedAssign -{ - public: - AutoScopedAssign(T* addr, const T& value - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : addr_(addr), old(*addr_) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - *addr_ = value; - } - - ~AutoScopedAssign() { *addr_ = old; } - - private: - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER - T* addr_; - T old; -}; - template static inline U ComputeByteAlignment(T bytes, U alignment)