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

Side by Side Diff: src/global-handles.h

Issue 21042004: Make GlobalHandle::NodeBlock deletable (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 4 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 | « no previous file | src/global-handles.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // Returns the current number of weak handles to global objects. 150 // Returns the current number of weak handles to global objects.
151 // These handles are also included in NumberOfWeakHandles(). 151 // These handles are also included in NumberOfWeakHandles().
152 int NumberOfGlobalObjectWeakHandles(); 152 int NumberOfGlobalObjectWeakHandles();
153 153
154 // Returns the current number of handles to global objects. 154 // Returns the current number of handles to global objects.
155 int global_handles_count() const { 155 int global_handles_count() const {
156 return number_of_global_handles_; 156 return number_of_global_handles_;
157 } 157 }
158 158
159 // Returns the current number of allocated blocks
160 int block_count() const { return number_of_blocks_; }
161
159 // Clear the weakness of a global handle. 162 // Clear the weakness of a global handle.
160 static void ClearWeakness(Object** location); 163 static void ClearWeakness(Object** location);
161 164
162 // Clear the weakness of a global handle. 165 // Clear the weakness of a global handle.
163 static void MarkIndependent(Object** location); 166 static void MarkIndependent(Object** location);
164 167
165 // Mark the reference to this object externaly unreachable. 168 // Mark the reference to this object externaly unreachable.
166 static void MarkPartiallyDependent(Object** location); 169 static void MarkPartiallyDependent(Object** location);
167 170
168 static bool IsIndependent(Object** location); 171 static bool IsIndependent(Object** location);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 void RemoveImplicitRefGroups(); 271 void RemoveImplicitRefGroups();
269 272
270 // Tear down the global handle structure. 273 // Tear down the global handle structure.
271 void TearDown(); 274 void TearDown();
272 275
273 Isolate* isolate() { return isolate_; } 276 Isolate* isolate() { return isolate_; }
274 277
275 #ifdef DEBUG 278 #ifdef DEBUG
276 void PrintStats(); 279 void PrintStats();
277 void Print(); 280 void Print();
281 void VerifyBlockInvariants();
278 #endif 282 #endif
279 283
280 private: 284 private:
281 explicit GlobalHandles(Isolate* isolate); 285 explicit GlobalHandles(Isolate* isolate);
282 286
287 void SortBlocks(bool shouldPrune);
288
283 // Migrates data from the internal representation (object_group_connections_, 289 // Migrates data from the internal representation (object_group_connections_,
284 // retainer_infos_ and implicit_ref_connections_) to the public and more 290 // retainer_infos_ and implicit_ref_connections_) to the public and more
285 // efficient representation (object_groups_ and implicit_ref_groups_). 291 // efficient representation (object_groups_ and implicit_ref_groups_).
286 void ComputeObjectGroupsAndImplicitReferences(); 292 void ComputeObjectGroupsAndImplicitReferences();
287 293
288 // v8::internal::List is inefficient even for small number of elements, if we 294 // v8::internal::List is inefficient even for small number of elements, if we
289 // don't assign any initial capacity. 295 // don't assign any initial capacity.
290 static const int kObjectGroupConnectionsCapacity = 20; 296 static const int kObjectGroupConnectionsCapacity = 20;
291 297
292 // Internal node structures. 298 // Internal node structures.
293 class Node; 299 class Node;
294 class NodeBlock; 300 class NodeBlock;
295 class NodeIterator; 301 class NodeIterator;
302 class BlockListIterator;
303 // Base class for NodeBlock
304 class BlockList {
305 public:
306 BlockList();
307 ~BlockList() { ASSERT(IsDetached()); }
308 void Detach();
309 void InsertAsHead(BlockList* block) {
310 ASSERT(IsAnchor());
311 InsertAsNext(block);
312 }
313 void InsertAsTail(BlockList* block) {
314 ASSERT(IsAnchor());
315 prev_block_->InsertAsNext(block);
316 }
317 inline bool IsAnchor() { return first_free_ == NULL && used_nodes_ == 0; }
318 inline bool IsDetached() {
319 ASSERT_EQ(prev_block_ == this, next_block_ == this);
320 return prev_block_ == this;
321 }
322 bool HasAtLeastLength(int length);
323 bool IsUnused() { return used_nodes_ == 0; }
324 int used_nodes() const { return used_nodes_; }
325 BlockList* next() { return next_block_; }
326 BlockList* prev() { return prev_block_; }
327 #ifdef DEBUG
328 int LengthOfFreeList();
329 #endif
330 static void SortBlocks(GlobalHandles* global_handles, bool prune);
331
332 protected:
333 BlockList* prev_block_;
334 BlockList* next_block_;
335 Node* first_free_;
336 int used_nodes_;
337
338 private:
339 // Needed for quicksort
340 static int CompareBlocks(const void* a, const void* b);
341 void InsertAsNext(BlockList* block);
342 DISALLOW_COPY_AND_ASSIGN(BlockList);
343 };
296 344
297 Isolate* isolate_; 345 Isolate* isolate_;
298 346
347 // Field always containing the number of blocks allocated.
348 int number_of_blocks_;
299 // Field always containing the number of handles to global objects. 349 // Field always containing the number of handles to global objects.
300 int number_of_global_handles_; 350 int number_of_global_handles_;
301 351
302 // List of all allocated node blocks. 352 // Anchors for doubly linked lists of blocks
303 NodeBlock* first_block_; 353 BlockList full_blocks_;
354 BlockList non_full_blocks_;
304 355
305 // List of node blocks with used nodes. 356 // An array of all the anchors held by GlobalHandles.
306 NodeBlock* first_used_block_; 357 // This simplifies iteration across all blocks.
307 358 static const int kAllAnchorsSize = 2;
308 // Free list of nodes. 359 BlockList* all_anchors_[kAllAnchorsSize];
309 Node* first_free_;
310 360
311 // Contains all nodes holding new space objects. Note: when the list 361 // Contains all nodes holding new space objects. Note: when the list
312 // is accessed, some of the objects may have been promoted already. 362 // is accessed, some of the objects may have been promoted already.
313 List<Node*> new_space_nodes_; 363 List<Node*> new_space_nodes_;
314 364
315 int post_gc_processing_count_; 365 int post_gc_processing_count_;
316 366
317 // Object groups and implicit references, public and more efficient 367 // Object groups and implicit references, public and more efficient
318 // representation. 368 // representation.
319 List<ObjectGroup*> object_groups_; 369 List<ObjectGroup*> object_groups_;
320 List<ImplicitRefGroup*> implicit_ref_groups_; 370 List<ImplicitRefGroup*> implicit_ref_groups_;
321 371
322 // Object groups and implicit references, temporary representation while 372 // Object groups and implicit references, temporary representation while
323 // constructing the groups. 373 // constructing the groups.
324 List<ObjectGroupConnection> object_group_connections_; 374 List<ObjectGroupConnection> object_group_connections_;
325 List<ObjectGroupRetainerInfo> retainer_infos_; 375 List<ObjectGroupRetainerInfo> retainer_infos_;
326 List<ObjectGroupConnection> implicit_ref_connections_; 376 List<ObjectGroupConnection> implicit_ref_connections_;
327 377
328 friend class Isolate; 378 friend class Isolate;
329 379
330 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); 380 DISALLOW_COPY_AND_ASSIGN(GlobalHandles);
331 }; 381 };
332 382
333 383
334 } } // namespace v8::internal 384 } } // namespace v8::internal
335 385
336 #endif // V8_GLOBAL_HANDLES_H_ 386 #endif // V8_GLOBAL_HANDLES_H_
OLDNEW
« no previous file with comments | « no previous file | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698