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

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

Issue 2626283002: [inspector] introduced debug::SetCompileEventListener (Closed)
Patch Set: rebased 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
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // There are three types of event listeners: C++ message_handler,
1875 // JavaScript event listener and C++ event listener. 1882 // JavaScript event listener and C++ event listener.
1876 // Currently inspector still uses C++ event listener and installs 1883 // Currently inspector still uses C++ event listener and installs
1877 // more specific event listeners for part of events. Calling of 1884 // more specific event listeners for part of events. Calling of
1878 // C++ event listener is redundant when more specific event listener 1885 // C++ event listener is redundant when more specific event listener
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1960 in_debug_event_listener_ = previous; 1967 in_debug_event_listener_ = previous;
1961 } 1968 }
1962 1969
1963 1970
1964 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) { 1971 void Debug::ProcessCompileEvent(v8::DebugEvent event, Handle<Script> script) {
1965 if (ignore_events()) return; 1972 if (ignore_events()) return;
1966 if (script->type() != i::Script::TYPE_NORMAL && 1973 if (script->type() != i::Script::TYPE_NORMAL &&
1967 script->type() != i::Script::TYPE_WASM) { 1974 script->type() != i::Script::TYPE_WASM) {
1968 return; 1975 return;
1969 } 1976 }
1977 if (compile_event_listener_) {
1978 compile_event_listener_(ToApiHandle<debug::Script>(script),
1979 event != v8::AfterCompile,
1980 compile_event_listener_data_);
1981 bool non_inspector_listener_exists =
1982 message_handler_ != nullptr ||
jgruber 2017/01/16 19:26:32 Nit: Maybe it'd make sense to extract this to a me
kozy 2017/01/16 22:22:39 Done.
1983 (event_listener_.is_null() && !event_listener_->IsForeign());
1984 if (!non_inspector_listener_exists) return;
1985 }
1986
1970 SuppressDebug while_processing(this); 1987 SuppressDebug while_processing(this);
1971 1988
1972 bool in_nested_debug_scope = in_debug_scope(); 1989 bool in_nested_debug_scope = in_debug_scope();
1973 HandleScope scope(isolate_); 1990 HandleScope scope(isolate_);
1974 DebugScope debug_scope(this); 1991 DebugScope debug_scope(this);
1975 if (debug_scope.failed()) return; 1992 if (debug_scope.failed()) return;
1976 1993
1977 // Create the compile state object. 1994 // Create the compile state object.
1978 Handle<Object> event_data; 1995 Handle<Object> event_data;
1979 // Bail out and don't call debugger if exception. 1996 // Bail out and don't call debugger if exception.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 UpdateState(); 2177 UpdateState();
2161 if (handler == NULL && in_debug_scope()) { 2178 if (handler == NULL && in_debug_scope()) {
2162 // Send an empty command to the debugger if in a break to make JavaScript 2179 // Send an empty command to the debugger if in a break to make JavaScript
2163 // run again if the debugger is closed. 2180 // run again if the debugger is closed.
2164 EnqueueCommandMessage(Vector<const uint16_t>::empty()); 2181 EnqueueCommandMessage(Vector<const uint16_t>::empty());
2165 } 2182 }
2166 } 2183 }
2167 2184
2168 void Debug::UpdateState() { 2185 void Debug::UpdateState() {
2169 bool is_active = message_handler_ != nullptr || !event_listener_.is_null() || 2186 bool is_active = message_handler_ != nullptr || !event_listener_.is_null() ||
2170 async_task_listener_ != nullptr; 2187 async_task_listener_ != nullptr ||
2188 compile_event_listener_ != nullptr;
2171 if (is_active || in_debug_scope()) { 2189 if (is_active || in_debug_scope()) {
2172 // Note that the debug context could have already been loaded to 2190 // Note that the debug context could have already been loaded to
2173 // bootstrap test cases. 2191 // bootstrap test cases.
2174 isolate_->compilation_cache()->Disable(); 2192 isolate_->compilation_cache()->Disable();
2175 is_active = Load(); 2193 is_active = Load();
2176 } else if (is_loaded()) { 2194 } else if (is_loaded()) {
2177 isolate_->compilation_cache()->Enable(); 2195 isolate_->compilation_cache()->Enable();
2178 Unload(); 2196 Unload();
2179 } 2197 }
2180 is_active_ = is_active; 2198 is_active_ = is_active;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 logger_->DebugEvent("Put", message.text()); 2666 logger_->DebugEvent("Put", message.text());
2649 } 2667 }
2650 2668
2651 void LockingCommandMessageQueue::Clear() { 2669 void LockingCommandMessageQueue::Clear() {
2652 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2670 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2653 queue_.Clear(); 2671 queue_.Clear();
2654 } 2672 }
2655 2673
2656 } // namespace internal 2674 } // namespace internal
2657 } // namespace v8 2675 } // namespace v8
OLDNEW
« no previous file with comments | « 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