Index: test/inspector/task-runner.cc |
diff --git a/test/inspector/task-runner.cc b/test/inspector/task-runner.cc |
index 59cae6e15506354f3f67f91dac43b7a6aee03486..4035e1d0b9c98bf6f281f170f19f7a37d396d1e9 100644 |
--- a/test/inspector/task-runner.cc |
+++ b/test/inspector/task-runner.cc |
@@ -26,24 +26,16 @@ void ReportUncaughtException(v8::Isolate* isolate, |
source_line.data(), line); |
} |
-v8::internal::Vector<uint16_t> ToVector(v8::Local<v8::String> str) { |
- v8::internal::Vector<uint16_t> buffer = |
- v8::internal::Vector<uint16_t>::New(str->Length()); |
- str->Write(buffer.start(), 0, str->Length()); |
- return buffer; |
-} |
- |
} // namespace |
TaskRunner::TaskRunner(IsolateData::SetupGlobalTasks setup_global_tasks, |
bool catch_exceptions, |
v8::base::Semaphore* ready_semaphore, |
- v8::StartupData* startup_data, |
- IsolateData::FrontendChannel* channel) |
+ v8::StartupData* startup_data, bool with_inspector) |
: Thread(Options("Task Runner")), |
setup_global_tasks_(std::move(setup_global_tasks)), |
startup_data_(startup_data), |
- channel_(channel), |
+ with_inspector_(with_inspector), |
catch_exceptions_(catch_exceptions), |
ready_semaphore_(ready_semaphore), |
data_(nullptr), |
@@ -56,7 +48,7 @@ TaskRunner::~TaskRunner() { Join(); } |
void TaskRunner::Run() { |
data_.reset(new IsolateData(this, std::move(setup_global_tasks_), |
- startup_data_, channel_)); |
+ startup_data_, with_inspector_)); |
if (ready_semaphore_) ready_semaphore_->Signal(); |
RunMessageLoop(false); |
} |
@@ -69,7 +61,7 @@ void TaskRunner::RunMessageLoop(bool only_protocol) { |
v8::Isolate::Scope isolate_scope(isolate()); |
if (catch_exceptions_) { |
v8::TryCatch try_catch(isolate()); |
- task->RunOnIsolate(data_.get()); |
+ task->Run(data_.get()); |
delete task; |
if (try_catch.HasCaught()) { |
ReportUncaughtException(isolate(), try_catch); |
@@ -78,7 +70,7 @@ void TaskRunner::RunMessageLoop(bool only_protocol) { |
_exit(0); |
} |
} else { |
- task->RunOnIsolate(data_.get()); |
+ task->Run(data_.get()); |
delete task; |
} |
} |
@@ -105,7 +97,7 @@ TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) { |
if (only_protocol) { |
Task* task = nullptr; |
if (queue_.Dequeue(&task)) { |
- if (task->is_inspector_task()) return task; |
+ if (task->is_priority_task()) return task; |
deffered_queue_.Enqueue(task); |
} |
} else { |
@@ -117,86 +109,3 @@ TaskRunner::Task* TaskRunner::GetNext(bool only_protocol) { |
} |
return nullptr; |
} |
- |
-AsyncTask::AsyncTask(IsolateData* data, const char* task_name) |
- : instrumenting_(data && task_name) { |
- if (!instrumenting_) return; |
- data->inspector()->asyncTaskScheduled( |
- v8_inspector::StringView(reinterpret_cast<const uint8_t*>(task_name), |
- strlen(task_name)), |
- this, false); |
-} |
- |
-void AsyncTask::Run() { |
- if (instrumenting_) data()->inspector()->asyncTaskStarted(this); |
- AsyncRun(); |
- if (instrumenting_) data()->inspector()->asyncTaskFinished(this); |
-} |
- |
-ExecuteStringTask::ExecuteStringTask( |
- IsolateData* data, int context_group_id, const char* task_name, |
- const v8::internal::Vector<uint16_t>& expression, |
- v8::Local<v8::String> name, v8::Local<v8::Integer> line_offset, |
- v8::Local<v8::Integer> column_offset, v8::Local<v8::Boolean> is_module) |
- : AsyncTask(data, task_name), |
- expression_(expression), |
- name_(ToVector(name)), |
- line_offset_(line_offset.As<v8::Int32>()->Value()), |
- column_offset_(column_offset.As<v8::Int32>()->Value()), |
- is_module_(is_module->Value()), |
- context_group_id_(context_group_id) {} |
- |
-ExecuteStringTask::ExecuteStringTask( |
- const v8::internal::Vector<const char>& expression, int context_group_id) |
- : AsyncTask(nullptr, nullptr), |
- expression_utf8_(expression), |
- context_group_id_(context_group_id) {} |
- |
-void ExecuteStringTask::AsyncRun() { |
- v8::MicrotasksScope microtasks_scope(isolate(), |
- v8::MicrotasksScope::kRunMicrotasks); |
- v8::HandleScope handle_scope(isolate()); |
- v8::Local<v8::Context> context = data()->GetContext(context_group_id_); |
- v8::Context::Scope context_scope(context); |
- |
- v8::Local<v8::String> name = |
- v8::String::NewFromTwoByte(isolate(), name_.start(), |
- v8::NewStringType::kNormal, name_.length()) |
- .ToLocalChecked(); |
- v8::Local<v8::Integer> line_offset = |
- v8::Integer::New(isolate(), line_offset_); |
- v8::Local<v8::Integer> column_offset = |
- v8::Integer::New(isolate(), column_offset_); |
- |
- v8::ScriptOrigin origin( |
- name, line_offset, column_offset, |
- /* resource_is_shared_cross_origin */ v8::Local<v8::Boolean>(), |
- /* script_id */ v8::Local<v8::Integer>(), |
- /* source_map_url */ v8::Local<v8::Value>(), |
- /* resource_is_opaque */ v8::Local<v8::Boolean>(), |
- /* is_wasm */ v8::Local<v8::Boolean>(), |
- v8::Boolean::New(isolate(), is_module_)); |
- v8::Local<v8::String> source; |
- if (expression_.length()) { |
- source = v8::String::NewFromTwoByte(isolate(), expression_.start(), |
- v8::NewStringType::kNormal, |
- expression_.length()) |
- .ToLocalChecked(); |
- } else { |
- source = v8::String::NewFromUtf8(isolate(), expression_utf8_.start(), |
- v8::NewStringType::kNormal, |
- expression_utf8_.length()) |
- .ToLocalChecked(); |
- } |
- |
- v8::ScriptCompiler::Source scriptSource(source, origin); |
- if (!is_module_) { |
- v8::Local<v8::Script> script; |
- if (!v8::ScriptCompiler::Compile(context, &scriptSource).ToLocal(&script)) |
- return; |
- v8::MaybeLocal<v8::Value> result; |
- result = script->Run(context); |
- } else { |
- data()->RegisterModule(context, name_, &scriptSource); |
- } |
-} |