OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 class MessageDispatchHelperThread; | 755 class MessageDispatchHelperThread; |
756 | 756 |
757 | 757 |
758 // LockingCommandMessageQueue is a thread-safe circular buffer of CommandMessage | 758 // LockingCommandMessageQueue is a thread-safe circular buffer of CommandMessage |
759 // messages. The message data is not managed by LockingCommandMessageQueue. | 759 // messages. The message data is not managed by LockingCommandMessageQueue. |
760 // Pointers to the data are passed in and out. Implemented by adding a | 760 // Pointers to the data are passed in and out. Implemented by adding a |
761 // Mutex to CommandMessageQueue. Includes logging of all puts and gets. | 761 // Mutex to CommandMessageQueue. Includes logging of all puts and gets. |
762 class LockingCommandMessageQueue BASE_EMBEDDED { | 762 class LockingCommandMessageQueue BASE_EMBEDDED { |
763 public: | 763 public: |
764 LockingCommandMessageQueue(Logger* logger, int size); | 764 LockingCommandMessageQueue(Logger* logger, int size); |
765 ~LockingCommandMessageQueue(); | |
766 bool IsEmpty() const; | 765 bool IsEmpty() const; |
767 CommandMessage Get(); | 766 CommandMessage Get(); |
768 void Put(const CommandMessage& message); | 767 void Put(const CommandMessage& message); |
769 void Clear(); | 768 void Clear(); |
770 private: | 769 private: |
771 Logger* logger_; | 770 Logger* logger_; |
772 CommandMessageQueue queue_; | 771 CommandMessageQueue queue_; |
773 Mutex* lock_; | 772 mutable Mutex mutex_; |
774 DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue); | 773 DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue); |
775 }; | 774 }; |
776 | 775 |
777 | 776 |
778 class Debugger { | 777 class Debugger { |
779 public: | 778 public: |
780 ~Debugger(); | 779 ~Debugger(); |
781 | 780 |
782 void DebugRequest(const uint16_t* json_request, int length); | 781 void DebugRequest(const uint16_t* json_request, int length); |
783 | 782 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 void CallMessageDispatchHandler(); | 855 void CallMessageDispatchHandler(); |
857 | 856 |
858 Handle<Context> GetDebugContext(); | 857 Handle<Context> GetDebugContext(); |
859 | 858 |
860 // Unload the debugger if possible. Only called when no debugger is currently | 859 // Unload the debugger if possible. Only called when no debugger is currently |
861 // active. | 860 // active. |
862 void UnloadDebugger(); | 861 void UnloadDebugger(); |
863 friend void ForceUnloadDebugger(); // In test-debug.cc | 862 friend void ForceUnloadDebugger(); // In test-debug.cc |
864 | 863 |
865 inline bool EventActive(v8::DebugEvent event) { | 864 inline bool EventActive(v8::DebugEvent event) { |
866 ScopedLock with(debugger_access_); | 865 LockGuard<RecursiveMutex> lock_guard(debugger_access_); |
867 | 866 |
868 // Check whether the message handler was been cleared. | 867 // Check whether the message handler was been cleared. |
869 if (debugger_unload_pending_) { | 868 if (debugger_unload_pending_) { |
870 if (isolate_->debug()->debugger_entry() == NULL) { | 869 if (isolate_->debug()->debugger_entry() == NULL) { |
871 UnloadDebugger(); | 870 UnloadDebugger(); |
872 } | 871 } |
873 } | 872 } |
874 | 873 |
875 if (((event == v8::BeforeCompile) || (event == v8::AfterCompile)) && | 874 if (((event == v8::BeforeCompile) || (event == v8::AfterCompile)) && |
876 !FLAG_debug_compile_events) { | 875 !FLAG_debug_compile_events) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 v8::Debug::ClientData* client_data); | 910 v8::Debug::ClientData* client_data); |
912 void CallCEventCallback(v8::DebugEvent event, | 911 void CallCEventCallback(v8::DebugEvent event, |
913 Handle<Object> exec_state, | 912 Handle<Object> exec_state, |
914 Handle<Object> event_data, | 913 Handle<Object> event_data, |
915 v8::Debug::ClientData* client_data); | 914 v8::Debug::ClientData* client_data); |
916 void CallJSEventCallback(v8::DebugEvent event, | 915 void CallJSEventCallback(v8::DebugEvent event, |
917 Handle<Object> exec_state, | 916 Handle<Object> exec_state, |
918 Handle<Object> event_data); | 917 Handle<Object> event_data); |
919 void ListenersChanged(); | 918 void ListenersChanged(); |
920 | 919 |
921 Mutex* debugger_access_; // Mutex guarding debugger variables. | 920 RecursiveMutex* debugger_access_; // Mutex guarding debugger variables. |
922 Handle<Object> event_listener_; // Global handle to listener. | 921 Handle<Object> event_listener_; // Global handle to listener. |
923 Handle<Object> event_listener_data_; | 922 Handle<Object> event_listener_data_; |
924 bool compiling_natives_; // Are we compiling natives? | 923 bool compiling_natives_; // Are we compiling natives? |
925 bool is_loading_debugger_; // Are we loading the debugger? | 924 bool is_loading_debugger_; // Are we loading the debugger? |
926 bool live_edit_enabled_; // Enable LiveEdit. | 925 bool live_edit_enabled_; // Enable LiveEdit. |
927 bool never_unload_debugger_; // Can we unload the debugger? | 926 bool never_unload_debugger_; // Can we unload the debugger? |
928 bool force_debugger_active_; // Activate debugger without event listeners. | 927 bool force_debugger_active_; // Activate debugger without event listeners. |
929 v8::Debug::MessageHandler2 message_handler_; | 928 v8::Debug::MessageHandler2 message_handler_; |
930 bool debugger_unload_pending_; // Was message handler cleared? | 929 bool debugger_unload_pending_; // Was message handler cleared? |
931 v8::Debug::HostDispatchHandler host_dispatch_handler_; | 930 v8::Debug::HostDispatchHandler host_dispatch_handler_; |
932 Mutex* dispatch_handler_access_; // Mutex guarding dispatch handler. | 931 Mutex dispatch_handler_access_; // Mutex guarding dispatch handler. |
933 v8::Debug::DebugMessageDispatchHandler debug_message_dispatch_handler_; | 932 v8::Debug::DebugMessageDispatchHandler debug_message_dispatch_handler_; |
934 MessageDispatchHelperThread* message_dispatch_helper_thread_; | 933 MessageDispatchHelperThread* message_dispatch_helper_thread_; |
935 int host_dispatch_micros_; | 934 int host_dispatch_micros_; |
936 | 935 |
937 DebuggerAgent* agent_; | 936 DebuggerAgent* agent_; |
938 | 937 |
939 static const int kQueueInitialSize = 4; | 938 static const int kQueueInitialSize = 4; |
940 LockingCommandMessageQueue command_queue_; | 939 LockingCommandMessageQueue command_queue_; |
941 Semaphore* command_received_; // Signaled for each command received. | 940 Semaphore* command_received_; // Signaled for each command received. |
942 LockingCommandMessageQueue event_command_queue_; | 941 LockingCommandMessageQueue event_command_queue_; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 explicit MessageDispatchHelperThread(Isolate* isolate); | 1048 explicit MessageDispatchHelperThread(Isolate* isolate); |
1050 ~MessageDispatchHelperThread(); | 1049 ~MessageDispatchHelperThread(); |
1051 | 1050 |
1052 void Schedule(); | 1051 void Schedule(); |
1053 | 1052 |
1054 private: | 1053 private: |
1055 void Run(); | 1054 void Run(); |
1056 | 1055 |
1057 Isolate* isolate_; | 1056 Isolate* isolate_; |
1058 Semaphore* const sem_; | 1057 Semaphore* const sem_; |
1059 Mutex* const mutex_; | 1058 Mutex mutex_; |
1060 bool already_signalled_; | 1059 bool already_signalled_; |
1061 | 1060 |
1062 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); | 1061 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); |
1063 }; | 1062 }; |
1064 | 1063 |
1065 | 1064 |
1066 } } // namespace v8::internal | 1065 } } // namespace v8::internal |
1067 | 1066 |
1068 #endif // ENABLE_DEBUGGER_SUPPORT | 1067 #endif // ENABLE_DEBUGGER_SUPPORT |
1069 | 1068 |
1070 #endif // V8_DEBUG_H_ | 1069 #endif // V8_DEBUG_H_ |
OLD | NEW |