diff options
author | Myles Borins <mylesborins@google.com> | 2019-09-24 11:56:38 -0400 |
---|---|---|
committer | Myles Borins <myles.borins@gmail.com> | 2019-10-07 03:19:23 -0400 |
commit | f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2 (patch) | |
tree | f5edbccb3ffda2573d70a6e291e7157f290e0ae0 /deps/v8/src/torque/contextual.h | |
parent | ffd22e81983056d09c064c59343a0e488236272d (diff) | |
download | android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.gz android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.bz2 android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.zip |
deps: update V8 to 7.8.279.9
PR-URL: https://github.com/nodejs/node/pull/29694
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Diffstat (limited to 'deps/v8/src/torque/contextual.h')
-rw-r--r-- | deps/v8/src/torque/contextual.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/deps/v8/src/torque/contextual.h b/deps/v8/src/torque/contextual.h index 92d2bdf3d7..d7764bfa68 100644 --- a/deps/v8/src/torque/contextual.h +++ b/deps/v8/src/torque/contextual.h @@ -15,7 +15,7 @@ namespace internal { namespace torque { template <class Variable> -V8_EXPORT_PRIVATE typename Variable::VariableType*& ContextualVariableTop(); +V8_EXPORT_PRIVATE typename Variable::Scope*& ContextualVariableTop(); // {ContextualVariable} provides a clean alternative to a global variable. // The contextual variable is mutable, and supports managing the value of @@ -30,8 +30,6 @@ V8_EXPORT_PRIVATE typename Variable::VariableType*& ContextualVariableTop(); template <class Derived, class VarType> class ContextualVariable { public: - using VariableType = VarType; - // A {Scope} contains a new object of type {VarType} and gives // ContextualVariable::Get() access to it. Upon destruction, the contextual // variable is restored to the state before the {Scope} was created. Scopes @@ -41,18 +39,20 @@ class ContextualVariable { public: template <class... Args> explicit Scope(Args&&... args) - : current_(std::forward<Args>(args)...), previous_(Top()) { - Top() = ¤t_; + : value_(std::forward<Args>(args)...), previous_(Top()) { + Top() = this; } ~Scope() { // Ensure stack discipline. - DCHECK_EQ(¤t_, Top()); + DCHECK_EQ(this, Top()); Top() = previous_; } + VarType& Value() { return value_; } + private: - VarType current_; - VarType* previous_; + VarType value_; + Scope* previous_; static_assert(std::is_base_of<ContextualVariable, Derived>::value, "Curiously Recurring Template Pattern"); @@ -65,13 +65,13 @@ class ContextualVariable { // for this contextual variable. static VarType& Get() { DCHECK_NOT_NULL(Top()); - return *Top(); + return Top()->Value(); } private: template <class T> - friend typename T::VariableType*& ContextualVariableTop(); - static VarType*& Top() { return ContextualVariableTop<Derived>(); } + friend typename T::Scope*& ContextualVariableTop(); + static Scope*& Top() { return ContextualVariableTop<Derived>(); } static bool HasScope() { return Top() != nullptr; } friend class MessageBuilder; @@ -82,11 +82,11 @@ class ContextualVariable { struct VarName \ : v8::internal::torque::ContextualVariable<VarName, __VA_ARGS__> {} -#define DEFINE_CONTEXTUAL_VARIABLE(VarName) \ - template <> \ - V8_EXPORT_PRIVATE VarName::VariableType*& ContextualVariableTop<VarName>() { \ - static thread_local VarName::VariableType* top = nullptr; \ - return top; \ +#define DEFINE_CONTEXTUAL_VARIABLE(VarName) \ + template <> \ + V8_EXPORT_PRIVATE VarName::Scope*& ContextualVariableTop<VarName>() { \ + static thread_local VarName::Scope* top = nullptr; \ + return top; \ } // By inheriting from {ContextualClass} a class can become a contextual variable |