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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 DISALLOW_COPY_AND_ASSIGN(BreakLocationIterator); | 167 DISALLOW_COPY_AND_ASSIGN(BreakLocationIterator); |
168 }; | 168 }; |
169 | 169 |
170 | 170 |
171 // Cache of all script objects in the heap. When a script is added a weak handle | 171 // Cache of all script objects in the heap. When a script is added a weak handle |
172 // to it is created and that weak handle is stored in the cache. The weak handle | 172 // to it is created and that weak handle is stored in the cache. The weak handle |
173 // callback takes care of removing the script from the cache. The key used in | 173 // callback takes care of removing the script from the cache. The key used in |
174 // the cache is the script id. | 174 // the cache is the script id. |
175 class ScriptCache : private HashMap { | 175 class ScriptCache : private HashMap { |
176 public: | 176 public: |
177 ScriptCache() : HashMap(ScriptMatch), collected_scripts_(10) {} | 177 explicit ScriptCache(Isolate* isolate) |
| 178 : HashMap(ScriptMatch), isolate_(isolate), collected_scripts_(10) {} |
178 virtual ~ScriptCache() { Clear(); } | 179 virtual ~ScriptCache() { Clear(); } |
179 | 180 |
180 // Add script to the cache. | 181 // Add script to the cache. |
181 void Add(Handle<Script> script); | 182 void Add(Handle<Script> script); |
182 | 183 |
183 // Return the scripts in the cache. | 184 // Return the scripts in the cache. |
184 Handle<FixedArray> GetScripts(); | 185 Handle<FixedArray> GetScripts(); |
185 | 186 |
186 // Generate debugger events for collected scripts. | 187 // Generate debugger events for collected scripts. |
187 void ProcessCollectedScripts(); | 188 void ProcessCollectedScripts(); |
188 | 189 |
189 private: | 190 private: |
190 // Calculate the hash value from the key (script id). | 191 // Calculate the hash value from the key (script id). |
191 static uint32_t Hash(int key) { | 192 static uint32_t Hash(int key) { |
192 return ComputeIntegerHash(key, v8::internal::kZeroHashSeed); | 193 return ComputeIntegerHash(key, v8::internal::kZeroHashSeed); |
193 } | 194 } |
194 | 195 |
195 // Scripts match if their keys (script id) match. | 196 // Scripts match if their keys (script id) match. |
196 static bool ScriptMatch(void* key1, void* key2) { return key1 == key2; } | 197 static bool ScriptMatch(void* key1, void* key2) { return key1 == key2; } |
197 | 198 |
198 // Clear the cache releasing all the weak handles. | 199 // Clear the cache releasing all the weak handles. |
199 void Clear(); | 200 void Clear(); |
200 | 201 |
201 // Weak handle callback for scripts in the cache. | 202 // Weak handle callback for scripts in the cache. |
202 static void HandleWeakScript(v8::Isolate* isolate, | 203 static void HandleWeakScript(v8::Isolate* isolate, |
203 v8::Persistent<v8::Value>* obj, | 204 v8::Persistent<v8::Value>* obj, |
204 void* data); | 205 void* data); |
205 | 206 |
| 207 Isolate* isolate_; |
206 // List used during GC to temporarily store id's of collected scripts. | 208 // List used during GC to temporarily store id's of collected scripts. |
207 List<int> collected_scripts_; | 209 List<int> collected_scripts_; |
208 }; | 210 }; |
209 | 211 |
210 | 212 |
211 // Linked list holding debug info objects. The debug info objects are kept as | 213 // Linked list holding debug info objects. The debug info objects are kept as |
212 // weak handles to avoid a debug info object to keep a function alive. | 214 // weak handles to avoid a debug info object to keep a function alive. |
213 class DebugInfoListNode { | 215 class DebugInfoListNode { |
214 public: | 216 public: |
215 explicit DebugInfoListNode(DebugInfo* debug_info); | 217 explicit DebugInfoListNode(DebugInfo* debug_info); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 static const int kInitialSize; | 527 static const int kInitialSize; |
526 // A value that padding words are filled with (in form of Smi). Going | 528 // A value that padding words are filled with (in form of Smi). Going |
527 // bottom-top, the first word not having this value is a counter word. | 529 // bottom-top, the first word not having this value is a counter word. |
528 static const int kPaddingValue; | 530 static const int kPaddingValue; |
529 }; | 531 }; |
530 | 532 |
531 private: | 533 private: |
532 explicit Debug(Isolate* isolate); | 534 explicit Debug(Isolate* isolate); |
533 ~Debug(); | 535 ~Debug(); |
534 | 536 |
535 static bool CompileDebuggerScript(int index); | 537 static bool CompileDebuggerScript(Isolate* isolate, int index); |
536 void ClearOneShot(); | 538 void ClearOneShot(); |
537 void ActivateStepIn(StackFrame* frame); | 539 void ActivateStepIn(StackFrame* frame); |
538 void ClearStepIn(); | 540 void ClearStepIn(); |
539 void ActivateStepOut(StackFrame* frame); | 541 void ActivateStepOut(StackFrame* frame); |
540 void ClearStepNext(); | 542 void ClearStepNext(); |
541 // Returns whether the compile succeeded. | 543 // Returns whether the compile succeeded. |
542 void RemoveDebugInfo(Handle<DebugInfo> debug_info); | 544 void RemoveDebugInfo(Handle<DebugInfo> debug_info); |
543 void SetAfterBreakTarget(JavaScriptFrame* frame); | 545 void SetAfterBreakTarget(JavaScriptFrame* frame); |
544 Handle<Object> CheckBreakPoints(Handle<Object> break_point); | 546 Handle<Object> CheckBreakPoints(Handle<Object> break_point); |
545 bool CheckBreakPoint(Handle<Object> break_point_object); | 547 bool CheckBreakPoint(Handle<Object> break_point_object); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 DISALLOW_COPY_AND_ASSIGN(Debugger); | 950 DISALLOW_COPY_AND_ASSIGN(Debugger); |
949 }; | 951 }; |
950 | 952 |
951 | 953 |
952 // This class is used for entering the debugger. Create an instance in the stack | 954 // This class is used for entering the debugger. Create an instance in the stack |
953 // to enter the debugger. This will set the current break state, make sure the | 955 // to enter the debugger. This will set the current break state, make sure the |
954 // debugger is loaded and switch to the debugger context. If the debugger for | 956 // debugger is loaded and switch to the debugger context. If the debugger for |
955 // some reason could not be entered FailedToEnter will return true. | 957 // some reason could not be entered FailedToEnter will return true. |
956 class EnterDebugger BASE_EMBEDDED { | 958 class EnterDebugger BASE_EMBEDDED { |
957 public: | 959 public: |
958 EnterDebugger(); | 960 explicit EnterDebugger(Isolate* isolate); |
959 ~EnterDebugger(); | 961 ~EnterDebugger(); |
960 | 962 |
961 // Check whether the debugger could be entered. | 963 // Check whether the debugger could be entered. |
962 inline bool FailedToEnter() { return load_failed_; } | 964 inline bool FailedToEnter() { return load_failed_; } |
963 | 965 |
964 // Check whether there are any JavaScript frames on the stack. | 966 // Check whether there are any JavaScript frames on the stack. |
965 inline bool HasJavaScriptFrames() { return has_js_frames_; } | 967 inline bool HasJavaScriptFrames() { return has_js_frames_; } |
966 | 968 |
967 // Get the active context from before entering the debugger. | 969 // Get the active context from before entering the debugger. |
968 inline Handle<Context> GetContext() { return save_.context(); } | 970 inline Handle<Context> GetContext() { return save_.context(); } |
969 | 971 |
970 private: | 972 private: |
971 Isolate* isolate_; | 973 Isolate* isolate_; |
972 EnterDebugger* prev_; // Previous debugger entry if entered recursively. | 974 EnterDebugger* prev_; // Previous debugger entry if entered recursively. |
973 JavaScriptFrameIterator it_; | 975 JavaScriptFrameIterator it_; |
974 const bool has_js_frames_; // Were there any JavaScript frames? | 976 const bool has_js_frames_; // Were there any JavaScript frames? |
975 StackFrame::Id break_frame_id_; // Previous break frame id. | 977 StackFrame::Id break_frame_id_; // Previous break frame id. |
976 int break_id_; // Previous break id. | 978 int break_id_; // Previous break id. |
977 bool load_failed_; // Did the debugger fail to load? | 979 bool load_failed_; // Did the debugger fail to load? |
978 SaveContext save_; // Saves previous context. | 980 SaveContext save_; // Saves previous context. |
979 }; | 981 }; |
980 | 982 |
981 | 983 |
982 // Stack allocated class for disabling break. | 984 // Stack allocated class for disabling break. |
983 class DisableBreak BASE_EMBEDDED { | 985 class DisableBreak BASE_EMBEDDED { |
984 public: | 986 public: |
985 explicit DisableBreak(bool disable_break) : isolate_(Isolate::Current()) { | 987 explicit DisableBreak(Isolate* isolate, bool disable_break) |
| 988 : isolate_(isolate) { |
986 prev_disable_break_ = isolate_->debug()->disable_break(); | 989 prev_disable_break_ = isolate_->debug()->disable_break(); |
987 isolate_->debug()->set_disable_break(disable_break); | 990 isolate_->debug()->set_disable_break(disable_break); |
988 } | 991 } |
989 ~DisableBreak() { | 992 ~DisableBreak() { |
990 ASSERT(Isolate::Current() == isolate_); | 993 ASSERT(Isolate::Current() == isolate_); |
991 isolate_->debug()->set_disable_break(prev_disable_break_); | 994 isolate_->debug()->set_disable_break(prev_disable_break_); |
992 } | 995 } |
993 | 996 |
994 private: | 997 private: |
995 Isolate* isolate_; | 998 Isolate* isolate_; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 | 1063 |
1061 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); | 1064 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); |
1062 }; | 1065 }; |
1063 | 1066 |
1064 | 1067 |
1065 } } // namespace v8::internal | 1068 } } // namespace v8::internal |
1066 | 1069 |
1067 #endif // ENABLE_DEBUGGER_SUPPORT | 1070 #endif // ENABLE_DEBUGGER_SUPPORT |
1068 | 1071 |
1069 #endif // V8_DEBUG_H_ | 1072 #endif // V8_DEBUG_H_ |
OLD | NEW |