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.
|
|
|
|
|
2020-10-05 15:01:50 +00:00
|
|
|
#ifndef V8_TEST_COMMON_WASM_FLAG_UTILS_H
|
|
|
|
#define V8_TEST_COMMON_WASM_FLAG_UTILS_H
|
2017-05-31 13:31:52 +00:00
|
|
|
|
2019-11-26 16:25:14 +00:00
|
|
|
#include "src/wasm/wasm-features.h"
|
2020-10-05 15:01:50 +00:00
|
|
|
#include "test/common/flag-utils.h"
|
2019-11-26 16:25:14 +00:00
|
|
|
|
2017-06-12 13:32:13 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2017-09-25 15:57:50 +00:00
|
|
|
#define EXPERIMENTAL_FLAG_SCOPE(flag) FLAG_SCOPE(experimental_wasm_##flag)
|
2017-06-12 13:32:13 +00:00
|
|
|
|
2019-11-26 16:25:14 +00:00
|
|
|
namespace wasm {
|
|
|
|
|
2020-11-26 10:08:27 +00:00
|
|
|
class V8_NODISCARD WasmFeatureScope {
|
2019-11-26 16:25:14 +00:00
|
|
|
public:
|
|
|
|
explicit WasmFeatureScope(WasmFeatures* features, WasmFeature feature,
|
|
|
|
bool val = true)
|
|
|
|
: prev_(features->contains(feature)),
|
|
|
|
feature_(feature),
|
|
|
|
features_(features) {
|
|
|
|
set(val);
|
|
|
|
}
|
|
|
|
~WasmFeatureScope() { set(prev_); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void set(bool val) {
|
|
|
|
if (val) {
|
|
|
|
features_->Add(feature_);
|
|
|
|
} else {
|
|
|
|
features_->Remove(feature_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool const prev_;
|
|
|
|
WasmFeature const feature_;
|
|
|
|
WasmFeatures* const features_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define WASM_FEATURE_SCOPE(feat) \
|
|
|
|
WasmFeatureScope feat##_scope(&this->enabled_features_, kFeature_##feat)
|
|
|
|
|
|
|
|
#define WASM_FEATURE_SCOPE_VAL(feat, val) \
|
|
|
|
WasmFeatureScope feat##_scope(&this->enabled_features_, kFeature_##feat, val)
|
|
|
|
|
|
|
|
} // namespace wasm
|
2017-06-12 13:32:13 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2017-05-31 13:31:52 +00:00
|
|
|
|
2020-10-05 15:01:50 +00:00
|
|
|
#endif // V8_TEST_COMMON_WASM_FLAG_UTILS_H
|