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