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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 intptr_t original_data_; | 221 intptr_t original_data_; |
222 int position_; | 222 int position_; |
223 int statement_position_; | 223 int statement_position_; |
224 }; | 224 }; |
225 | 225 |
226 | 226 |
227 // Cache of all script objects in the heap. When a script is added a weak handle | 227 // Cache of all script objects in the heap. When a script is added a weak handle |
228 // to it is created and that weak handle is stored in the cache. The weak handle | 228 // to it is created and that weak handle is stored in the cache. The weak handle |
229 // callback takes care of removing the script from the cache. The key used in | 229 // callback takes care of removing the script from the cache. The key used in |
230 // the cache is the script id. | 230 // the cache is the script id. |
231 class ScriptCache : private HashMap { | 231 class ScriptCache { |
232 public: | 232 public: |
233 explicit ScriptCache(Isolate* isolate); | 233 explicit ScriptCache(Isolate* isolate); |
234 virtual ~ScriptCache() { Clear(); } | 234 ~ScriptCache(); |
235 | 235 |
236 // Add script to the cache. | 236 // Add script to the cache. |
237 void Add(Handle<Script> script); | 237 void Add(Handle<Script> script); |
238 | 238 |
239 // Return the scripts in the cache. | 239 // Return the scripts in the cache. |
240 Handle<FixedArray> GetScripts(); | 240 Handle<FixedArray> GetScripts() { |
| 241 return WeakValueHashTable::GetWeakValues(table_); |
| 242 } |
241 | 243 |
242 private: | 244 private: |
243 // Calculate the hash value from the key (script id). | |
244 static uint32_t Hash(int key) { | |
245 return ComputeIntegerHash(key, v8::internal::kZeroHashSeed); | |
246 } | |
247 | |
248 // Clear the cache releasing all the weak handles. | |
249 void Clear(); | |
250 | |
251 // Weak handle callback for scripts in the cache. | |
252 static void HandleWeakScript( | |
253 const v8::WeakCallbackData<v8::Value, void>& data); | |
254 | |
255 Isolate* isolate_; | 245 Isolate* isolate_; |
| 246 Handle<WeakValueHashTable> table_; |
256 }; | 247 }; |
257 | 248 |
258 | 249 |
259 // Linked list holding debug info objects. The debug info objects are kept as | 250 // Linked list holding debug info objects. The debug info objects are kept as |
260 // weak handles to avoid a debug info object to keep a function alive. | 251 // weak handles to avoid a debug info object to keep a function alive. |
261 class DebugInfoListNode { | 252 class DebugInfoListNode { |
262 public: | 253 public: |
263 explicit DebugInfoListNode(DebugInfo* debug_info); | 254 explicit DebugInfoListNode(DebugInfo* debug_info); |
264 virtual ~DebugInfoListNode() { ClearInfo(); } | 255 virtual ~DebugInfoListNode() { ClearInfo(); } |
265 | 256 |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // several frames above. | 830 // several frames above. |
840 // There is no calling conventions here, because it never actually gets | 831 // There is no calling conventions here, because it never actually gets |
841 // called, it only gets returned to. | 832 // called, it only gets returned to. |
842 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); | 833 static void GenerateFrameDropperLiveEdit(MacroAssembler* masm); |
843 }; | 834 }; |
844 | 835 |
845 | 836 |
846 } } // namespace v8::internal | 837 } } // namespace v8::internal |
847 | 838 |
848 #endif // V8_DEBUG_H_ | 839 #endif // V8_DEBUG_H_ |
OLD | NEW |