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

Side by Side Diff: src/spaces.h

Issue 113262: Revert r1900, r1897 and r1895 which are all gc changes. The changes... (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). There are some caveats. 514 // allocation pointer (space top). If the space top changes during
515 // 515 // iteration (because of allocating new objects), the iterator does
516 // (1) If the space top changes upward during iteration (because of 516 // not iterate new objects. The caller function must create a new
517 // allocating new objects), the iterator does not iterate objects 517 // iterator starting from the old top in order to visit these new
518 // above the original space top. The caller must create a new 518 // objects. Heap::Scavenage() is such an example.
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.
530 519
531 class HeapObjectIterator: public ObjectIterator { 520 class HeapObjectIterator: public ObjectIterator {
532 public: 521 public:
533 // Creates a new object iterator in a given space. If a start 522 // Creates a new object iterator in a given space. If a start
534 // address is not given, the iterator starts from the space bottom. 523 // address is not given, the iterator starts from the space bottom.
535 // If the size function is not given, the iterator calls the default 524 // If the size function is not given, the iterator calls the default
536 // Object::Size(). 525 // Object::Size().
537 explicit HeapObjectIterator(PagedSpace* space); 526 explicit HeapObjectIterator(PagedSpace* space);
538 HeapObjectIterator(PagedSpace* space, HeapObjectCallback size_func); 527 HeapObjectIterator(PagedSpace* space, HeapObjectCallback size_func);
539 HeapObjectIterator(PagedSpace* space, Address start); 528 HeapObjectIterator(PagedSpace* space, Address start);
(...skipping 23 matching lines...) Expand all
563 void Initialize(Address start, Address end, HeapObjectCallback size_func); 552 void Initialize(Address start, Address end, HeapObjectCallback size_func);
564 553
565 #ifdef DEBUG 554 #ifdef DEBUG
566 // Verifies whether fields have valid values. 555 // Verifies whether fields have valid values.
567 void Verify(); 556 void Verify();
568 #endif 557 #endif
569 }; 558 };
570 559
571 560
572 // ----------------------------------------------------------------------------- 561 // -----------------------------------------------------------------------------
573 // A PageIterator iterates the pages in a paged space. 562 // A PageIterator iterates pages in a space.
574 // 563 //
575 // The PageIterator class provides three modes for iterating pages in a space: 564 // The PageIterator class provides three modes for iterating pages in a space:
576 // PAGES_IN_USE iterates pages containing allocated objects. 565 // PAGES_IN_USE iterates pages that are in use by the allocator;
577 // PAGES_USED_BY_MC iterates pages that hold relocated objects during a 566 // PAGES_USED_BY_GC iterates pages that hold relocated objects during a
578 // mark-compact collection. 567 // mark-compact collection;
579 // ALL_PAGES iterates all pages in the space. 568 // 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.
594 569
595 class PageIterator BASE_EMBEDDED { 570 class PageIterator BASE_EMBEDDED {
596 public: 571 public:
597 enum Mode { 572 enum Mode {PAGES_IN_USE, PAGES_USED_BY_MC, ALL_PAGES};
598 PAGES_IN_USE,
599 PAGES_USED_BY_MC,
600 ALL_PAGES
601 };
602 573
603 PageIterator(PagedSpace* space, Mode mode); 574 PageIterator(PagedSpace* space, Mode mode);
604 575
605 inline bool has_next(); 576 inline bool has_next();
606 inline Page* next(); 577 inline Page* next();
607 578
608 private: 579 private:
609 PagedSpace* space_; 580 Page* cur_page_; // next page to return
610 Page* prev_page_; // Previous page returned. 581 Page* stop_page_; // page where to stop
611 Page* stop_page_; // Page to stop at (last page returned by the iterator).
612 }; 582 };
613 583
614 584
615 // ----------------------------------------------------------------------------- 585 // -----------------------------------------------------------------------------
616 // A space has a list of pages. The next page can be accessed via 586 // A space has a list of pages. The next page can be accessed via
617 // Page::next_page() call. The next page of the last page is an 587 // Page::next_page() call. The next page of the last page is an
618 // invalid page pointer. A space can expand and shrink dynamically. 588 // invalid page pointer. A space can expand and shrink dynamically.
619 589
620 // An abstraction of allocation and relocation pointers in a page-structured 590 // An abstraction of allocation and relocation pointers in a page-structured
621 // space. 591 // space.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 protected: 802 protected:
833 // Maximum capacity of this space. 803 // Maximum capacity of this space.
834 int max_capacity_; 804 int max_capacity_;
835 805
836 // Accounting information for this space. 806 // Accounting information for this space.
837 AllocationStats accounting_stats_; 807 AllocationStats accounting_stats_;
838 808
839 // The first page in this space. 809 // The first page in this space.
840 Page* first_page_; 810 Page* first_page_;
841 811
842 // The last page in this space. Initially set in Setup, updated in
843 // Expand and Shrink.
844 Page* last_page_;
845
846 // Normal allocation information. 812 // Normal allocation information.
847 AllocationInfo allocation_info_; 813 AllocationInfo allocation_info_;
848 814
849 // Relocation information during mark-compact collections. 815 // Relocation information during mark-compact collections.
850 AllocationInfo mc_forwarding_info_; 816 AllocationInfo mc_forwarding_info_;
851 817
852 // Sets allocation pointer to a page bottom. 818 // Sets allocation pointer to a page bottom.
853 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p); 819 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p);
854 820
855 // Returns the top page specified by an allocation info structure. 821 // Returns the top page specified by an allocation info structure.
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 1694
1729 private: 1695 private:
1730 LargeObjectChunk* current_; 1696 LargeObjectChunk* current_;
1731 HeapObjectCallback size_func_; 1697 HeapObjectCallback size_func_;
1732 }; 1698 };
1733 1699
1734 1700
1735 } } // namespace v8::internal 1701 } } // namespace v8::internal
1736 1702
1737 #endif // V8_SPACES_H_ 1703 #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