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

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

Issue 2626283002: [inspector] introduced debug::SetCompileEventListener (Closed)
Patch Set: extracted non_inspector_listener_exists Created 3 years, 11 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 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 return async_id->value(); 1859 return async_id->value();
1860 } 1860 }
1861 1861
1862 void Debug::SetAsyncTaskListener(debug::AsyncTaskListener listener, 1862 void Debug::SetAsyncTaskListener(debug::AsyncTaskListener listener,
1863 void* data) { 1863 void* data) {
1864 async_task_listener_ = listener; 1864 async_task_listener_ = listener;
1865 async_task_listener_data_ = data; 1865 async_task_listener_data_ = data;
1866 UpdateState(); 1866 UpdateState();
1867 } 1867 }
1868 1868
1869 void Debug::SetCompileEventListener(debug::CompileEventListener listener,
1870 void* data) {
1871 compile_event_listener_ = listener;
1872 compile_event_listener_data_ = data;
1873 UpdateState();
1874 }
1875
1869 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) { 1876 void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) {
1870 if (in_debug_scope() || ignore_events()) return; 1877 if (in_debug_scope() || ignore_events()) return;
1871 1878
1872 if (async_task_listener_) { 1879 if (async_task_listener_) {
1873 async_task_listener_(type, id, async_task_listener_data_); 1880 async_task_listener_(type, id, async_task_listener_data_);
1874 // There are three types of event listeners: C++ message_handler, 1881 if (!non_inspector_listener_exists()) return;
1875 // JavaScript event listener and C++ event listener.
1876 // Currently inspector still uses C++ event listener and installs
1877 // more specific event listeners for part of events. Calling of
1878 // C++ event listener is redundant when more specific event listener
1879 // is presented. Other clients can install JavaScript event listener
1880 // (e.g. some of NodeJS module).
1881 bool non_inspector_listener_exists =
1882 message_handler_ != nullptr ||
1883 (event_listener_.is_null() && !event_listener_->IsForeign());
1884 if (!non_inspector_listener_exists) return;
1885 } 1882 }
1886 1883
1887 HandleScope scope(isolate_); 1884 HandleScope scope(isolate_);
1888 DebugScope debug_scope(this); 1885 DebugScope debug_scope(this);
1889 if (debug_scope.failed()) return; 1886 if (debug_scope.failed()) return;
1890 1887
1891 // Create the script collected state object. 1888 // Create the script collected state object.
1892 Handle<Object> event_data; 1889 Handle<Object> event_data;
1893 // Bail out and don't call debugger if exception. 1890 // Bail out and don't call debugger if exception.
1894 if (!MakeAsyncTaskEvent(handle(Smi::FromInt(type), isolate_), 1891 if (!MakeAsyncTaskEvent(handle(Smi::FromInt(type), isolate_),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 in_debug_event_listener_ = previous; 1957 in_debug_event_listener_ = previous;
1961 } 1958 }
1962 1959
1963 1960
1964 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { 1961 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
1965 if (ignore_events()) return; 1962 if (ignore_events()) return;
1966 if (script->type() != i::Script::TYPE_NORMAL && 1963 if (script->type() != i::Script::TYPE_NORMAL &&
1967 script->type() != i::Script::TYPE_WASM) { 1964 script->type() != i::Script::TYPE_WASM) {
1968 return; 1965 return;
1969 } 1966 }
1967 if (compile_event_listener_) {
1968 compile_event_listener_(ToApiHandle<debug::Script>(script),
1969 event != v8::AfterCompile,
1970 compile_event_listener_data_);
1971 if (!non_inspector_listener_exists()) return;
1972 }
1973
1970 SuppressDebug while_processing(this); 1974 SuppressDebug while_processing(this);
1971 1975
1972 bool in_nested_debug_scope = in_debug_scope(); 1976 bool in_nested_debug_scope = in_debug_scope();
1973 HandleScope scope(isolate_); 1977 HandleScope scope(isolate_);
1974 DebugScope debug_scope(this); 1978 DebugScope debug_scope(this);
1975 if (debug_scope.failed()) return; 1979 if (debug_scope.failed()) return;
1976 1980
1977 // Create the compile state object. 1981 // Create the compile state object.
1978 Handle<Object> event_data; 1982 Handle<Object> event_data;
1979 // Bail out and don't call debugger if exception. 1983 // Bail out and don't call debugger if exception.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 UpdateState(); 2164 UpdateState();
2161 if (handler == NULL && in_debug_scope()) { 2165 if (handler == NULL && in_debug_scope()) {
2162 // Send an empty command to the debugger if in a break to make JavaScript 2166 // Send an empty command to the debugger if in a break to make JavaScript
2163 // run again if the debugger is closed. 2167 // run again if the debugger is closed.
2164 EnqueueCommandMessage(Vector<const uint16_t>::empty()); 2168 EnqueueCommandMessage(Vector<const uint16_t>::empty());
2165 } 2169 }
2166 } 2170 }
2167 2171
2168 void Debug::UpdateState() { 2172 void Debug::UpdateState() {
2169 bool is_active = message_handler_ != nullptr || !event_listener_.is_null() || 2173 bool is_active = message_handler_ != nullptr || !event_listener_.is_null() ||
2170 async_task_listener_ != nullptr; 2174 async_task_listener_ != nullptr ||
2175 compile_event_listener_ != nullptr;
2171 if (is_active || in_debug_scope()) { 2176 if (is_active || in_debug_scope()) {
2172 // Note that the debug context could have already been loaded to 2177 // Note that the debug context could have already been loaded to
2173 // bootstrap test cases. 2178 // bootstrap test cases.
2174 isolate_->compilation_cache()->Disable(); 2179 isolate_->compilation_cache()->Disable();
2175 is_active = Load(); 2180 is_active = Load();
2176 } else if (is_loaded()) { 2181 } else if (is_loaded()) {
2177 isolate_->compilation_cache()->Enable(); 2182 isolate_->compilation_cache()->Enable();
2178 Unload(); 2183 Unload();
2179 } 2184 }
2180 is_active_ = is_active; 2185 is_active_ = is_active;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 logger_->DebugEvent("Put", message.text()); 2653 logger_->DebugEvent("Put", message.text());
2649 } 2654 }
2650 2655
2651 void LockingCommandMessageQueue::Clear() { 2656 void LockingCommandMessageQueue::Clear() {
2652 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2657 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2653 queue_.Clear(); 2658 queue_.Clear();
2654 } 2659 }
2655 2660
2656 } // namespace internal 2661 } // namespace internal
2657 } // namespace v8 2662 } // namespace v8
OLDNEW
« src/debug/debug.h ('K') | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698