OLD | NEW |
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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 // Sets allocation pointer to a page bottom. | 793 // Sets allocation pointer to a page bottom. |
794 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p); | 794 static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p); |
795 | 795 |
796 // Returns the top page specified by an allocation info structure. | 796 // Returns the top page specified by an allocation info structure. |
797 static Page* TopPageOf(AllocationInfo alloc_info) { | 797 static Page* TopPageOf(AllocationInfo alloc_info) { |
798 return Page::FromAllocationTop(alloc_info.limit); | 798 return Page::FromAllocationTop(alloc_info.limit); |
799 } | 799 } |
800 | 800 |
801 // Expands the space by allocating a fixed number of pages. Returns false if | 801 // Expands the space by allocating a fixed number of pages. Returns false if |
802 // it cannot allocate requested number of pages from OS. Newly allocated | 802 // it cannot allocate requested number of pages from OS. Newly allocated |
803 // pages are appened to the last_page; | 803 // pages are append to the last_page; |
804 bool Expand(Page* last_page); | 804 bool Expand(Page* last_page); |
805 | 805 |
806 // Generic fast case allocation function that tries linear allocation in | 806 // Generic fast case allocation function that tries linear allocation in |
807 // the top page of 'alloc_info'. Returns NULL on failure. | 807 // the top page of 'alloc_info'. Returns NULL on failure. |
808 inline HeapObject* AllocateLinearly(AllocationInfo* alloc_info, | 808 inline HeapObject* AllocateLinearly(AllocationInfo* alloc_info, |
809 int size_in_bytes); | 809 int size_in_bytes); |
810 | 810 |
811 // During normal allocation or deserialization, roll to the next page in | 811 // During normal allocation or deserialization, roll to the next page in |
812 // the space (there is assumed to be one) and allocate there. This | 812 // the space (there is assumed to be one) and allocate there. This |
813 // function is space-dependent. | 813 // function is space-dependent. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 889 |
890 // Tear down the space. Heap memory was not allocated by the space, so it | 890 // Tear down the space. Heap memory was not allocated by the space, so it |
891 // is not deallocated here. | 891 // is not deallocated here. |
892 void TearDown(); | 892 void TearDown(); |
893 | 893 |
894 // True if the space has been set up but not torn down. | 894 // True if the space has been set up but not torn down. |
895 bool HasBeenSetup() { return start_ != NULL; } | 895 bool HasBeenSetup() { return start_ != NULL; } |
896 | 896 |
897 // Double the size of the semispace by committing extra virtual memory. | 897 // Double the size of the semispace by committing extra virtual memory. |
898 // Assumes that the caller has checked that the semispace has not reached | 898 // Assumes that the caller has checked that the semispace has not reached |
899 // its maxmimum capacity (and thus there is space available in the reserved | 899 // its maximum capacity (and thus there is space available in the reserved |
900 // address range to grow). | 900 // address range to grow). |
901 bool Double(); | 901 bool Double(); |
902 | 902 |
903 // Returns the start address of the space. | 903 // Returns the start address of the space. |
904 Address low() { return start_; } | 904 Address low() { return start_; } |
905 // Returns one past the end address of the space. | 905 // Returns one past the end address of the space. |
906 Address high() { return low() + capacity_; } | 906 Address high() { return low() + capacity_; } |
907 | 907 |
908 // Age mark accessors. | 908 // Age mark accessors. |
909 Address age_mark() { return age_mark_; } | 909 Address age_mark() { return age_mark_; } |
910 void set_age_mark(Address mark) { age_mark_ = mark; } | 910 void set_age_mark(Address mark) { age_mark_ = mark; } |
911 | 911 |
912 // True if the address is in the address range of this semispace (not | 912 // True if the address is in the address range of this semispace (not |
913 // necessarily below the allocation pointer). | 913 // necessarily below the allocation pointer). |
914 bool Contains(Address a) { | 914 bool Contains(Address a) { |
915 return (reinterpret_cast<uint32_t>(a) & address_mask_) | 915 return (reinterpret_cast<uint32_t>(a) & address_mask_) |
916 == reinterpret_cast<uint32_t>(start_); | 916 == reinterpret_cast<uint32_t>(start_); |
917 } | 917 } |
918 | 918 |
919 // True if the object is a heap object in the address range of this | 919 // True if the object is a heap object in the address range of this |
920 // semispace (not necessarily below the allocation pointer). | 920 // semispace (not necessarily below the allocation pointer). |
921 bool Contains(Object* o) { | 921 bool Contains(Object* o) { |
922 return (reinterpret_cast<uint32_t>(o) & object_mask_) == object_expected_; | 922 return (reinterpret_cast<uint32_t>(o) & object_mask_) == object_expected_; |
923 } | 923 } |
924 | 924 |
925 // The offset of an address from the begining of the space. | 925 // The offset of an address from the beginning of the space. |
926 int SpaceOffsetForAddress(Address addr) { return addr - low(); } | 926 int SpaceOffsetForAddress(Address addr) { return addr - low(); } |
927 | 927 |
928 // If we don't have this here then SemiSpace will be abstract. However | 928 // If we don't have this here then SemiSpace will be abstract. However |
929 // it should never be called. | 929 // it should never be called. |
930 virtual int Size() { | 930 virtual int Size() { |
931 UNREACHABLE(); | 931 UNREACHABLE(); |
932 return 0; | 932 return 0; |
933 } | 933 } |
934 | 934 |
935 #ifdef DEBUG | 935 #ifdef DEBUG |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 // Accessors for the fields of the chunk. | 1519 // Accessors for the fields of the chunk. |
1520 LargeObjectChunk* next() { return next_; } | 1520 LargeObjectChunk* next() { return next_; } |
1521 void set_next(LargeObjectChunk* chunk) { next_ = chunk; } | 1521 void set_next(LargeObjectChunk* chunk) { next_ = chunk; } |
1522 | 1522 |
1523 size_t size() { return size_; } | 1523 size_t size() { return size_; } |
1524 void set_size(size_t size_in_bytes) { size_ = size_in_bytes; } | 1524 void set_size(size_t size_in_bytes) { size_ = size_in_bytes; } |
1525 | 1525 |
1526 // Returns the object in this chunk. | 1526 // Returns the object in this chunk. |
1527 inline HeapObject* GetObject(); | 1527 inline HeapObject* GetObject(); |
1528 | 1528 |
1529 // Given a requested size (including any extra remembereed set words), | 1529 // Given a requested size (including any extra remembered set words), |
1530 // returns the physical size of a chunk to be allocated. | 1530 // returns the physical size of a chunk to be allocated. |
1531 static int ChunkSizeFor(int size_in_bytes); | 1531 static int ChunkSizeFor(int size_in_bytes); |
1532 | 1532 |
1533 // Given a chunk size, returns the object size it can accomodate (not | 1533 // Given a chunk size, returns the object size it can accommodate (not |
1534 // including any extra remembered set words). Used by | 1534 // including any extra remembered set words). Used by |
1535 // LargeObjectSpace::Available. Note that this can overestimate the size | 1535 // LargeObjectSpace::Available. Note that this can overestimate the size |
1536 // of object that will fit in a chunk---if the object requires extra | 1536 // of object that will fit in a chunk---if the object requires extra |
1537 // remembered set words (eg, for large fixed arrays), the actual object | 1537 // remembered set words (eg, for large fixed arrays), the actual object |
1538 // size for the chunk will be smaller than reported by this function. | 1538 // size for the chunk will be smaller than reported by this function. |
1539 static int ObjectSizeFor(int chunk_size) { | 1539 static int ObjectSizeFor(int chunk_size) { |
1540 if (chunk_size <= (Page::kPageSize + Page::kObjectStartOffset)) return 0; | 1540 if (chunk_size <= (Page::kPageSize + Page::kObjectStartOffset)) return 0; |
1541 return chunk_size - Page::kPageSize - Page::kObjectStartOffset; | 1541 return chunk_size - Page::kPageSize - Page::kObjectStartOffset; |
1542 } | 1542 } |
1543 | 1543 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 | 1654 |
1655 private: | 1655 private: |
1656 LargeObjectChunk* current_; | 1656 LargeObjectChunk* current_; |
1657 HeapObjectCallback size_func_; | 1657 HeapObjectCallback size_func_; |
1658 }; | 1658 }; |
1659 | 1659 |
1660 | 1660 |
1661 } } // namespace v8::internal | 1661 } } // namespace v8::internal |
1662 | 1662 |
1663 #endif // V8_SPACES_H_ | 1663 #endif // V8_SPACES_H_ |
OLD | NEW |