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