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

Side by Side Diff: src/spaces.h

Issue 245963007: Clean up some uses of Failures and MaybeObjects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 1715
1716 // Cleans up the space, frees all pages in this space except those belonging 1716 // Cleans up the space, frees all pages in this space except those belonging
1717 // to the initial chunk, uncommits addresses in the initial chunk. 1717 // to the initial chunk, uncommits addresses in the initial chunk.
1718 void TearDown(); 1718 void TearDown();
1719 1719
1720 // Checks whether an object/address is in this space. 1720 // Checks whether an object/address is in this space.
1721 inline bool Contains(Address a); 1721 inline bool Contains(Address a);
1722 bool Contains(HeapObject* o) { return Contains(o->address()); } 1722 bool Contains(HeapObject* o) { return Contains(o->address()); }
1723 1723
1724 // Given an address occupied by a live object, return that object if it is 1724 // Given an address occupied by a live object, return that object if it is
1725 // in this space, or Failure::Exception() if it is not. The implementation 1725 // in this space, or Failure::Exception() if it is not. The implementation
Michael Starzinger 2014/04/23 14:34:52 Comment is outdated.
Yang 2014/04/23 15:07:55 Done.
1726 // iterates over objects in the page containing the address, the cost is 1726 // iterates over objects in the page containing the address, the cost is
1727 // linear in the number of objects in the page. It may be slow. 1727 // linear in the number of objects in the page. It may be slow.
1728 MUST_USE_RESULT MaybeObject* FindObject(Address addr); 1728 MUST_USE_RESULT Object* FindObject(Address addr);
Michael Starzinger 2014/04/23 14:34:52 nit: I think the MUST_USE_RESULT is overzealous he
Yang 2014/04/23 15:07:55 Done.
1729 1729
1730 // During boot the free_space_map is created, and afterwards we may need 1730 // During boot the free_space_map is created, and afterwards we may need
1731 // to write it into the free list nodes that were already created. 1731 // to write it into the free list nodes that were already created.
1732 void RepairFreeListsAfterBoot(); 1732 void RepairFreeListsAfterBoot();
1733 1733
1734 // Prepares for a mark-compact GC. 1734 // Prepares for a mark-compact GC.
1735 void PrepareForMarkCompact(); 1735 void PrepareForMarkCompact();
1736 1736
1737 // Current capacity without growing (Size() + Available()). 1737 // Current capacity without growing (Size() + Available()).
1738 intptr_t Capacity() { return accounting_stats_.Capacity(); } 1738 intptr_t Capacity() { return accounting_stats_.Capacity(); }
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 return Size(); 2834 return Size();
2835 } 2835 }
2836 2836
2837 // Approximate amount of physical memory committed for this space. 2837 // Approximate amount of physical memory committed for this space.
2838 size_t CommittedPhysicalMemory(); 2838 size_t CommittedPhysicalMemory();
2839 2839
2840 int PageCount() { 2840 int PageCount() {
2841 return page_count_; 2841 return page_count_;
2842 } 2842 }
2843 2843
2844 // Finds an object for a given address, returns Failure::Exception() 2844 // Finds an object for a given address, returns Failure::Exception()
Michael Starzinger 2014/04/23 14:34:52 Comment is outdated.
Yang 2014/04/23 15:07:55 Done.
2845 // if it is not found. The function iterates through all objects in this 2845 // if it is not found. The function iterates through all objects in this
2846 // space, may be slow. 2846 // space, may be slow.
2847 MaybeObject* FindObject(Address a); 2847 Object* FindObject(Address a);
2848 2848
2849 // Finds a large object page containing the given address, returns NULL 2849 // Finds a large object page containing the given address, returns NULL
2850 // if such a page doesn't exist. 2850 // if such a page doesn't exist.
2851 LargePage* FindPage(Address a); 2851 LargePage* FindPage(Address a);
2852 2852
2853 // Frees unmarked objects. 2853 // Frees unmarked objects.
2854 void FreeUnmarkedObjects(); 2854 void FreeUnmarkedObjects();
2855 2855
2856 // Checks whether a heap object is in this space; O(1). 2856 // Checks whether a heap object is in this space; O(1).
2857 bool Contains(HeapObject* obj); 2857 bool Contains(HeapObject* obj);
2858 2858
2859 // Checks whether the space is empty. 2859 // Checks whether the space is empty.
2860 bool IsEmpty() { return first_page_ == NULL; } 2860 bool IsEmpty() { return first_page_ == NULL; }
2861 2861
2862 LargePage* first_page() { return first_page_; } 2862 LargePage* first_page() { return first_page_; }
2863 2863
2864 #ifdef VERIFY_HEAP 2864 #ifdef VERIFY_HEAP
2865 virtual void Verify(); 2865 virtual void Verify();
2866 #endif 2866 #endif
2867 2867
2868 #ifdef DEBUG 2868 #ifdef DEBUG
2869 virtual void Print(); 2869 virtual void Print();
2870 void ReportStatistics(); 2870 void ReportStatistics();
2871 void CollectCodeStatistics(); 2871 void CollectCodeStatistics();
2872 #endif 2872 #endif
2873 // Checks whether an address is in the object area in this space. It 2873 // Checks whether an address is in the object area in this space. It
2874 // iterates all objects in the space. May be slow. 2874 // iterates all objects in the space. May be slow.
2875 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); } 2875 bool SlowContains(Address addr) { return FindObject(addr)->IsHeapObject(); }
2876 2876
2877 private: 2877 private:
2878 intptr_t max_capacity_; 2878 intptr_t max_capacity_;
2879 intptr_t maximum_committed_; 2879 intptr_t maximum_committed_;
2880 // The head of the linked list of large object chunks. 2880 // The head of the linked list of large object chunks.
2881 LargePage* first_page_; 2881 LargePage* first_page_;
2882 intptr_t size_; // allocated bytes 2882 intptr_t size_; // allocated bytes
2883 int page_count_; // number of chunks 2883 int page_count_; // number of chunks
2884 intptr_t objects_size_; // size of objects 2884 intptr_t objects_size_; // size of objects
2885 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them 2885 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2981 } 2981 }
2982 // Must be small, since an iteration is used for lookup. 2982 // Must be small, since an iteration is used for lookup.
2983 static const int kMaxComments = 64; 2983 static const int kMaxComments = 64;
2984 }; 2984 };
2985 #endif 2985 #endif
2986 2986
2987 2987
2988 } } // namespace v8::internal 2988 } } // namespace v8::internal
2989 2989
2990 #endif // V8_SPACES_H_ 2990 #endif // V8_SPACES_H_
OLDNEW
« src/objects.h ('K') | « src/objects-inl.h ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698