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

Side by Side Diff: src/debug/debug.cc

Issue 2415023002: [promises] Move async debug event creation to c++ (Closed)
Patch Set: use consts Created 4 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 1651
1652 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script, 1652 MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
1653 v8::DebugEvent type) { 1653 v8::DebugEvent type) {
1654 // Create the compile event object. 1654 // Create the compile event object.
1655 Handle<Object> script_wrapper = Script::GetWrapper(script); 1655 Handle<Object> script_wrapper = Script::GetWrapper(script);
1656 Handle<Object> argv[] = { script_wrapper, 1656 Handle<Object> argv[] = { script_wrapper,
1657 isolate_->factory()->NewNumberFromInt(type) }; 1657 isolate_->factory()->NewNumberFromInt(type) };
1658 return CallFunction("MakeCompileEvent", arraysize(argv), argv); 1658 return CallFunction("MakeCompileEvent", arraysize(argv), argv);
1659 } 1659 }
1660 1660
1661 1661 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<Object> type,
1662 MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) { 1662 Handle<Object> id,
1663 Handle<Object> name) {
1663 // Create the async task event object. 1664 // Create the async task event object.
1664 Handle<Object> argv[] = { task_event }; 1665 Handle<Object> argv[] = {type, id, name};
1665 return CallFunction("MakeAsyncTaskEvent", arraysize(argv), argv); 1666 return CallFunction("MakeAsyncTaskEvent", arraysize(argv), argv);
1666 } 1667 }
1667 1668
1668 1669
1669 void Debug::OnThrow(Handle<Object> exception) { 1670 void Debug::OnThrow(Handle<Object> exception) {
1670 if (in_debug_scope() || ignore_events()) return; 1671 if (in_debug_scope() || ignore_events()) return;
1671 PrepareStepOnThrow(); 1672 PrepareStepOnThrow();
1672 // Temporarily clear any scheduled_exception to allow evaluating 1673 // Temporarily clear any scheduled_exception to allow evaluating
1673 // JavaScript from the debug event handler. 1674 // JavaScript from the debug event handler.
1674 HandleScope scope(isolate_); 1675 HandleScope scope(isolate_);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 void Debug::OnBeforeCompile(Handle<Script> script) { 1775 void Debug::OnBeforeCompile(Handle<Script> script) {
1775 ProcessCompileEvent(v8::BeforeCompile, script); 1776 ProcessCompileEvent(v8::BeforeCompile, script);
1776 } 1777 }
1777 1778
1778 1779
1779 // Handle debugger actions when a new script is compiled. 1780 // Handle debugger actions when a new script is compiled.
1780 void Debug::OnAfterCompile(Handle<Script> script) { 1781 void Debug::OnAfterCompile(Handle<Script> script) {
1781 ProcessCompileEvent(v8::AfterCompile, script); 1782 ProcessCompileEvent(v8::AfterCompile, script);
1782 } 1783 }
1783 1784
1784 1785 void Debug::OnAsyncTaskEvent(Handle<Object> type, Handle<Object> id,
1785 void Debug::OnAsyncTaskEvent(Handle<JSObject> data) { 1786 Handle<Object> name) {
adamk 2016/10/13 15:59:10 And then you can add a DCHECK(id->IsNumber()) here
gsathya 2016/10/13 21:27:30 Done.
1786 if (in_debug_scope() || ignore_events()) return; 1787 if (in_debug_scope() || ignore_events()) return;
1787 1788
1788 HandleScope scope(isolate_); 1789 HandleScope scope(isolate_);
1789 DebugScope debug_scope(this); 1790 DebugScope debug_scope(this);
1790 if (debug_scope.failed()) return; 1791 if (debug_scope.failed()) return;
1791 1792
1792 // Create the script collected state object. 1793 // Create the script collected state object.
1793 Handle<Object> event_data; 1794 Handle<Object> event_data;
1794 // Bail out and don't call debugger if exception. 1795 // Bail out and don't call debugger if exception.
1795 if (!MakeAsyncTaskEvent(data).ToHandle(&event_data)) return; 1796 if (!MakeAsyncTaskEvent(type, id, name).ToHandle(&event_data)) return;
1796 1797
1797 // Process debug event. 1798 // Process debug event.
1798 ProcessDebugEvent(v8::AsyncTaskEvent, 1799 ProcessDebugEvent(v8::AsyncTaskEvent,
1799 Handle<JSObject>::cast(event_data), 1800 Handle<JSObject>::cast(event_data),
1800 true); 1801 true);
1801 } 1802 }
1802 1803
1803 1804
1804 void Debug::ProcessDebugEvent(v8::DebugEvent event, 1805 void Debug::ProcessDebugEvent(v8::DebugEvent event,
1805 Handle<JSObject> event_data, 1806 Handle<JSObject> event_data,
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 } 2559 }
2559 2560
2560 2561
2561 void LockingCommandMessageQueue::Clear() { 2562 void LockingCommandMessageQueue::Clear() {
2562 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2563 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2563 queue_.Clear(); 2564 queue_.Clear();
2564 } 2565 }
2565 2566
2566 } // namespace internal 2567 } // namespace internal
2567 } // namespace v8 2568 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698