Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1567 | 1567 |
| 1568 // Releases an unused page and shrinks the space. | 1568 // Releases an unused page and shrinks the space. |
| 1569 void ReleasePage(Page* page); | 1569 void ReleasePage(Page* page); |
| 1570 | 1570 |
| 1571 // Releases all of the unused pages. | 1571 // Releases all of the unused pages. |
| 1572 void ReleaseAllUnusedPages(); | 1572 void ReleaseAllUnusedPages(); |
| 1573 | 1573 |
| 1574 // The dummy page that anchors the linked list of pages. | 1574 // The dummy page that anchors the linked list of pages. |
| 1575 Page* anchor() { return &anchor_; } | 1575 Page* anchor() { return &anchor_; } |
| 1576 | 1576 |
| 1577 // Verify integrity of this space. | |
| 1578 virtual void Verify(ObjectVisitor* visitor); | |
| 1579 | |
| 1580 // Overridden by subclasses to verify space-specific object | |
| 1581 // properties (e.g., only maps or free-list nodes are in map space). | |
| 1582 virtual void VerifyObject(HeapObject* obj) {} | |
| 1583 | |
| 1577 #ifdef DEBUG | 1584 #ifdef DEBUG |
| 1578 // Print meta info and objects in this space. | 1585 // Print meta info and objects in this space. |
| 1579 virtual void Print(); | 1586 virtual void Print(); |
| 1580 | 1587 |
| 1581 // Verify integrity of this space. | |
| 1582 virtual void Verify(ObjectVisitor* visitor); | |
| 1583 | |
| 1584 // Reports statistics for the space | 1588 // Reports statistics for the space |
| 1585 void ReportStatistics(); | 1589 void ReportStatistics(); |
| 1586 | 1590 |
| 1587 // Overridden by subclasses to verify space-specific object | |
| 1588 // properties (e.g., only maps or free-list nodes are in map space). | |
| 1589 virtual void VerifyObject(HeapObject* obj) {} | |
| 1590 | |
| 1591 // Report code object related statistics | 1591 // Report code object related statistics |
| 1592 void CollectCodeStatistics(); | 1592 void CollectCodeStatistics(); |
| 1593 static void ReportCodeStatistics(); | 1593 static void ReportCodeStatistics(); |
| 1594 static void ResetCodeStatistics(); | 1594 static void ResetCodeStatistics(); |
| 1595 #endif | 1595 #endif |
| 1596 | 1596 |
| 1597 bool was_swept_conservatively() { return was_swept_conservatively_; } | 1597 bool was_swept_conservatively() { return was_swept_conservatively_; } |
| 1598 void set_was_swept_conservatively(bool b) { was_swept_conservatively_ = b; } | 1598 void set_was_swept_conservatively(bool b) { was_swept_conservatively_ = b; } |
| 1599 | 1599 |
| 1600 // Evacuation candidates are swept by evacuator. Needs to return a valid | 1600 // Evacuation candidates are swept by evacuator. Needs to return a valid |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1927 return false; | 1927 return false; |
| 1928 } | 1928 } |
| 1929 | 1929 |
| 1930 bool is_committed() { return committed_; } | 1930 bool is_committed() { return committed_; } |
| 1931 bool Commit(); | 1931 bool Commit(); |
| 1932 bool Uncommit(); | 1932 bool Uncommit(); |
| 1933 | 1933 |
| 1934 NewSpacePage* first_page() { return anchor_.next_page(); } | 1934 NewSpacePage* first_page() { return anchor_.next_page(); } |
| 1935 NewSpacePage* current_page() { return current_page_; } | 1935 NewSpacePage* current_page() { return current_page_; } |
| 1936 | 1936 |
| 1937 virtual void Verify(); | |
| 1938 | |
| 1937 #ifdef DEBUG | 1939 #ifdef DEBUG |
| 1938 virtual void Print(); | 1940 virtual void Print(); |
| 1939 virtual void Verify(); | |
| 1940 // Validate a range of of addresses in a SemiSpace. | 1941 // Validate a range of of addresses in a SemiSpace. |
| 1941 // The "from" address must be on a page prior to the "to" address, | 1942 // The "from" address must be on a page prior to the "to" address, |
| 1942 // in the linked page order, or it must be earlier on the same page. | 1943 // in the linked page order, or it must be earlier on the same page. |
| 1943 static void AssertValidRange(Address from, Address to); | 1944 static void AssertValidRange(Address from, Address to); |
| 1944 #else | 1945 #else |
| 1945 // Do nothing. | 1946 // Do nothing. |
| 1946 inline static void AssertValidRange(Address from, Address to) {} | 1947 inline static void AssertValidRange(Address from, Address to) {} |
| 1947 #endif | 1948 #endif |
| 1948 | 1949 |
| 1949 // Returns the current capacity of the semi space. | 1950 // Returns the current capacity of the semi space. |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2254 // if successful. | 2255 // if successful. |
| 2255 bool AddFreshPage(); | 2256 bool AddFreshPage(); |
| 2256 | 2257 |
| 2257 virtual bool ReserveSpace(int bytes); | 2258 virtual bool ReserveSpace(int bytes); |
| 2258 | 2259 |
| 2259 // Resizes a sequential string which must be the most recent thing that was | 2260 // Resizes a sequential string which must be the most recent thing that was |
| 2260 // allocated in new space. | 2261 // allocated in new space. |
| 2261 template <typename StringType> | 2262 template <typename StringType> |
| 2262 inline void ShrinkStringAtAllocationBoundary(String* string, int len); | 2263 inline void ShrinkStringAtAllocationBoundary(String* string, int len); |
| 2263 | 2264 |
| 2264 #ifdef DEBUG | |
| 2265 // Verify the active semispace. | 2265 // Verify the active semispace. |
| 2266 virtual void Verify(); | 2266 virtual void Verify(); |
| 2267 | |
| 2268 #ifdef DEBUG | |
| 2267 // Print the active semispace. | 2269 // Print the active semispace. |
| 2268 virtual void Print() { to_space_.Print(); } | 2270 virtual void Print() { to_space_.Print(); } |
| 2269 #endif | 2271 #endif |
| 2270 | 2272 |
| 2271 // Iterates the active semispace to collect statistics. | 2273 // Iterates the active semispace to collect statistics. |
| 2272 void CollectStatistics(); | 2274 void CollectStatistics(); |
| 2273 // Reports previously collected statistics of the active semispace. | 2275 // Reports previously collected statistics of the active semispace. |
| 2274 void ReportStatistics(); | 2276 void ReportStatistics(); |
| 2275 // Clears previously collected statistics. | 2277 // Clears previously collected statistics. |
| 2276 void ClearHistograms(); | 2278 void ClearHistograms(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2426 | 2428 |
| 2427 virtual int RoundSizeDownToObjectAlignment(int size) { | 2429 virtual int RoundSizeDownToObjectAlignment(int size) { |
| 2428 if (IsPowerOf2(Map::kSize)) { | 2430 if (IsPowerOf2(Map::kSize)) { |
| 2429 return RoundDown(size, Map::kSize); | 2431 return RoundDown(size, Map::kSize); |
| 2430 } else { | 2432 } else { |
| 2431 return (size / Map::kSize) * Map::kSize; | 2433 return (size / Map::kSize) * Map::kSize; |
| 2432 } | 2434 } |
| 2433 } | 2435 } |
| 2434 | 2436 |
| 2435 protected: | 2437 protected: |
| 2436 #ifdef DEBUG | |
| 2437 virtual void VerifyObject(HeapObject* obj); | 2438 virtual void VerifyObject(HeapObject* obj); |
| 2438 #endif | |
| 2439 | 2439 |
| 2440 private: | 2440 private: |
| 2441 static const int kMapsPerPage = Page::kNonCodeObjectAreaSize / Map::kSize; | 2441 static const int kMapsPerPage = Page::kNonCodeObjectAreaSize / Map::kSize; |
| 2442 | 2442 |
| 2443 // Do map space compaction if there is a page gap. | 2443 // Do map space compaction if there is a page gap. |
| 2444 int CompactionThreshold() { | 2444 int CompactionThreshold() { |
| 2445 return kMapsPerPage * (max_map_space_pages_ - 1); | 2445 return kMapsPerPage * (max_map_space_pages_ - 1); |
| 2446 } | 2446 } |
| 2447 | 2447 |
| 2448 const int max_map_space_pages_; | 2448 const int max_map_space_pages_; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2464 | 2464 |
| 2465 virtual int RoundSizeDownToObjectAlignment(int size) { | 2465 virtual int RoundSizeDownToObjectAlignment(int size) { |
| 2466 if (IsPowerOf2(JSGlobalPropertyCell::kSize)) { | 2466 if (IsPowerOf2(JSGlobalPropertyCell::kSize)) { |
| 2467 return RoundDown(size, JSGlobalPropertyCell::kSize); | 2467 return RoundDown(size, JSGlobalPropertyCell::kSize); |
| 2468 } else { | 2468 } else { |
| 2469 return (size / JSGlobalPropertyCell::kSize) * JSGlobalPropertyCell::kSize; | 2469 return (size / JSGlobalPropertyCell::kSize) * JSGlobalPropertyCell::kSize; |
| 2470 } | 2470 } |
| 2471 } | 2471 } |
| 2472 | 2472 |
| 2473 protected: | 2473 protected: |
| 2474 #ifdef DEBUG | |
| 2475 virtual void VerifyObject(HeapObject* obj); | 2474 virtual void VerifyObject(HeapObject* obj); |
| 2476 #endif | |
| 2477 | 2475 |
| 2478 public: | 2476 public: |
| 2479 TRACK_MEMORY("CellSpace") | 2477 TRACK_MEMORY("CellSpace") |
| 2480 }; | 2478 }; |
| 2481 | 2479 |
| 2482 | 2480 |
| 2483 // ----------------------------------------------------------------------------- | 2481 // ----------------------------------------------------------------------------- |
| 2484 // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by | 2482 // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by |
| 2485 // the large object space. A large object is allocated from OS heap with | 2483 // the large object space. A large object is allocated from OS heap with |
| 2486 // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset). | 2484 // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset). |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2545 // Checks whether the space is empty. | 2543 // Checks whether the space is empty. |
| 2546 bool IsEmpty() { return first_page_ == NULL; } | 2544 bool IsEmpty() { return first_page_ == NULL; } |
| 2547 | 2545 |
| 2548 // See the comments for ReserveSpace in the Space class. This has to be | 2546 // See the comments for ReserveSpace in the Space class. This has to be |
| 2549 // called after ReserveSpace has been called on the paged spaces, since they | 2547 // called after ReserveSpace has been called on the paged spaces, since they |
| 2550 // may use some memory, leaving less for large objects. | 2548 // may use some memory, leaving less for large objects. |
| 2551 virtual bool ReserveSpace(int bytes); | 2549 virtual bool ReserveSpace(int bytes); |
| 2552 | 2550 |
| 2553 LargePage* first_page() { return first_page_; } | 2551 LargePage* first_page() { return first_page_; } |
| 2554 | 2552 |
| 2553 virtual void Verify(); | |
|
Michael Starzinger
2012/10/11 12:42:46
Empty newline after declaration.
mvstanton1
2012/10/12 08:40:50
Done.
| |
| 2555 #ifdef DEBUG | 2554 #ifdef DEBUG |
| 2556 virtual void Verify(); | |
| 2557 virtual void Print(); | 2555 virtual void Print(); |
| 2558 void ReportStatistics(); | 2556 void ReportStatistics(); |
| 2559 void CollectCodeStatistics(); | 2557 void CollectCodeStatistics(); |
| 2560 #endif | 2558 #endif |
| 2561 // Checks whether an address is in the object area in this space. It | 2559 // Checks whether an address is in the object area in this space. It |
| 2562 // iterates all objects in the space. May be slow. | 2560 // iterates all objects in the space. May be slow. |
| 2563 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); } | 2561 bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); } |
| 2564 | 2562 |
| 2565 private: | 2563 private: |
| 2566 intptr_t max_capacity_; | 2564 intptr_t max_capacity_; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2668 } | 2666 } |
| 2669 // Must be small, since an iteration is used for lookup. | 2667 // Must be small, since an iteration is used for lookup. |
| 2670 static const int kMaxComments = 64; | 2668 static const int kMaxComments = 64; |
| 2671 }; | 2669 }; |
| 2672 #endif | 2670 #endif |
| 2673 | 2671 |
| 2674 | 2672 |
| 2675 } } // namespace v8::internal | 2673 } } // namespace v8::internal |
| 2676 | 2674 |
| 2677 #endif // V8_SPACES_H_ | 2675 #endif // V8_SPACES_H_ |
| OLD | NEW |