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

Side by Side Diff: src/spaces.h

Issue 8256012: Remove some asserts to speed up debug mode. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 2 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/objects-inl.h ('k') | src/spaces-inl.h » ('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 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 INLINE(static Page* FromAddress(Address a)) { 635 INLINE(static Page* FromAddress(Address a)) {
636 return reinterpret_cast<Page*>(OffsetFrom(a) & ~kPageAlignmentMask); 636 return reinterpret_cast<Page*>(OffsetFrom(a) & ~kPageAlignmentMask);
637 } 637 }
638 638
639 // Returns the page containing an allocation top. Because an allocation 639 // Returns the page containing an allocation top. Because an allocation
640 // top address can be the upper bound of the page, we need to subtract 640 // top address can be the upper bound of the page, we need to subtract
641 // it with kPointerSize first. The address ranges from 641 // it with kPointerSize first. The address ranges from
642 // [page_addr + kObjectStartOffset .. page_addr + kPageSize]. 642 // [page_addr + kObjectStartOffset .. page_addr + kPageSize].
643 INLINE(static Page* FromAllocationTop(Address top)) { 643 INLINE(static Page* FromAllocationTop(Address top)) {
644 Page* p = FromAddress(top - kPointerSize); 644 Page* p = FromAddress(top - kPointerSize);
645 ASSERT_PAGE_OFFSET(p->Offset(top));
646 return p; 645 return p;
647 } 646 }
648 647
649 // Returns the next page in the chain of pages owned by a space. 648 // Returns the next page in the chain of pages owned by a space.
650 inline Page* next_page(); 649 inline Page* next_page();
651 inline Page* prev_page(); 650 inline Page* prev_page();
652 inline void set_next_page(Page* page); 651 inline void set_next_page(Page* page);
653 inline void set_prev_page(Page* page); 652 inline void set_prev_page(Page* page);
654 653
655 // Returns the start address of the object area in this page. 654 // Returns the start address of the object area in this page.
656 Address ObjectAreaStart() { return address() + kObjectStartOffset; } 655 Address ObjectAreaStart() { return address() + kObjectStartOffset; }
657 656
658 // Returns the end address (exclusive) of the object area in this page. 657 // Returns the end address (exclusive) of the object area in this page.
659 Address ObjectAreaEnd() { return address() + Page::kPageSize; } 658 Address ObjectAreaEnd() { return address() + Page::kPageSize; }
660 659
661 // Checks whether an address is page aligned. 660 // Checks whether an address is page aligned.
662 static bool IsAlignedToPageSize(Address a) { 661 static bool IsAlignedToPageSize(Address a) {
663 return 0 == (OffsetFrom(a) & kPageAlignmentMask); 662 return 0 == (OffsetFrom(a) & kPageAlignmentMask);
664 } 663 }
665 664
666 // Returns the offset of a given address to this page. 665 // Returns the offset of a given address to this page.
667 INLINE(int Offset(Address a)) { 666 INLINE(int Offset(Address a)) {
668 int offset = static_cast<int>(a - address()); 667 int offset = static_cast<int>(a - address());
669 ASSERT_PAGE_OFFSET(offset);
670 return offset; 668 return offset;
671 } 669 }
672 670
673 // Returns the address for a given offset to the this page. 671 // Returns the address for a given offset to the this page.
674 Address OffsetToAddress(int offset) { 672 Address OffsetToAddress(int offset) {
675 ASSERT_PAGE_OFFSET(offset); 673 ASSERT_PAGE_OFFSET(offset);
676 return address() + offset; 674 return address() + offset;
677 } 675 }
678 676
679 // --------------------------------------------------------------------- 677 // ---------------------------------------------------------------------
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 Address address() { 1732 Address address() {
1735 return reinterpret_cast<Address>(this); 1733 return reinterpret_cast<Address>(this);
1736 } 1734 }
1737 1735
1738 // Finds the NewSpacePage containg the given address. 1736 // Finds the NewSpacePage containg the given address.
1739 static inline NewSpacePage* FromAddress(Address address_in_page) { 1737 static inline NewSpacePage* FromAddress(Address address_in_page) {
1740 Address page_start = 1738 Address page_start =
1741 reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address_in_page) & 1739 reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address_in_page) &
1742 ~Page::kPageAlignmentMask); 1740 ~Page::kPageAlignmentMask);
1743 NewSpacePage* page = reinterpret_cast<NewSpacePage*>(page_start); 1741 NewSpacePage* page = reinterpret_cast<NewSpacePage*>(page_start);
1744 ASSERT(page->InNewSpace());
1745 return page; 1742 return page;
1746 } 1743 }
1747 1744
1748 // Find the page for a limit address. A limit address is either an address 1745 // Find the page for a limit address. A limit address is either an address
1749 // inside a page, or the address right after the last byte of a page. 1746 // inside a page, or the address right after the last byte of a page.
1750 static inline NewSpacePage* FromLimit(Address address_limit) { 1747 static inline NewSpacePage* FromLimit(Address address_limit) {
1751 return NewSpacePage::FromAddress(address_limit - 1); 1748 return NewSpacePage::FromAddress(address_limit - 1);
1752 } 1749 }
1753 1750
1754 private: 1751 private:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 bool ShrinkTo(int new_capacity); 1808 bool ShrinkTo(int new_capacity);
1812 1809
1813 // Returns the start address of the first page of the space. 1810 // Returns the start address of the first page of the space.
1814 Address space_start() { 1811 Address space_start() {
1815 ASSERT(anchor_.next_page() != &anchor_); 1812 ASSERT(anchor_.next_page() != &anchor_);
1816 return anchor_.next_page()->body(); 1813 return anchor_.next_page()->body();
1817 } 1814 }
1818 1815
1819 // Returns the start address of the current page of the space. 1816 // Returns the start address of the current page of the space.
1820 Address page_low() { 1817 Address page_low() {
1821 ASSERT(anchor_.next_page() != &anchor_);
1822 return current_page_->body(); 1818 return current_page_->body();
1823 } 1819 }
1824 1820
1825 // Returns one past the end address of the space. 1821 // Returns one past the end address of the space.
1826 Address space_end() { 1822 Address space_end() {
1827 return anchor_.prev_page()->body_limit(); 1823 return anchor_.prev_page()->body_limit();
1828 } 1824 }
1829 1825
1830 // Returns one past the end address of the current page of the space. 1826 // Returns one past the end address of the current page of the space.
1831 Address page_high() { 1827 Address page_high() {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 static_cast<int>(top() - to_space_.page_low()); 2073 static_cast<int>(top() - to_space_.page_low());
2078 } 2074 }
2079 2075
2080 // The same, but returning an int. We have to have the one that returns 2076 // The same, but returning an int. We have to have the one that returns
2081 // intptr_t because it is inherited, but if we know we are dealing with the 2077 // intptr_t because it is inherited, but if we know we are dealing with the
2082 // new space, which can't get as big as the other spaces then this is useful: 2078 // new space, which can't get as big as the other spaces then this is useful:
2083 int SizeAsInt() { return static_cast<int>(Size()); } 2079 int SizeAsInt() { return static_cast<int>(Size()); }
2084 2080
2085 // Return the current capacity of a semispace. 2081 // Return the current capacity of a semispace.
2086 intptr_t EffectiveCapacity() { 2082 intptr_t EffectiveCapacity() {
2087 ASSERT(to_space_.Capacity() == from_space_.Capacity()); 2083 SLOW_ASSERT(to_space_.Capacity() == from_space_.Capacity());
2088 return (to_space_.Capacity() / Page::kPageSize) * Page::kObjectAreaSize; 2084 return (to_space_.Capacity() / Page::kPageSize) * Page::kObjectAreaSize;
2089 } 2085 }
2090 2086
2091 // Return the current capacity of a semispace. 2087 // Return the current capacity of a semispace.
2092 intptr_t Capacity() { 2088 intptr_t Capacity() {
2093 ASSERT(to_space_.Capacity() == from_space_.Capacity()); 2089 ASSERT(to_space_.Capacity() == from_space_.Capacity());
2094 return to_space_.Capacity(); 2090 return to_space_.Capacity();
2095 } 2091 }
2096 2092
2097 // Return the total amount of memory committed for new space. 2093 // Return the total amount of memory committed for new space.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 } 2306 }
2311 2307
2312 public: 2308 public:
2313 TRACK_MEMORY("OldSpace") 2309 TRACK_MEMORY("OldSpace")
2314 }; 2310 };
2315 2311
2316 2312
2317 // For contiguous spaces, top should be in the space (or at the end) and limit 2313 // For contiguous spaces, top should be in the space (or at the end) and limit
2318 // should be the end of the space. 2314 // should be the end of the space.
2319 #define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \ 2315 #define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \
2320 ASSERT((space).page_low() <= (info).top \ 2316 SLOW_ASSERT((space).page_low() <= (info).top \
2321 && (info).top <= (space).page_high() \ 2317 && (info).top <= (space).page_high() \
2322 && (info).limit <= (space).page_high()) 2318 && (info).limit <= (space).page_high())
2323 2319
2324 2320
2325 // ----------------------------------------------------------------------------- 2321 // -----------------------------------------------------------------------------
2326 // Old space for objects of a fixed size 2322 // Old space for objects of a fixed size
2327 2323
2328 class FixedSpace : public PagedSpace { 2324 class FixedSpace : public PagedSpace {
2329 public: 2325 public:
2330 FixedSpace(Heap* heap, 2326 FixedSpace(Heap* heap,
2331 intptr_t max_capacity, 2327 intptr_t max_capacity,
2332 AllocationSpace id, 2328 AllocationSpace id,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 } 2615 }
2620 // Must be small, since an iteration is used for lookup. 2616 // Must be small, since an iteration is used for lookup.
2621 static const int kMaxComments = 64; 2617 static const int kMaxComments = 64;
2622 }; 2618 };
2623 #endif 2619 #endif
2624 2620
2625 2621
2626 } } // namespace v8::internal 2622 } } // namespace v8::internal
2627 2623
2628 #endif // V8_SPACES_H_ 2624 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698