Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_TEST_COMMON_FLAG_UTILS_H
6 : #define V8_TEST_COMMON_FLAG_UTILS_H
7 :
8 : namespace v8 {
9 : namespace internal {
10 :
11 : template <typename T>
12 : class FlagScope {
13 : public:
14 4002 : FlagScope(T* flag, T new_value) : flag_(flag), previous_value_(*flag) {
15 4017 : *flag = new_value;
16 : }
17 4001 : ~FlagScope() { *flag_ = previous_value_; }
18 :
19 : private:
20 : T* flag_;
21 : T previous_value_;
22 : };
23 :
24 : #define FLAG_SCOPE(flag) \
25 : FlagScope<bool> __scope_##flag##__LINE__(&FLAG_##flag, true)
26 :
27 : #define EXPERIMENTAL_FLAG_SCOPE(flag) FLAG_SCOPE(experimental_wasm_##flag)
28 :
29 : } // namespace internal
30 : } // namespace v8
31 :
32 : #endif // V8_TEST_COMMON_FLAG_UTILS_H
|