| 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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 // Give a block of memory to the space's free list. It might be added to | 1513 // Give a block of memory to the space's free list. It might be added to |
| 1514 // the free list or accounted as waste. | 1514 // the free list or accounted as waste. |
| 1515 // If add_to_freelist is false then just accounting stats are updated and | 1515 // If add_to_freelist is false then just accounting stats are updated and |
| 1516 // no attempt to add area to free list is made. | 1516 // no attempt to add area to free list is made. |
| 1517 int Free(Address start, int size_in_bytes) { | 1517 int Free(Address start, int size_in_bytes) { |
| 1518 int wasted = free_list_.Free(start, size_in_bytes); | 1518 int wasted = free_list_.Free(start, size_in_bytes); |
| 1519 accounting_stats_.DeallocateBytes(size_in_bytes - wasted); | 1519 accounting_stats_.DeallocateBytes(size_in_bytes - wasted); |
| 1520 return size_in_bytes - wasted; | 1520 return size_in_bytes - wasted; |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 void ResetFreeList() { |
| 1524 free_list_.Reset(); |
| 1525 } |
| 1526 |
| 1523 // Set space allocation info. | 1527 // Set space allocation info. |
| 1524 void SetTop(Address top, Address limit) { | 1528 void SetTop(Address top, Address limit) { |
| 1525 ASSERT(top == limit || | 1529 ASSERT(top == limit || |
| 1526 Page::FromAddress(top) == Page::FromAddress(limit - 1)); | 1530 Page::FromAddress(top) == Page::FromAddress(limit - 1)); |
| 1527 allocation_info_.top = top; | 1531 allocation_info_.top = top; |
| 1528 allocation_info_.limit = limit; | 1532 allocation_info_.limit = limit; |
| 1529 } | 1533 } |
| 1530 | 1534 |
| 1531 void Allocate(int bytes) { | 1535 void Allocate(int bytes) { |
| 1532 accounting_stats_.AllocateBytes(bytes); | 1536 accounting_stats_.AllocateBytes(bytes); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2364 // The limit of allocation for a page in this space. | 2368 // The limit of allocation for a page in this space. |
| 2365 virtual Address PageAllocationLimit(Page* page) { | 2369 virtual Address PageAllocationLimit(Page* page) { |
| 2366 return page->area_end() - page_extra_; | 2370 return page->area_end() - page_extra_; |
| 2367 } | 2371 } |
| 2368 | 2372 |
| 2369 int object_size_in_bytes() { return object_size_in_bytes_; } | 2373 int object_size_in_bytes() { return object_size_in_bytes_; } |
| 2370 | 2374 |
| 2371 // Prepares for a mark-compact GC. | 2375 // Prepares for a mark-compact GC. |
| 2372 virtual void PrepareForMarkCompact(); | 2376 virtual void PrepareForMarkCompact(); |
| 2373 | 2377 |
| 2374 protected: | |
| 2375 void ResetFreeList() { | |
| 2376 free_list_.Reset(); | |
| 2377 } | |
| 2378 | |
| 2379 private: | 2378 private: |
| 2380 // The size of objects in this space. | 2379 // The size of objects in this space. |
| 2381 int object_size_in_bytes_; | 2380 int object_size_in_bytes_; |
| 2382 | 2381 |
| 2383 // The name of this space. | 2382 // The name of this space. |
| 2384 const char* name_; | 2383 const char* name_; |
| 2385 }; | 2384 }; |
| 2386 | 2385 |
| 2387 | 2386 |
| 2388 // ----------------------------------------------------------------------------- | 2387 // ----------------------------------------------------------------------------- |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2640 } | 2639 } |
| 2641 // Must be small, since an iteration is used for lookup. | 2640 // Must be small, since an iteration is used for lookup. |
| 2642 static const int kMaxComments = 64; | 2641 static const int kMaxComments = 64; |
| 2643 }; | 2642 }; |
| 2644 #endif | 2643 #endif |
| 2645 | 2644 |
| 2646 | 2645 |
| 2647 } } // namespace v8::internal | 2646 } } // namespace v8::internal |
| 2648 | 2647 |
| 2649 #endif // V8_SPACES_H_ | 2648 #endif // V8_SPACES_H_ |
| OLD | NEW |