v8/test/common/flag-utils.h
Clemens Backes 444e6e3482 Reland "[flags] Remove FLAG_* aliases"
This is a reland of commit e3096c31d6.
The one additional use of FLAG_turboshaft is also rewritten now.

Original change's description:
> [flags] Remove FLAG_* aliases
>
> This removes the deprecated FLAG_* aliases, and switches remaining uses
> to the new v8_flags syntax.
>
> R=jkummerow@chromium.org
>
> Bug: v8:12887
> Change-Id: Icde494a3819a9b1386c91e44f5d72a55666d9eae
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3952350
> Reviewed-by: Maya Lekova <mslekova@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#83686}

Bug: v8:12887
Change-Id: I978df89f51e11c9a101ff3c1e385b1eced697a74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3953292
Reviewed-by: Marja Hölttä <marja@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83717}
2022-10-14 13:13:55 +00:00

37 lines
947 B
C++

// Copyright 2020 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
#include "src/base/macros.h"
#include "src/flags/flags.h"
namespace v8 {
namespace internal {
template <typename T>
class V8_NODISCARD FlagScope {
public:
FlagScope(FlagValue<T>* flag, T new_value)
: flag_(flag), previous_value_(*flag) {
*flag = new_value;
}
~FlagScope() { *flag_ = previous_value_; }
private:
FlagValue<T>* flag_;
T previous_value_;
};
} // namespace internal
} // namespace v8
#define FLAG_VALUE_SCOPE(flag, value) \
::v8::internal::FlagScope<bool> UNIQUE_IDENTIFIER(__scope_##flag)( \
&::v8::internal::v8_flags.flag, value)
#define FLAG_SCOPE(flag) FLAG_VALUE_SCOPE(flag, true)
#endif // V8_TEST_COMMON_FLAG_UTILS_H