2017-05-31 13:31:52 +00:00
|
|
|
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef V8_TEST_COMMON_FLAG_UTILS_H
|
|
|
|
#define V8_TEST_COMMON_FLAG_UTILS_H
|
|
|
|
|
2017-06-12 13:32:13 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class FlagScope {
|
2017-05-31 13:31:52 +00:00
|
|
|
public:
|
2017-06-12 13:32:13 +00:00
|
|
|
FlagScope(T* flag, T new_value) : flag_(flag), previous_value_(*flag) {
|
2017-05-31 13:31:52 +00:00
|
|
|
*flag = new_value;
|
|
|
|
}
|
2017-06-12 13:32:13 +00:00
|
|
|
~FlagScope() { *flag_ = previous_value_; }
|
2017-05-31 13:31:52 +00:00
|
|
|
|
|
|
|
private:
|
2017-06-12 13:32:13 +00:00
|
|
|
T* flag_;
|
|
|
|
T previous_value_;
|
2017-05-31 13:31:52 +00:00
|
|
|
};
|
|
|
|
|
2017-09-25 15:57:50 +00:00
|
|
|
#define FLAG_SCOPE(flag) \
|
|
|
|
FlagScope<bool> __scope_##flag##__LINE__(&FLAG_##flag, true)
|
|
|
|
|
|
|
|
#define EXPERIMENTAL_FLAG_SCOPE(flag) FLAG_SCOPE(experimental_wasm_##flag)
|
2017-06-12 13:32:13 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2017-05-31 13:31:52 +00:00
|
|
|
|
|
|
|
#endif // V8_TEST_COMMON_FLAG_UTILS_H
|