Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: src/debug.cc

Issue 812583003: Support tasks injection into a running VM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressing comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index a7321b2b157f074a02e8a8dd5bf7e78148803cbc..fc9a80aefb4778e16f4e5575069ba420c0203609 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -3103,6 +3103,27 @@ void Debug::EnqueueDebugCommand(v8::Debug::ClientData* client_data) {
}
+void Debug::EnqueueEmbedderTask(v8::Task* task) {
+ embedder_task_queue_.Enqueue(task);
+
+ // Set the debug command break flag to have the command processed.
+ if (!in_debug_scope()) {
+ isolate_->stack_guard()->RequestDebugCommand();
+ }
+}
+
+
+bool Debug::ProcessEmbedderTasks() {
+ bool did_process_task = false;
+ while (v8::Task* task = embedder_task_queue_.Dequeue()) {
+ did_process_task = true;
+ task->Run();
+ delete task;
+ }
+ return did_process_task;
+}
+
+
MaybeHandle<Object> Debug::Call(Handle<JSFunction> fun, Handle<Object> data) {
DebugScope debug_scope(this);
if (debug_scope.failed()) return isolate_->factory()->undefined_value();
@@ -3128,6 +3149,9 @@ void Debug::HandleDebugBreak() {
if (isolate_->bootstrapper()->IsActive()) return;
// Just continue if breaks are disabled.
if (break_disabled()) return;
+ if (ProcessEmbedderTasks()) {
+ isolate_->stack_guard()->ClearDebugCommand();
+ }
// Ignore debug break if debugger is not active.
if (!is_active()) return;
@@ -3480,4 +3504,33 @@ void LockingCommandMessageQueue::Clear() {
queue_.Clear();
}
+
+LockingTaskQueue::LockingTaskQueue() {}
+
+
+LockingTaskQueue::~LockingTaskQueue() { Clear(); }
+
+
+void LockingTaskQueue::Enqueue(v8::Task* task) {
+ base::LockGuard<base::Mutex> lock_guard(&mutex_);
+ queue_.push(task);
+}
+
+
+v8::Task* LockingTaskQueue::Dequeue() {
+ base::LockGuard<base::Mutex> lock_guard(&mutex_);
+ if (queue_.empty()) return NULL;
+ v8::Task* task = queue_.front();
+ queue_.pop();
+ return task;
+}
+
+
+void LockingTaskQueue::Clear() {
+ base::LockGuard<base::Mutex> lock_guard(&mutex_);
+ while (!queue_.empty()) {
+ delete queue_.front();
+ queue_.pop();
+ }
+}
} } // namespace v8::internal
« no previous file with comments | « src/debug.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698