Commit 4d97ff59 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[inspector][test][cleanup] Introduce enums for bools

Instead of passing two bools to the {TaskRunner} constructor, pass to
enums. This makes the semantics more clear in the caller.

In the fuzzer, we actually *do not* want to catch exceptions. This
semantic fix will be done in a follow-up CL, such that this CL is a pure
refactoring.

R=szuend@chromium.org

Bug: v8:11074
Change-Id: I7f6df3a3f344524deb08db10b9317a6734b7ea42
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2526385Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71056}
parent 4e0da20d
......@@ -567,8 +567,8 @@ void FuzzInspector(const uint8_t* data, size_t size) {
IsolateData::SetupGlobalTasks frontend_extensions;
frontend_extensions.emplace_back(new UtilsExtension());
TaskRunner frontend_runner(std::move(frontend_extensions), true,
&ready_semaphore, nullptr, false);
TaskRunner frontend_runner(std::move(frontend_extensions), kDoCatchExceptions,
&ready_semaphore, nullptr, kNoInspector);
ready_semaphore.Wait();
int frontend_context_group_id = 0;
......@@ -580,8 +580,8 @@ void FuzzInspector(const uint8_t* data, size_t size) {
IsolateData::SetupGlobalTasks backend_extensions;
backend_extensions.emplace_back(new SetTimeoutExtension());
backend_extensions.emplace_back(new InspectorExtension());
TaskRunner backend_runner(std::move(backend_extensions), false,
&ready_semaphore, nullptr, true);
TaskRunner backend_runner(std::move(backend_extensions), kDontCatchExceptions,
&ready_semaphore, nullptr, kWithInspector);
ready_semaphore.Wait();
UtilsExtension::set_backend_task_runner(&backend_runner);
......
......@@ -754,8 +754,8 @@ int InspectorTestMain(int argc, char* argv[]) {
IsolateData::SetupGlobalTasks frontend_extensions;
frontend_extensions.emplace_back(new UtilsExtension());
TaskRunner frontend_runner(
std::move(frontend_extensions), true, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, false);
std::move(frontend_extensions), kDoCatchExceptions, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, kNoInspector);
ready_semaphore.Wait();
int frontend_context_group_id = 0;
......@@ -768,8 +768,8 @@ int InspectorTestMain(int argc, char* argv[]) {
backend_extensions.emplace_back(new SetTimeoutExtension());
backend_extensions.emplace_back(new InspectorExtension());
TaskRunner backend_runner(
std::move(backend_extensions), false, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, true);
std::move(backend_extensions), kDontCatchExceptions, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, kWithInspector);
ready_semaphore.Wait();
UtilsExtension::set_backend_task_runner(&backend_runner);
......
......@@ -40,7 +40,8 @@ class Inspectable : public v8_inspector::V8InspectorSession::Inspectable {
IsolateData::IsolateData(TaskRunner* task_runner,
IsolateData::SetupGlobalTasks setup_global_tasks,
v8::StartupData* startup_data, bool with_inspector)
v8::StartupData* startup_data,
WithInspector with_inspector)
: task_runner_(task_runner),
setup_global_tasks_(std::move(setup_global_tasks)) {
v8::Isolate::CreateParams params;
......
......@@ -20,6 +20,8 @@ namespace internal {
class TaskRunner;
enum WithInspector : bool { kWithInspector = true, kNoInspector = false };
class IsolateData : public v8_inspector::V8InspectorClient {
public:
class SetupGlobalTask {
......@@ -31,7 +33,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
using SetupGlobalTasks = std::vector<std::unique_ptr<SetupGlobalTask>>;
IsolateData(TaskRunner* task_runner, SetupGlobalTasks setup_global_tasks,
v8::StartupData* startup_data, bool with_inspector);
v8::StartupData* startup_data, WithInspector with_inspector);
static IsolateData* FromContext(v8::Local<v8::Context> context);
v8::Isolate* isolate() const { return isolate_.get(); }
......
......@@ -36,9 +36,10 @@ void ReportUncaughtException(v8::Isolate* isolate,
} // namespace
TaskRunner::TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks,
bool catch_exceptions,
CatchExceptions catch_exceptions,
v8::base::Semaphore* ready_semaphore,
v8::StartupData* startup_data, bool with_inspector)
v8::StartupData* startup_data,
WithInspector with_inspector)
: Thread(Options("Task Runner")),
setup_global_tasks_(std::move(setup_global_tasks)),
startup_data_(startup_data),
......
......@@ -20,6 +20,11 @@
namespace v8 {
namespace internal {
enum CatchExceptions : bool {
kDoCatchExceptions = true,
kDontCatchExceptions = false
};
class TaskRunner : public v8::base::Thread {
public:
class Task {
......@@ -30,8 +35,9 @@ class TaskRunner : public v8::base::Thread {
};
TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks,
bool catch_exceptions, v8::base::Semaphore* ready_semaphore,
v8::StartupData* startup_data, bool with_inspector);
CatchExceptions catch_exceptions,
v8::base::Semaphore* ready_semaphore,
v8::StartupData* startup_data, WithInspector with_inspector);
~TaskRunner() override;
IsolateData* data() const { return data_.get(); }
......@@ -52,8 +58,8 @@ class TaskRunner : public v8::base::Thread {
IsolateData::SetupGlobalTasks setup_global_tasks_;
v8::StartupData* startup_data_;
bool with_inspector_;
bool catch_exceptions_;
WithInspector with_inspector_;
CatchExceptions catch_exceptions_;
v8::base::Semaphore* ready_semaphore_;
std::unique_ptr<IsolateData> data_;
......
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