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

Side by Side Diff: src/spaces.h

Issue 113267: Reapply r1900, r1897, r1895 with a fix.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 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/heap.cc ('k') | src/spaces.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 virtual bool has_next_object() = 0; 504 virtual bool has_next_object() = 0;
505 virtual HeapObject* next_object() = 0; 505 virtual HeapObject* next_object() = 0;
506 }; 506 };
507 507
508 508
509 // ----------------------------------------------------------------------------- 509 // -----------------------------------------------------------------------------
510 // Heap object iterator in new/old/map spaces. 510 // Heap object iterator in new/old/map spaces.
511 // 511 //
512 // A HeapObjectIterator iterates objects from a given address to the 512 // A HeapObjectIterator iterates objects from a given address to the
513 // top of a space. The given address must be below the current 513 // top of a space. The given address must be below the current
514 // allocation pointer (space top). If the space top changes during 514 // allocation pointer (space top). There are some caveats.
515 // iteration (because of allocating new objects), the iterator does 515 //
516 // not iterate new objects. The caller function must create a new 516 // (1) If the space top changes upward during iteration (because of
517 // iterator starting from the old top in order to visit these new 517 // allocating new objects), the iterator does not iterate objects
518 // objects. Heap::Scavenage() is such an example. 518 // above the original space top. The caller must create a new
519 // iterator starting from the old top in order to visit these new
520 // objects.
521 //
522 // (2) If new objects are allocated below the original allocation top
523 // (e.g., free-list allocation in paged spaces), the new objects
524 // may or may not be iterated depending on their position with
525 // respect to the current point of iteration.
526 //
527 // (3) The space top should not change downward during iteration,
528 // otherwise the iterator will return not-necessarily-valid
529 // objects.
519 530
520 class HeapObjectIterator: public ObjectIterator { 531 class HeapObjectIterator: public ObjectIterator {
521 public: 532 public:
522 // Creates a new object iterator in a given space. If a start 533 // Creates a new object iterator in a given space. If a start
523 // address is not given, the iterator starts from the space bottom. 534 // address is not given, the iterator starts from the space bottom.
524 // If the size function is not given, the iterator calls the default 535 // If the size function is not given, the iterator calls the default
525 // Object::Size(). 536 // Object::Size().
526 explicit HeapObjectIterator(PagedSpace* space); 537 explicit HeapObjectIterator(PagedSpace* space);
527 HeapObjectIterator(PagedSpace* space, HeapObjectCallback size_func); 538 HeapObjectIterator(PagedSpace* space, HeapObjectCallback size_func);
528 HeapObjectIterator(PagedSpace* space, Address start); 539 HeapObjectIterator(PagedSpace* space, Address start);
(...skipping 23 matching lines...) Expand all
552 void Initialize(Address start, Address end, HeapObjectCallback size_func); 563 void Initialize(Address start, Address end, HeapObjectCallback size_func);
553 564
554 #ifdef DEBUG 565 #ifdef DEBUG
555 // Verifies whether fields have valid values. 566 // Verifies whether fields have valid values.
556 void Verify(); 567 void Verify();
557 #endif 568 #endif
558 }; 569 };
559 570
560 571
561 // ----------------------------------------------------------------------------- 572 // -----------------------------------------------------------------------------
562 // A PageIterator iterates pages in a space. 573 // A PageIterator iterates the pages in a paged space.
563 // 574 //
564 // The PageIterator class provides three modes for iterating pages in a space: 575 // The PageIterator class provides three modes for iterating pages in a space:
565 // PAGES_IN_USE iterates pages that are in use by the allocator; 576 // PAGES_IN_USE iterates pages containing allocated objects.
566 // PAGES_USED_BY_GC iterates pages that hold relocated objects during a 577 // PAGES_USED_BY_MC iterates pages that hold relocated objects during a
567 // mark-compact collection; 578 // mark-compact collection.
568 // ALL_PAGES iterates all pages in the space. 579 // ALL_PAGES iterates all pages in the space.
580 //
581 // There are some caveats.
582 //
583 // (1) If the space expands during iteration, new pages will not be
584 // returned by the iterator in any mode.
585 //
586 // (2) If new objects are allocated during iteration, they will appear
587 // in pages returned by the iterator. Allocation may cause the
588 // allocation pointer or MC allocation pointer in the last page to
589 // change between constructing the iterator and iterating the last
590 // page.
591 //
592 // (3) The space should not shrink during iteration, otherwise the
593 // iterator will return deallocated pages.
569 594
570 class PageIterator BASE_EMBEDDED { 595 class PageIterator BASE_EMBEDDED {
571 public: 596 public:
572 enum Mode {PAGES_IN_USE, PAGES_USED_BY_MC, ALL_PAGES}; 597 enum Mode {
598 PAGES_IN_USE,
599 PAGES_USED_BY_MC,
600 ALL_PAGES
601 };
573 602
574 PageIterator(PagedSpace* space, Mode mode); 603 PageIterator(PagedSpace* space, Mode mode);
575 604
576 inline bool has_next(); 605 inline bool has_next();
577 inline Page* next(); 606 inline Page* next();
578 607
579 private: 608 private:
580 Page* cur_page_; // next page to return 609 PagedSpace* space_;
581 Page* stop_page_; // page where to stop 610 Page* prev_page_; // Previous page returned.
611 Page* stop_page_; // Page to stop at (last page returned by the iterator).
582 }; 612 };
583 613
584 614
585 // ----------------------------------------------------------------------------- 615 // -----------------------------------------------------------------------------
586 // A space has a list of pages. The next page can be accessed via 616 // A space has a list of pages. The next page can be accessed via
587 // Page::next_page() call. The next page of the last page is an 617 // Page::next_page() call. The next page of the last page is an
588 // invalid page pointer. A space can expand and shrink dynamically. 618 // invalid page pointer. A space can expand and shrink dynamically.
589 619
590 // An abstraction of allocation and relocation pointers in a page-structured 620 // An abstraction of allocation and relocation pointers in a page-structured
591 // space. 621 // space.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 protected: 832 protected:
803 // Maximum capacity of this space. 833 // Maximum capacity of this space.
804 int max_capacity_; 834 int max_capacity_;
805 835
806 // Accounting information for this space. 836 // Accounting information for this space.
807 AllocationStats accounting_stats_; 837 AllocationStats accounting_stats_;
808 838
809 // The first page in this space. 839 // The first page in this space.
810 Page* first_page_; 840 Page* first_page_;
811 841
842 // The last page in this space. Initially set in Setup, updated in
843 // Expand and Shrink.
844 Page* last_page_;
845
812 // Normal allocation information. 846 // Normal allocation information.
813 AllocationInfo allocation_info_; 847 AllocationInfo allocation_info_;
814 848
815 // Relocation information during mark-compact collections. 849 // Relocation information during mark-compact collections.
816 AllocationInfo mc_forwarding_info_; 850 AllocationInfo mc_forwarding_info_;
817 851
818 // Sets allocation pointer to a page bottom. 852 // Sets allocation pointer to a page bottom.
819 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p); 853 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p);
820 854
821 // Returns the top page specified by an allocation info structure. 855 // Returns the top page specified by an allocation info structure.
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 1728
1695 private: 1729 private:
1696 LargeObjectChunk* current_; 1730 LargeObjectChunk* current_;
1697 HeapObjectCallback size_func_; 1731 HeapObjectCallback size_func_;
1698 }; 1732 };
1699 1733
1700 1734
1701 } } // namespace v8::internal 1735 } } // namespace v8::internal
1702 1736
1703 #endif // V8_SPACES_H_ 1737 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698