Commit 4064757c authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[cleanup] Clean up base::EnumSet

After moving to its own header, this CL cleans up some parts of the
interface. It fixes names and const-declarations of simple accessors,
and adds a named constructor to make it explicit that an EnumSet should
be constructed from an integral value.
Also refactor the use in cctest.h to have less statically declared
constants. Instead, just create the set of extensions in the individual
tests.

R=titzer@chromium.org

Bug: v8:8562
Change-Id: I6178d1aba25afa1d7f54c29ccf81505c165e7cd3
Reviewed-on: https://chromium-review.googlesource.com/c/1409366
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58862}
parent 7b0038ef
......@@ -52,20 +52,20 @@ Handle<Object> StdlibMathMember(Isolate* isolate, Handle<JSReceiver> stdlib,
bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
wasm::AsmJsParser::StdlibSet members,
bool* is_typed_array) {
if (members.Contains(wasm::AsmJsParser::StandardMember::kInfinity)) {
if (members.contains(wasm::AsmJsParser::StandardMember::kInfinity)) {
members.Remove(wasm::AsmJsParser::StandardMember::kInfinity);
Handle<Name> name = isolate->factory()->Infinity_string();
Handle<Object> value = JSReceiver::GetDataProperty(stdlib, name);
if (!value->IsNumber() || !std::isinf(value->Number())) return false;
}
if (members.Contains(wasm::AsmJsParser::StandardMember::kNaN)) {
if (members.contains(wasm::AsmJsParser::StandardMember::kNaN)) {
members.Remove(wasm::AsmJsParser::StandardMember::kNaN);
Handle<Name> name = isolate->factory()->NaN_string();
Handle<Object> value = JSReceiver::GetDataProperty(stdlib, name);
if (!value->IsNaN()) return false;
}
#define STDLIB_MATH_FUNC(fname, FName, ignore1, ignore2) \
if (members.Contains(wasm::AsmJsParser::StandardMember::kMath##FName)) { \
if (members.contains(wasm::AsmJsParser::StandardMember::kMath##FName)) { \
members.Remove(wasm::AsmJsParser::StandardMember::kMath##FName); \
Handle<Name> name(isolate->factory()->InternalizeOneByteString( \
StaticCharVector(#fname))); \
......@@ -82,7 +82,7 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
STDLIB_MATH_FUNCTION_LIST(STDLIB_MATH_FUNC)
#undef STDLIB_MATH_FUNC
#define STDLIB_MATH_CONST(cname, const_value) \
if (members.Contains(wasm::AsmJsParser::StandardMember::kMath##cname)) { \
if (members.contains(wasm::AsmJsParser::StandardMember::kMath##cname)) { \
members.Remove(wasm::AsmJsParser::StandardMember::kMath##cname); \
Handle<Name> name(isolate->factory()->InternalizeOneByteString( \
StaticCharVector(#cname))); \
......@@ -92,7 +92,7 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
STDLIB_MATH_VALUE_LIST(STDLIB_MATH_CONST)
#undef STDLIB_MATH_CONST
#define STDLIB_ARRAY_TYPE(fname, FName) \
if (members.Contains(wasm::AsmJsParser::StandardMember::k##FName)) { \
if (members.contains(wasm::AsmJsParser::StandardMember::k##FName)) { \
members.Remove(wasm::AsmJsParser::StandardMember::k##FName); \
*is_typed_array = true; \
Handle<Name> name(isolate->factory()->InternalizeOneByteString( \
......@@ -112,7 +112,7 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
STDLIB_ARRAY_TYPE(float64_array_fun, Float64Array)
#undef STDLIB_ARRAY_TYPE
// All members accounted for.
DCHECK(members.IsEmpty());
DCHECK(members.empty());
return true;
}
......@@ -366,8 +366,9 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
// Check that all used stdlib members are valid.
bool stdlib_use_of_typed_array_present = false;
wasm::AsmJsParser::StdlibSet stdlib_uses(uses_bitset->value_as_bits());
if (!stdlib_uses.IsEmpty()) { // No checking needed if no uses.
wasm::AsmJsParser::StdlibSet stdlib_uses =
wasm::AsmJsParser::StdlibSet::FromIntegral(uses_bitset->value_as_bits());
if (!stdlib_uses.empty()) { // No checking needed if no uses.
if (stdlib.is_null()) {
ReportInstantiationFailure(script, position, "Requires standard library");
return MaybeHandle<Object>();
......
......@@ -19,10 +19,15 @@ class EnumSet {
static_assert(std::is_enum<E>::value, "EnumSet can only be used with enums");
public:
explicit EnumSet(T bits = 0) : bits_(bits) {}
bool IsEmpty() const { return bits_ == 0; }
bool Contains(E element) const { return (bits_ & Mask(element)) != 0; }
bool ContainsAnyOf(const EnumSet& set) const {
constexpr EnumSet() = default;
EnumSet(std::initializer_list<E> init) {
for (E e : init) Add(e);
}
bool empty() const { return bits_ == 0; }
bool contains(E element) const { return (bits_ & Mask(element)) != 0; }
bool contains_any(const EnumSet& set) const {
return (bits_ & set.bits_) != 0;
}
void Add(E element) { bits_ |= Mask(element); }
......@@ -32,8 +37,8 @@ class EnumSet {
void RemoveAll() { bits_ = 0; }
void Intersect(const EnumSet& set) { bits_ &= set.bits_; }
T ToIntegral() const { return bits_; }
bool operator==(const EnumSet& set) { return bits_ == set.bits_; }
bool operator!=(const EnumSet& set) { return bits_ != set.bits_; }
bool operator==(const EnumSet& set) const { return bits_ == set.bits_; }
bool operator!=(const EnumSet& set) const { return bits_ != set.bits_; }
EnumSet operator|(const EnumSet& set) const {
return EnumSet(bits_ | set.bits_);
}
......@@ -41,7 +46,11 @@ class EnumSet {
return EnumSet(bits_ & set.bits_);
}
static constexpr EnumSet FromIntegral(T bits) { return EnumSet{bits}; }
private:
explicit constexpr EnumSet(T bits) : bits_(bits) {}
static T Mask(E element) {
DCHECK_GT(sizeof(T) * 8, static_cast<int>(element));
return T{1} << static_cast<typename std::underlying_type<E>::type>(element);
......
......@@ -109,7 +109,7 @@ void GapResolver::Resolve(ParallelMove* moves) {
++it;
}
if ((source_kinds & destination_kinds).IsEmpty() || moves->size() < 2) {
if ((source_kinds & destination_kinds).empty() || moves->size() < 2) {
// Fast path for non-conflicting parallel moves.
for (MoveOperands* move : *moves) {
assembler_->AssembleMove(&move->source(), &move->destination());
......
......@@ -199,7 +199,7 @@ class V8_EXPORT_PRIVATE MachineOperatorBuilder final
case kNoSupport:
return false;
case kSomeSupport:
return !unsupported.Contains(rep);
return !unsupported.contains(rep);
}
UNREACHABLE();
}
......
......@@ -1692,11 +1692,11 @@ void CompilationStateImpl::OnFinishedUnit(ExecutionTier tier, WasmCode* code) {
}
}
if (!events.IsEmpty()) {
if (!events.empty()) {
auto notify_events = [this, events] {
for (auto event : {CompilationEvent::kFinishedBaselineCompilation,
CompilationEvent::kFinishedTopTierCompilation}) {
if (!events.Contains(event)) continue;
if (!events.contains(event)) continue;
NotifyOnEvent(event, nullptr);
}
};
......
......@@ -161,21 +161,21 @@ void CcTest::TearDown() {
if (isolate_ != nullptr) isolate_->Dispose();
}
v8::Local<v8::Context> CcTest::NewContext(CcTestExtensionFlags extensions,
v8::Local<v8::Context> CcTest::NewContext(CcTestExtensionFlags extension_flags,
v8::Isolate* isolate) {
const char* extension_names[kMaxExtensions];
int extension_count = 0;
#define CHECK_EXTENSION_FLAG(Name, Id) \
if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id;
EXTENSION_LIST(CHECK_EXTENSION_FLAG)
#undef CHECK_EXTENSION_FLAG
v8::ExtensionConfiguration config(extension_count, extension_names);
v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
CHECK(!context.IsEmpty());
return context;
const char* extension_names[kMaxExtensions];
int extension_count = 0;
for (int i = 0; i < kMaxExtensions; ++i) {
if (!extension_flags.contains(static_cast<CcTestExtensionId>(i))) continue;
extension_names[extension_count] = kExtensionName[i];
++extension_count;
}
v8::ExtensionConfiguration config(extension_count, extension_names);
v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
CHECK(!context.IsEmpty());
return context;
}
void CcTest::DisableAutomaticDispose() {
CHECK_EQ(kUninitialized, initialization_state_);
disable_automatic_dispose_ = true;
......
......@@ -88,20 +88,15 @@ class Zone;
V(TRACE_EXTENSION, "v8/trace")
#define DEFINE_EXTENSION_ID(Name, Ident) Name##_ID,
enum CcTestExtensionIds {
EXTENSION_LIST(DEFINE_EXTENSION_ID)
kMaxExtensions
};
enum CcTestExtensionId { EXTENSION_LIST(DEFINE_EXTENSION_ID) kMaxExtensions };
#undef DEFINE_EXTENSION_ID
using CcTestExtensionFlags = v8::base::EnumSet<CcTestExtensionIds>;
#define DEFINE_EXTENSION_FLAG(Name, Ident) \
static const CcTestExtensionFlags Name(1 << Name##_ID);
static const CcTestExtensionFlags NO_EXTENSIONS(0);
static const CcTestExtensionFlags ALL_EXTENSIONS((1 << kMaxExtensions) - 1);
EXTENSION_LIST(DEFINE_EXTENSION_FLAG)
#undef DEFINE_EXTENSION_FLAG
using CcTestExtensionFlags = v8::base::EnumSet<CcTestExtensionId>;
#define DEFINE_EXTENSION_NAME(Name, Ident) Ident,
static constexpr const char* kExtensionName[kMaxExtensions] = {
EXTENSION_LIST(DEFINE_EXTENSION_NAME)};
#undef DEFINE_EXTENSION_NAME
class CcTest {
public:
......@@ -161,7 +156,11 @@ class CcTest {
// Helper function to configure a context.
// Must be in a HandleScope.
static v8::Local<v8::Context> NewContext(
CcTestExtensionFlags extensions,
v8::Isolate* isolate = CcTest::isolate()) {
return NewContext({}, isolate);
}
static v8::Local<v8::Context> NewContext(
CcTestExtensionFlags extension_flags,
v8::Isolate* isolate = CcTest::isolate());
static void TearDown();
......
......@@ -154,7 +154,7 @@ TEST(Sum) {
TEST(Print) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION);
v8::Local<v8::Context> context = CcTest::NewContext({PRINT_EXTENSION_ID});
v8::Context::Scope context_scope(context);
const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);";
Handle<JSFunction> fun = Compile(source);
......@@ -222,7 +222,7 @@ TEST(C2JSFrames) {
FLAG_expose_gc = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context =
CcTest::NewContext(PRINT_EXTENSION | GC_EXTENSION);
CcTest::NewContext({PRINT_EXTENSION_ID, GC_EXTENSION_ID});
v8::Context::Scope context_scope(context);
const char* source = "function foo(a) { gc(), print(a); }";
......
......@@ -1079,7 +1079,7 @@ static const char* bound_function_test_source =
TEST(BoundFunctionCall) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
CompileRun(bound_function_test_source);
......@@ -1344,7 +1344,7 @@ static const char* cpu_profiler_deep_stack_test_source =
// 0 foo 21 #254 no reason
TEST(CpuProfileDeepStack) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
......@@ -1402,7 +1402,7 @@ static void CallJsFunction(const v8::FunctionCallbackInfo<v8::Value>& info) {
TEST(JsNativeJsSample) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
......@@ -1455,7 +1455,7 @@ static const char* js_native_js_runtime_js_test_source =
TEST(JsNativeJsRuntimeJsSample) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
......@@ -1512,7 +1512,7 @@ static const char* js_native1_js_native2_js_test_source =
TEST(JsNative1JsNative2JsSample) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
v8::Local<v8::Function> func1 =
......@@ -1558,7 +1558,7 @@ static void CallCollectSample(const v8::FunctionCallbackInfo<v8::Value>& info) {
TEST(CollectSampleAPI) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
v8::Local<v8::FunctionTemplate> func_template =
......@@ -1612,7 +1612,7 @@ static const char* js_native_js_runtime_multiple_test_source =
TEST(JsNativeJsRuntimeJsSampleMultiple) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
v8::Local<v8::FunctionTemplate> func_template =
......@@ -1677,7 +1677,7 @@ static const char* inlining_test_source =
TEST(Inlining) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
......@@ -1774,7 +1774,7 @@ const double load_factor = 1.0;
TEST(Inlining2) {
FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
CompileRun(inlining_test_source2);
......@@ -1894,7 +1894,7 @@ static void CheckFunctionDetails(v8::Isolate* isolate,
TEST(FunctionDetails) {
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
......@@ -1941,7 +1941,7 @@ TEST(FunctionDetailsInlining) {
if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return;
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
......@@ -2019,7 +2019,7 @@ TEST(FunctionDetailsInlining) {
TEST(DontStopOnFinishedProfileDelete) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
v8::CpuProfiler* profiler = v8::CpuProfiler::New(env->GetIsolate());
......@@ -2067,7 +2067,7 @@ TEST(CollectDeoptEvents) {
if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return;
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
i::CpuProfiler* iprofiler =
......@@ -2200,7 +2200,7 @@ TEST(DeoptAtFirstLevelInlinedSource) {
if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return;
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
i::CpuProfiler* iprofiler =
......@@ -2270,7 +2270,7 @@ TEST(DeoptAtSecondLevelInlinedSource) {
if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return;
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
i::CpuProfiler* iprofiler =
......@@ -2345,7 +2345,7 @@ TEST(DeoptUntrackedFunction) {
if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return;
i::FLAG_allow_natives_syntax = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
ProfilerHelper helper(env);
i::CpuProfiler* iprofiler =
......@@ -2556,7 +2556,7 @@ TEST(StaticCollectSampleAPI) {
TEST(CodeEntriesMemoryLeak) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
std::string source = "function start() {}\n";
......@@ -2590,7 +2590,7 @@ TEST(NativeFrameStackTrace) {
// v8::internal::StringTable::LookupStringIfExists_NoAllocate native function
// without producing an EXIT frame.
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
const char* source = R"(
......
......@@ -147,7 +147,7 @@ TEST(CFromJSStackTrace) {
i::TraceExtension::InitTraceEnv(&sample);
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Local<v8::Context> context = CcTest::NewContext({TRACE_EXTENSION_ID});
v8::Context::Scope context_scope(context);
// Create global function JSFuncDoTrace which calls
......@@ -196,7 +196,7 @@ TEST(PureJSStackTrace) {
i::TraceExtension::InitTraceEnv(&sample);
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Local<v8::Context> context = CcTest::NewContext({TRACE_EXTENSION_ID});
v8::Context::Scope context_scope(context);
// Create global function JSFuncDoTrace which calls
......@@ -266,7 +266,7 @@ TEST(PureCStackTrace) {
TickSample sample;
i::TraceExtension::InitTraceEnv(&sample);
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Local<v8::Context> context = CcTest::NewContext({TRACE_EXTENSION_ID});
v8::Context::Scope context_scope(context);
// Check that sampler doesn't crash
CHECK_EQ(10, CFunc(10));
......@@ -275,7 +275,7 @@ TEST(PureCStackTrace) {
TEST(JsEntrySp) {
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> context = CcTest::NewContext(TRACE_EXTENSION);
v8::Local<v8::Context> context = CcTest::NewContext({TRACE_EXTENSION_ID});
v8::Context::Scope context_scope(context);
CHECK(!i::TraceExtension::GetJsEntrySp());
CompileRun("a = 1; b = a + 1;");
......
......@@ -1551,33 +1551,33 @@ enum ParserSyncTestResult {
};
void SetGlobalFlags(base::EnumSet<ParserFlag> flags) {
i::FLAG_allow_natives_syntax = flags.Contains(kAllowNatives);
i::FLAG_harmony_public_fields = flags.Contains(kAllowHarmonyPublicFields);
i::FLAG_harmony_private_fields = flags.Contains(kAllowHarmonyPrivateFields);
i::FLAG_harmony_private_methods = flags.Contains(kAllowHarmonyPrivateMethods);
i::FLAG_harmony_static_fields = flags.Contains(kAllowHarmonyStaticFields);
i::FLAG_harmony_dynamic_import = flags.Contains(kAllowHarmonyDynamicImport);
i::FLAG_harmony_import_meta = flags.Contains(kAllowHarmonyImportMeta);
i::FLAG_allow_natives_syntax = flags.contains(kAllowNatives);
i::FLAG_harmony_public_fields = flags.contains(kAllowHarmonyPublicFields);
i::FLAG_harmony_private_fields = flags.contains(kAllowHarmonyPrivateFields);
i::FLAG_harmony_private_methods = flags.contains(kAllowHarmonyPrivateMethods);
i::FLAG_harmony_static_fields = flags.contains(kAllowHarmonyStaticFields);
i::FLAG_harmony_dynamic_import = flags.contains(kAllowHarmonyDynamicImport);
i::FLAG_harmony_import_meta = flags.contains(kAllowHarmonyImportMeta);
i::FLAG_harmony_numeric_separator =
flags.Contains(kAllowHarmonyNumericSeparator);
flags.contains(kAllowHarmonyNumericSeparator);
}
void SetParserFlags(i::PreParser* parser, base::EnumSet<ParserFlag> flags) {
parser->set_allow_natives(flags.Contains(kAllowNatives));
parser->set_allow_natives(flags.contains(kAllowNatives));
parser->set_allow_harmony_public_fields(
flags.Contains(kAllowHarmonyPublicFields));
flags.contains(kAllowHarmonyPublicFields));
parser->set_allow_harmony_private_fields(
flags.Contains(kAllowHarmonyPrivateFields));
flags.contains(kAllowHarmonyPrivateFields));
parser->set_allow_harmony_private_methods(
flags.Contains(kAllowHarmonyPrivateMethods));
flags.contains(kAllowHarmonyPrivateMethods));
parser->set_allow_harmony_static_fields(
flags.Contains(kAllowHarmonyStaticFields));
flags.contains(kAllowHarmonyStaticFields));
parser->set_allow_harmony_dynamic_import(
flags.Contains(kAllowHarmonyDynamicImport));
flags.contains(kAllowHarmonyDynamicImport));
parser->set_allow_harmony_import_meta(
flags.Contains(kAllowHarmonyImportMeta));
flags.contains(kAllowHarmonyImportMeta));
parser->set_allow_harmony_numeric_separator(
flags.Contains(kAllowHarmonyNumericSeparator));
flags.contains(kAllowHarmonyNumericSeparator));
}
void TestParserSyncWithFlags(i::Handle<i::String> source,
......@@ -1616,7 +1616,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
SetGlobalFlags(flags);
i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(isolate, script);
info.set_allow_lazy_parsing(flags.Contains(kAllowLazy));
info.set_allow_lazy_parsing(flags.contains(kAllowLazy));
if (is_module) info.set_module();
i::parsing::ParseProgram(&info, isolate);
function = info.literal();
......
......@@ -538,7 +538,7 @@ TEST(RecordStackTraceAtStartProfiling) {
i::FLAG_turbo_inlining = false;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
std::unique_ptr<i::CpuProfiler> iprofiler(
new i::CpuProfiler(CcTest::i_isolate()));
......@@ -616,7 +616,7 @@ TEST(ProfileNodeScriptId) {
i::FLAG_turbo_inlining = false;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
std::unique_ptr<CpuProfiler> iprofiler(new CpuProfiler(CcTest::i_isolate()));
i::ProfilerExtension::set_profiler(iprofiler.get());
......@@ -716,7 +716,7 @@ TEST(BailoutReason) {
i::FLAG_always_opt = false;
i::FLAG_opt = true;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Local<v8::Context> env = CcTest::NewContext({PROFILER_EXTENSION_ID});
v8::Context::Scope context_scope(env);
std::unique_ptr<CpuProfiler> iprofiler(new CpuProfiler(CcTest::i_isolate()));
i::ProfilerExtension::set_profiler(iprofiler.get());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment