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) { ...@@ -567,8 +567,8 @@ void FuzzInspector(const uint8_t* data, size_t size) {
IsolateData::SetupGlobalTasks frontend_extensions; IsolateData::SetupGlobalTasks frontend_extensions;
frontend_extensions.emplace_back(new UtilsExtension()); frontend_extensions.emplace_back(new UtilsExtension());
TaskRunner frontend_runner(std::move(frontend_extensions), true, TaskRunner frontend_runner(std::move(frontend_extensions), kDoCatchExceptions,
&ready_semaphore, nullptr, false); &ready_semaphore, nullptr, kNoInspector);
ready_semaphore.Wait(); ready_semaphore.Wait();
int frontend_context_group_id = 0; int frontend_context_group_id = 0;
...@@ -580,8 +580,8 @@ void FuzzInspector(const uint8_t* data, size_t size) { ...@@ -580,8 +580,8 @@ void FuzzInspector(const uint8_t* data, size_t size) {
IsolateData::SetupGlobalTasks backend_extensions; IsolateData::SetupGlobalTasks backend_extensions;
backend_extensions.emplace_back(new SetTimeoutExtension()); backend_extensions.emplace_back(new SetTimeoutExtension());
backend_extensions.emplace_back(new InspectorExtension()); backend_extensions.emplace_back(new InspectorExtension());
TaskRunner backend_runner(std::move(backend_extensions), false, TaskRunner backend_runner(std::move(backend_extensions), kDontCatchExceptions,
&ready_semaphore, nullptr, true); &ready_semaphore, nullptr, kWithInspector);
ready_semaphore.Wait(); ready_semaphore.Wait();
UtilsExtension::set_backend_task_runner(&backend_runner); UtilsExtension::set_backend_task_runner(&backend_runner);
......
...@@ -754,8 +754,8 @@ int InspectorTestMain(int argc, char* argv[]) { ...@@ -754,8 +754,8 @@ int InspectorTestMain(int argc, char* argv[]) {
IsolateData::SetupGlobalTasks frontend_extensions; IsolateData::SetupGlobalTasks frontend_extensions;
frontend_extensions.emplace_back(new UtilsExtension()); frontend_extensions.emplace_back(new UtilsExtension());
TaskRunner frontend_runner( TaskRunner frontend_runner(
std::move(frontend_extensions), true, &ready_semaphore, std::move(frontend_extensions), kDoCatchExceptions, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, false); startup_data.data ? &startup_data : nullptr, kNoInspector);
ready_semaphore.Wait(); ready_semaphore.Wait();
int frontend_context_group_id = 0; int frontend_context_group_id = 0;
...@@ -768,8 +768,8 @@ int InspectorTestMain(int argc, char* argv[]) { ...@@ -768,8 +768,8 @@ int InspectorTestMain(int argc, char* argv[]) {
backend_extensions.emplace_back(new SetTimeoutExtension()); backend_extensions.emplace_back(new SetTimeoutExtension());
backend_extensions.emplace_back(new InspectorExtension()); backend_extensions.emplace_back(new InspectorExtension());
TaskRunner backend_runner( TaskRunner backend_runner(
std::move(backend_extensions), false, &ready_semaphore, std::move(backend_extensions), kDontCatchExceptions, &ready_semaphore,
startup_data.data ? &startup_data : nullptr, true); startup_data.data ? &startup_data : nullptr, kWithInspector);
ready_semaphore.Wait(); ready_semaphore.Wait();
UtilsExtension::set_backend_task_runner(&backend_runner); UtilsExtension::set_backend_task_runner(&backend_runner);
......
...@@ -40,7 +40,8 @@ class Inspectable : public v8_inspector::V8InspectorSession::Inspectable { ...@@ -40,7 +40,8 @@ class Inspectable : public v8_inspector::V8InspectorSession::Inspectable {
IsolateData::IsolateData(TaskRunner* task_runner, IsolateData::IsolateData(TaskRunner* task_runner,
IsolateData::SetupGlobalTasks setup_global_tasks, IsolateData::SetupGlobalTasks setup_global_tasks,
v8::StartupData* startup_data, bool with_inspector) v8::StartupData* startup_data,
WithInspector with_inspector)
: task_runner_(task_runner), : task_runner_(task_runner),
setup_global_tasks_(std::move(setup_global_tasks)) { setup_global_tasks_(std::move(setup_global_tasks)) {
v8::Isolate::CreateParams params; v8::Isolate::CreateParams params;
......
...@@ -20,6 +20,8 @@ namespace internal { ...@@ -20,6 +20,8 @@ namespace internal {
class TaskRunner; class TaskRunner;
enum WithInspector : bool { kWithInspector = true, kNoInspector = false };
class IsolateData : public v8_inspector::V8InspectorClient { class IsolateData : public v8_inspector::V8InspectorClient {
public: public:
class SetupGlobalTask { class SetupGlobalTask {
...@@ -31,7 +33,7 @@ class IsolateData : public v8_inspector::V8InspectorClient { ...@@ -31,7 +33,7 @@ class IsolateData : public v8_inspector::V8InspectorClient {
using SetupGlobalTasks = std::vector<std::unique_ptr<SetupGlobalTask>>; using SetupGlobalTasks = std::vector<std::unique_ptr<SetupGlobalTask>>;
IsolateData(TaskRunner* task_runner, SetupGlobalTasks setup_global_tasks, 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); static IsolateData* FromContext(v8::Local<v8::Context> context);
v8::Isolate* isolate() const { return isolate_.get(); } v8::Isolate* isolate() const { return isolate_.get(); }
......
...@@ -36,9 +36,10 @@ void ReportUncaughtException(v8::Isolate* isolate, ...@@ -36,9 +36,10 @@ void ReportUncaughtException(v8::Isolate* isolate,
} // namespace } // namespace
TaskRunner::TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks, TaskRunner::TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks,
bool catch_exceptions, CatchExceptions catch_exceptions,
v8::base::Semaphore* ready_semaphore, v8::base::Semaphore* ready_semaphore,
v8::StartupData* startup_data, bool with_inspector) v8::StartupData* startup_data,
WithInspector with_inspector)
: Thread(Options("Task Runner")), : Thread(Options("Task Runner")),
setup_global_tasks_(std::move(setup_global_tasks)), setup_global_tasks_(std::move(setup_global_tasks)),
startup_data_(startup_data), startup_data_(startup_data),
......
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
enum CatchExceptions : bool {
kDoCatchExceptions = true,
kDontCatchExceptions = false
};
class TaskRunner : public v8::base::Thread { class TaskRunner : public v8::base::Thread {
public: public:
class Task { class Task {
...@@ -30,8 +35,9 @@ class TaskRunner : public v8::base::Thread { ...@@ -30,8 +35,9 @@ class TaskRunner : public v8::base::Thread {
}; };
TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks, TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks,
bool catch_exceptions, v8::base::Semaphore* ready_semaphore, CatchExceptions catch_exceptions,
v8::StartupData* startup_data, bool with_inspector); v8::base::Semaphore* ready_semaphore,
v8::StartupData* startup_data, WithInspector with_inspector);
~TaskRunner() override; ~TaskRunner() override;
IsolateData* data() const { return data_.get(); } IsolateData* data() const { return data_.get(); }
...@@ -52,8 +58,8 @@ class TaskRunner : public v8::base::Thread { ...@@ -52,8 +58,8 @@ class TaskRunner : public v8::base::Thread {
IsolateData::SetupGlobalTasks setup_global_tasks_; IsolateData::SetupGlobalTasks setup_global_tasks_;
v8::StartupData* startup_data_; v8::StartupData* startup_data_;
bool with_inspector_; WithInspector with_inspector_;
bool catch_exceptions_; CatchExceptions catch_exceptions_;
v8::base::Semaphore* ready_semaphore_; v8::base::Semaphore* ready_semaphore_;
std::unique_ptr<IsolateData> data_; 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