diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-09-21 09:14:51 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-09-22 18:29:25 +0200 |
commit | 0e7ddbd3d7e9439c67573b854c49cf82c398ae82 (patch) | |
tree | 2afe372acde921cb57ddb3444ff00c5adef8848c /deps/v8/src/torque/contextual.h | |
parent | 13245dc50da4cb7443c39ef6c68d419d5e6336d4 (diff) | |
download | android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.gz android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.tar.bz2 android-node-v8-0e7ddbd3d7e9439c67573b854c49cf82c398ae82.zip |
deps: update V8 to 7.0.276.20
PR-URL: https://github.com/nodejs/node/pull/22754
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/src/torque/contextual.h')
-rw-r--r-- | deps/v8/src/torque/contextual.h | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/deps/v8/src/torque/contextual.h b/deps/v8/src/torque/contextual.h index 9cd56a2ed9..8fb02e1072 100644 --- a/deps/v8/src/torque/contextual.h +++ b/deps/v8/src/torque/contextual.h @@ -27,6 +27,8 @@ namespace torque { 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 @@ -36,13 +38,13 @@ class ContextualVariable { public: template <class... Args> explicit Scope(Args&&... args) - : current_(std::forward<Args>(args)...), previous_(top_) { - top_ = ¤t_; + : current_(std::forward<Args>(args)...), previous_(Top()) { + Top() = ¤t_; } ~Scope() { // Ensure stack discipline. - DCHECK_EQ(¤t_, top_); - top_ = previous_; + DCHECK_EQ(¤t_, Top()); + Top() = previous_; } private: @@ -59,22 +61,27 @@ class ContextualVariable { // Access the most recent active {Scope}. There has to be an active {Scope} // for this contextual variable. static VarType& Get() { - DCHECK_NOT_NULL(top_); - return *top_; + DCHECK_NOT_NULL(Top()); + return *Top(); } private: - static thread_local VarType* top_; + V8_EXPORT_PRIVATE static VarType*& Top(); }; -template <class Derived, class VarType> -thread_local VarType* ContextualVariable<Derived, VarType>::top_ = nullptr; - // Usage: DECLARE_CONTEXTUAL_VARIABLE(VarName, VarType) #define DECLARE_CONTEXTUAL_VARIABLE(VarName, ...) \ struct VarName \ : v8::internal::torque::ContextualVariable<VarName, __VA_ARGS__> {}; +#define DEFINE_CONTEXTUAL_VARIABLE(VarName) \ + template <> \ + V8_EXPORT_PRIVATE VarName::VariableType*& \ + ContextualVariable<VarName, VarName::VariableType>::Top() { \ + static thread_local VarName::VariableType* top = nullptr; \ + return top; \ + } + // By inheriting from {ContextualClass} a class can become a contextual variable // of itself, which is very similar to a singleton. template <class T> |