9240b556c2
The EnableFlagScope is useful also for non-boolean flags. With the template we can use if for example in the wasm fuzzers to reduce the maximum memory size of a wasm module. In addition I put the EnableFlagScope into the v8::internal namespace, and I fixed a small typo. BUG=v8:6474 R=clemensh@chromium.org Change-Id: Iae5d5c058c334cd0f9e09d20adfd229fc2d6c585 Reviewed-on: https://chromium-review.googlesource.com/531005 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#45862}
31 lines
721 B
C++
31 lines
721 B
C++
// 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
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
template <typename T>
|
|
class FlagScope {
|
|
public:
|
|
FlagScope(T* flag, T new_value) : flag_(flag), previous_value_(*flag) {
|
|
*flag = new_value;
|
|
}
|
|
~FlagScope() { *flag_ = previous_value_; }
|
|
|
|
private:
|
|
T* flag_;
|
|
T previous_value_;
|
|
};
|
|
|
|
#define EXPERIMENTAL_FLAG_SCOPE(flag) \
|
|
FlagScope<bool> __scope_##__LINE__(&FLAG_experimental_wasm_##flag, true)
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|
|
|
|
#endif // V8_TEST_COMMON_FLAG_UTILS_H
|