5 #ifndef V8_TORQUE_CONTEXTUAL_H_ 6 #define V8_TORQUE_CONTEXTUAL_H_ 10 #include "src/base/macros.h" 11 #include "src/base/platform/platform.h" 27 template <
class Derived,
class VarType>
30 using VariableType = VarType;
39 template <
class... Args>
40 explicit Scope(Args&&... args)
41 : current_(std::forward<Args>(args)...), previous_(Top()) {
46 DCHECK_EQ(¤t_, Top());
54 static_assert(std::is_base_of<ContextualVariable, Derived>::value,
55 "Curiously Recurring Template Pattern");
57 DISALLOW_NEW_AND_DELETE();
58 DISALLOW_COPY_AND_ASSIGN(
Scope);
63 static VarType& Get() {
64 DCHECK_NOT_NULL(Top());
69 V8_EXPORT_PRIVATE
static VarType*& Top();
73 #define DECLARE_CONTEXTUAL_VARIABLE(VarName, ...) \ 75 : v8::internal::torque::ContextualVariable<VarName, __VA_ARGS__> {}; 77 #define DEFINE_CONTEXTUAL_VARIABLE(VarName) \ 79 V8_EXPORT_PRIVATE VarName::VariableType*& \ 80 ContextualVariable<VarName, VarName::VariableType>::Top() { \ 81 static thread_local VarName::VariableType* top = nullptr; \ 88 using ContextualClass = ContextualVariable<T, T>;
94 #endif // V8_TORQUE_CONTEXTUAL_H_