OLD | NEW |
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 #ifndef V8_DEBUG_H_ | 5 #ifndef V8_DEBUG_H_ |
6 #define V8_DEBUG_H_ | 6 #define V8_DEBUG_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 public: | 152 public: |
153 explicit ScriptCache(Isolate* isolate); | 153 explicit ScriptCache(Isolate* isolate); |
154 virtual ~ScriptCache() { Clear(); } | 154 virtual ~ScriptCache() { Clear(); } |
155 | 155 |
156 // Add script to the cache. | 156 // Add script to the cache. |
157 void Add(Handle<Script> script); | 157 void Add(Handle<Script> script); |
158 | 158 |
159 // Return the scripts in the cache. | 159 // Return the scripts in the cache. |
160 Handle<FixedArray> GetScripts(); | 160 Handle<FixedArray> GetScripts(); |
161 | 161 |
162 // Generate debugger events for collected scripts. | |
163 void ProcessCollectedScripts(); | |
164 | |
165 private: | 162 private: |
166 // Calculate the hash value from the key (script id). | 163 // Calculate the hash value from the key (script id). |
167 static uint32_t Hash(int key) { | 164 static uint32_t Hash(int key) { |
168 return ComputeIntegerHash(key, v8::internal::kZeroHashSeed); | 165 return ComputeIntegerHash(key, v8::internal::kZeroHashSeed); |
169 } | 166 } |
170 | 167 |
171 // Clear the cache releasing all the weak handles. | 168 // Clear the cache releasing all the weak handles. |
172 void Clear(); | 169 void Clear(); |
173 | 170 |
174 // Weak handle callback for scripts in the cache. | 171 // Weak handle callback for scripts in the cache. |
175 static void HandleWeakScript( | 172 static void HandleWeakScript( |
176 const v8::WeakCallbackData<v8::Value, void>& data); | 173 const v8::WeakCallbackData<v8::Value, void>& data); |
177 | 174 |
178 Isolate* isolate_; | 175 Isolate* isolate_; |
179 // List used during GC to temporarily store id's of collected scripts. | |
180 List<int> collected_scripts_; | |
181 }; | 176 }; |
182 | 177 |
183 | 178 |
184 // Linked list holding debug info objects. The debug info objects are kept as | 179 // Linked list holding debug info objects. The debug info objects are kept as |
185 // weak handles to avoid a debug info object to keep a function alive. | 180 // weak handles to avoid a debug info object to keep a function alive. |
186 class DebugInfoListNode { | 181 class DebugInfoListNode { |
187 public: | 182 public: |
188 explicit DebugInfoListNode(DebugInfo* debug_info); | 183 explicit DebugInfoListNode(DebugInfo* debug_info); |
189 virtual ~DebugInfoListNode(); | 184 virtual ~DebugInfoListNode(); |
190 | 185 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // debug_info which is a FixedArray. Each entry in this list is of class | 358 // debug_info which is a FixedArray. Each entry in this list is of class |
364 // DebugInfo. | 359 // DebugInfo. |
365 class Debug { | 360 class Debug { |
366 public: | 361 public: |
367 // Debug event triggers. | 362 // Debug event triggers. |
368 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); | 363 void OnDebugBreak(Handle<Object> break_points_hit, bool auto_continue); |
369 void OnException(Handle<Object> exception, bool uncaught); | 364 void OnException(Handle<Object> exception, bool uncaught); |
370 void OnCompileError(Handle<Script> script); | 365 void OnCompileError(Handle<Script> script); |
371 void OnBeforeCompile(Handle<Script> script); | 366 void OnBeforeCompile(Handle<Script> script); |
372 void OnAfterCompile(Handle<Script> script); | 367 void OnAfterCompile(Handle<Script> script); |
373 void OnScriptCollected(int id); | |
374 | 368 |
375 // API facing. | 369 // API facing. |
376 void SetEventListener(Handle<Object> callback, Handle<Object> data); | 370 void SetEventListener(Handle<Object> callback, Handle<Object> data); |
377 void SetMessageHandler(v8::Debug::MessageHandler handler); | 371 void SetMessageHandler(v8::Debug::MessageHandler handler); |
378 void EnqueueCommandMessage(Vector<const uint16_t> command, | 372 void EnqueueCommandMessage(Vector<const uint16_t> command, |
379 v8::Debug::ClientData* client_data = NULL); | 373 v8::Debug::ClientData* client_data = NULL); |
380 // Enqueue a debugger command to the command queue for event listeners. | 374 // Enqueue a debugger command to the command queue for event listeners. |
381 void EnqueueDebugCommand(v8::Debug::ClientData* client_data = NULL); | 375 void EnqueueDebugCommand(v8::Debug::ClientData* client_data = NULL); |
382 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<JSFunction> fun, | 376 MUST_USE_RESULT MaybeHandle<Object> Call(Handle<JSFunction> fun, |
383 Handle<Object> data); | 377 Handle<Object> data); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 464 |
471 // Threading support. | 465 // Threading support. |
472 char* ArchiveDebug(char* to); | 466 char* ArchiveDebug(char* to); |
473 char* RestoreDebug(char* from); | 467 char* RestoreDebug(char* from); |
474 static int ArchiveSpacePerThread(); | 468 static int ArchiveSpacePerThread(); |
475 void FreeThreadResources() { } | 469 void FreeThreadResources() { } |
476 | 470 |
477 // Record function from which eval was called. | 471 // Record function from which eval was called. |
478 static void RecordEvalCaller(Handle<Script> script); | 472 static void RecordEvalCaller(Handle<Script> script); |
479 | 473 |
480 // Garbage collection notifications. | |
481 void AfterGarbageCollection(); | |
482 | |
483 // Flags and states. | 474 // Flags and states. |
484 DebugScope* debugger_entry() { return thread_local_.current_debug_scope_; } | 475 DebugScope* debugger_entry() { return thread_local_.current_debug_scope_; } |
485 inline Handle<Context> debug_context() { return debug_context_; } | 476 inline Handle<Context> debug_context() { return debug_context_; } |
486 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; } | 477 void set_live_edit_enabled(bool v) { live_edit_enabled_ = v; } |
487 bool live_edit_enabled() const { | 478 bool live_edit_enabled() const { |
488 return FLAG_enable_liveedit && live_edit_enabled_ ; | 479 return FLAG_enable_liveedit && live_edit_enabled_ ; |
489 } | 480 } |
490 | 481 |
491 inline bool is_active() const { return is_active_; } | 482 inline bool is_active() const { return is_active_; } |
492 inline bool is_loaded() const { return !debug_context_.is_null(); } | 483 inline bool is_loaded() const { return !debug_context_.is_null(); } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 Handle<Object> argv[]); | 528 Handle<Object> argv[]); |
538 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); | 529 MUST_USE_RESULT MaybeHandle<Object> MakeExecutionState(); |
539 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( | 530 MUST_USE_RESULT MaybeHandle<Object> MakeBreakEvent( |
540 Handle<Object> break_points_hit); | 531 Handle<Object> break_points_hit); |
541 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( | 532 MUST_USE_RESULT MaybeHandle<Object> MakeExceptionEvent( |
542 Handle<Object> exception, | 533 Handle<Object> exception, |
543 bool uncaught, | 534 bool uncaught, |
544 Handle<Object> promise); | 535 Handle<Object> promise); |
545 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent( | 536 MUST_USE_RESULT MaybeHandle<Object> MakeCompileEvent( |
546 Handle<Script> script, v8::DebugEvent type); | 537 Handle<Script> script, v8::DebugEvent type); |
547 MUST_USE_RESULT MaybeHandle<Object> MakeScriptCollectedEvent(int id); | |
548 | 538 |
549 // Mirror cache handling. | 539 // Mirror cache handling. |
550 void ClearMirrorCache(); | 540 void ClearMirrorCache(); |
551 | 541 |
552 // Returns a promise if it does not have a reject handler. | 542 // Returns a promise if it does not have a reject handler. |
553 Handle<Object> GetPromiseForUncaughtException(); | 543 Handle<Object> GetPromiseForUncaughtException(); |
554 | 544 |
555 void CallEventCallback(v8::DebugEvent event, | 545 void CallEventCallback(v8::DebugEvent event, |
556 Handle<Object> exec_state, | 546 Handle<Object> exec_state, |
557 Handle<Object> event_data, | 547 Handle<Object> event_data, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 // several frames above. | 754 // several frames above. |
765 // There is no calling conventions here, because it never actually gets | 755 // There is no calling conventions here, because it never actually gets |
766 // called, it only gets returned to. | 756 // called, it only gets returned to. |
767 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | 757 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); |
768 }; | 758 }; |
769 | 759 |
770 | 760 |
771 } } // namespace v8::internal | 761 } } // namespace v8::internal |
772 | 762 |
773 #endif // V8_DEBUG_H_ | 763 #endif // V8_DEBUG_H_ |
OLD | NEW |