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

Side by Side Diff: src/debug.h

Issue 239133002: Refactoring: HashMap: provide a pointer match function, so users don't need to. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/bootstrapper.cc ('k') | src/hashmap.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 // 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 explicit ScriptCache(Isolate* isolate) 177 explicit ScriptCache(Isolate* isolate)
178 : HashMap(ScriptMatch), isolate_(isolate), collected_scripts_(10) {} 178 : HashMap(HashMap::PointersMatch),
179 isolate_(isolate),
180 collected_scripts_(10) {}
179 virtual ~ScriptCache() { Clear(); } 181 virtual ~ScriptCache() { Clear(); }
180 182
181 // Add script to the cache. 183 // Add script to the cache.
182 void Add(Handle<Script> script); 184 void Add(Handle<Script> script);
183 185
184 // Return the scripts in the cache. 186 // Return the scripts in the cache.
185 Handle<FixedArray> GetScripts(); 187 Handle<FixedArray> GetScripts();
186 188
187 // Generate debugger events for collected scripts. 189 // Generate debugger events for collected scripts.
188 void ProcessCollectedScripts(); 190 void ProcessCollectedScripts();
189 191
190 private: 192 private:
191 // Calculate the hash value from the key (script id). 193 // Calculate the hash value from the key (script id).
192 static uint32_t Hash(int key) { 194 static uint32_t Hash(int key) {
193 return ComputeIntegerHash(key, v8::internal::kZeroHashSeed); 195 return ComputeIntegerHash(key, v8::internal::kZeroHashSeed);
194 } 196 }
195 197
196 // Scripts match if their keys (script id) match.
197 static bool ScriptMatch(void* key1, void* key2) { return key1 == key2; }
198
199 // Clear the cache releasing all the weak handles. 198 // Clear the cache releasing all the weak handles.
200 void Clear(); 199 void Clear();
201 200
202 // Weak handle callback for scripts in the cache. 201 // Weak handle callback for scripts in the cache.
203 static void HandleWeakScript( 202 static void HandleWeakScript(
204 const v8::WeakCallbackData<v8::Value, void>& data); 203 const v8::WeakCallbackData<v8::Value, void>& data);
205 204
206 Isolate* isolate_; 205 Isolate* isolate_;
207 // List used during GC to temporarily store id's of collected scripts. 206 // List used during GC to temporarily store id's of collected scripts.
208 List<int> collected_scripts_; 207 List<int> collected_scripts_;
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 1058
1060 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread); 1059 DISALLOW_COPY_AND_ASSIGN(MessageDispatchHelperThread);
1061 }; 1060 };
1062 1061
1063 1062
1064 } } // namespace v8::internal 1063 } } // namespace v8::internal
1065 1064
1066 #endif // ENABLE_DEBUGGER_SUPPORT 1065 #endif // ENABLE_DEBUGGER_SUPPORT
1067 1066
1068 #endif // V8_DEBUG_H_ 1067 #endif // V8_DEBUG_H_
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/hashmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698