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

Side by Side Diff: src/heap.h

Issue 12217106: Don't use TLS for space iterators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed feedback. Created 7 years, 10 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/debug.cc ('k') | src/heap.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 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 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 // or care about intergenerational references. All heap object pointers have to 2332 // or care about intergenerational references. All heap object pointers have to
2333 // point into the heap to a location that has a map pointer at its first word. 2333 // point into the heap to a location that has a map pointer at its first word.
2334 // Caveat: Heap::Contains is an approximation because it can return true for 2334 // Caveat: Heap::Contains is an approximation because it can return true for
2335 // objects in a heap space but above the allocation pointer. 2335 // objects in a heap space but above the allocation pointer.
2336 class VerifyPointersVisitor: public ObjectVisitor { 2336 class VerifyPointersVisitor: public ObjectVisitor {
2337 public: 2337 public:
2338 inline void VisitPointers(Object** start, Object** end); 2338 inline void VisitPointers(Object** start, Object** end);
2339 }; 2339 };
2340 2340
2341 2341
2342 // Space iterator for iterating over all spaces of the heap. 2342 // Space iterator for iterating over all spaces of the heap. Returns each space
2343 // Returns each space in turn, and null when it is done. 2343 // in turn, and null when it is done.
2344 class AllSpaces BASE_EMBEDDED { 2344 class AllSpaces BASE_EMBEDDED {
2345 public: 2345 public:
2346 explicit AllSpaces(Heap* heap) : heap_(heap), counter_(FIRST_SPACE) {}
2346 Space* next(); 2347 Space* next();
2347 AllSpaces() { counter_ = FIRST_SPACE; }
2348 private: 2348 private:
2349 Heap* heap_;
2349 int counter_; 2350 int counter_;
2350 }; 2351 };
2351 2352
2352 2353
2353 // Space iterator for iterating over all old spaces of the heap: Old pointer 2354 // Space iterator for iterating over all old spaces of the heap: Old pointer
2354 // space, old data space and code space. 2355 // space, old data space and code space. Returns each space in turn, and null
2355 // Returns each space in turn, and null when it is done. 2356 // when it is done.
2356 class OldSpaces BASE_EMBEDDED { 2357 class OldSpaces BASE_EMBEDDED {
2357 public: 2358 public:
2359 explicit OldSpaces(Heap* heap) : heap_(heap), counter_(OLD_POINTER_SPACE) {}
2358 OldSpace* next(); 2360 OldSpace* next();
2359 OldSpaces() { counter_ = OLD_POINTER_SPACE; }
2360 private: 2361 private:
2362 Heap* heap_;
2361 int counter_; 2363 int counter_;
2362 }; 2364 };
2363 2365
2364 2366
2365 // Space iterator for iterating over all the paged spaces of the heap: 2367 // Space iterator for iterating over all the paged spaces of the heap: Map
2366 // Map space, old pointer space, old data space, code space and cell space. 2368 // space, old pointer space, old data space, code space and cell space. Returns
2367 // Returns each space in turn, and null when it is done. 2369 // each space in turn, and null when it is done.
2368 class PagedSpaces BASE_EMBEDDED { 2370 class PagedSpaces BASE_EMBEDDED {
2369 public: 2371 public:
2372 explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_POINTER_SPACE) {}
2370 PagedSpace* next(); 2373 PagedSpace* next();
2371 PagedSpaces() { counter_ = OLD_POINTER_SPACE; }
2372 private: 2374 private:
2375 Heap* heap_;
2373 int counter_; 2376 int counter_;
2374 }; 2377 };
2375 2378
2376 2379
2377 // Space iterator for iterating over all spaces of the heap. 2380 // Space iterator for iterating over all spaces of the heap.
2378 // For each space an object iterator is provided. The deallocation of the 2381 // For each space an object iterator is provided. The deallocation of the
2379 // returned object iterators is handled by the space iterator. 2382 // returned object iterators is handled by the space iterator.
2380 class SpaceIterator : public Malloced { 2383 class SpaceIterator : public Malloced {
2381 public: 2384 public:
2382 SpaceIterator(); 2385 explicit SpaceIterator(Heap* heap);
2383 explicit SpaceIterator(HeapObjectCallback size_func); 2386 SpaceIterator(Heap* heap, HeapObjectCallback size_func);
2384 virtual ~SpaceIterator(); 2387 virtual ~SpaceIterator();
2385 2388
2386 bool has_next(); 2389 bool has_next();
2387 ObjectIterator* next(); 2390 ObjectIterator* next();
2388 2391
2389 private: 2392 private:
2390 ObjectIterator* CreateIterator(); 2393 ObjectIterator* CreateIterator();
2391 2394
2395 Heap* heap_;
2392 int current_space_; // from enum AllocationSpace. 2396 int current_space_; // from enum AllocationSpace.
2393 ObjectIterator* iterator_; // object iterator for the current space. 2397 ObjectIterator* iterator_; // object iterator for the current space.
2394 HeapObjectCallback size_func_; 2398 HeapObjectCallback size_func_;
2395 }; 2399 };
2396 2400
2397 2401
2398 // A HeapIterator provides iteration over the whole heap. It 2402 // A HeapIterator provides iteration over the whole heap. It
2399 // aggregates the specific iterators for the different spaces as 2403 // aggregates the specific iterators for the different spaces as
2400 // these can only iterate over one space only. 2404 // these can only iterate over one space only.
2401 // 2405 //
2402 // HeapIterator can skip free list nodes (that is, de-allocated heap 2406 // HeapIterator can skip free list nodes (that is, de-allocated heap
2403 // objects that still remain in the heap). As implementation of free 2407 // objects that still remain in the heap). As implementation of free
2404 // nodes filtering uses GC marks, it can't be used during MS/MC GC 2408 // nodes filtering uses GC marks, it can't be used during MS/MC GC
2405 // phases. Also, it is forbidden to interrupt iteration in this mode, 2409 // phases. Also, it is forbidden to interrupt iteration in this mode,
2406 // as this will leave heap objects marked (and thus, unusable). 2410 // as this will leave heap objects marked (and thus, unusable).
2407 class HeapObjectsFilter; 2411 class HeapObjectsFilter;
2408 2412
2409 class HeapIterator BASE_EMBEDDED { 2413 class HeapIterator BASE_EMBEDDED {
2410 public: 2414 public:
2411 enum HeapObjectsFiltering { 2415 enum HeapObjectsFiltering {
2412 kNoFiltering, 2416 kNoFiltering,
2413 kFilterUnreachable 2417 kFilterUnreachable
2414 }; 2418 };
2415 2419
2416 HeapIterator(); 2420 explicit HeapIterator(Heap* heap);
2417 explicit HeapIterator(HeapObjectsFiltering filtering); 2421 HeapIterator(Heap* heap, HeapObjectsFiltering filtering);
2418 ~HeapIterator(); 2422 ~HeapIterator();
2419 2423
2420 HeapObject* next(); 2424 HeapObject* next();
2421 void reset(); 2425 void reset();
2422 2426
2423 private: 2427 private:
2424 // Perform the initialization. 2428 // Perform the initialization.
2425 void Init(); 2429 void Init();
2426 // Perform all necessary shutdown (destruction) work. 2430 // Perform all necessary shutdown (destruction) work.
2427 void Shutdown(); 2431 void Shutdown();
2428 HeapObject* NextObject(); 2432 HeapObject* NextObject();
2429 2433
2434 Heap* heap_;
2430 HeapObjectsFiltering filtering_; 2435 HeapObjectsFiltering filtering_;
2431 HeapObjectsFilter* filter_; 2436 HeapObjectsFilter* filter_;
2432 // Space iterator for iterating all the spaces. 2437 // Space iterator for iterating all the spaces.
2433 SpaceIterator* space_iterator_; 2438 SpaceIterator* space_iterator_;
2434 // Object iterator for the space currently being iterated. 2439 // Object iterator for the space currently being iterated.
2435 ObjectIterator* object_iterator_; 2440 ObjectIterator* object_iterator_;
2436 }; 2441 };
2437 2442
2438 2443
2439 // Cache for mapping (map, property name) into field offset. 2444 // Cache for mapping (map, property name) into field offset.
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 AssertNoAllocation no_alloc; // i.e. no gc allowed. 2945 AssertNoAllocation no_alloc; // i.e. no gc allowed.
2941 2946
2942 private: 2947 private:
2943 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2948 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2944 }; 2949 };
2945 #endif // DEBUG 2950 #endif // DEBUG
2946 2951
2947 } } // namespace v8::internal 2952 } } // namespace v8::internal
2948 2953
2949 #endif // V8_HEAP_H_ 2954 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698