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

Side by Side Diff: src/spaces.h

Issue 143633007: A64: Synchronize with r18764. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/scopes.cc ('k') | src/spaces.cc » ('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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 intptr_t Concatenate(FreeListCategory* category); 1514 intptr_t Concatenate(FreeListCategory* category);
1515 1515
1516 void Reset(); 1516 void Reset();
1517 1517
1518 void Free(FreeListNode* node, int size_in_bytes); 1518 void Free(FreeListNode* node, int size_in_bytes);
1519 1519
1520 FreeListNode* PickNodeFromList(int *node_size); 1520 FreeListNode* PickNodeFromList(int *node_size);
1521 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size); 1521 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size);
1522 1522
1523 intptr_t EvictFreeListItemsInList(Page* p); 1523 intptr_t EvictFreeListItemsInList(Page* p);
1524 bool ContainsPageFreeListItemsInList(Page* p);
1524 1525
1525 void RepairFreeList(Heap* heap); 1526 void RepairFreeList(Heap* heap);
1526 1527
1527 FreeListNode** GetTopAddress() { return &top_; } 1528 FreeListNode** GetTopAddress() { return &top_; }
1528 FreeListNode* top() const { return top_; } 1529 FreeListNode* top() const { return top_; }
1529 void set_top(FreeListNode* top) { top_ = top; } 1530 void set_top(FreeListNode* top) { top_ = top; }
1530 1531
1531 FreeListNode** GetEndAddress() { return &end_; } 1532 FreeListNode** GetEndAddress() { return &end_; }
1532 FreeListNode* end() const { return end_; } 1533 FreeListNode* end() const { return end_; }
1533 void set_end(FreeListNode* end) { end_ = end; } 1534 void set_end(FreeListNode* end) { end_ = end; }
1534 1535
1535 int* GetAvailableAddress() { return &available_; } 1536 int* GetAvailableAddress() { return &available_; }
1536 int available() const { return available_; } 1537 int available() const { return available_; }
1537 void set_available(int available) { available_ = available; } 1538 void set_available(int available) { available_ = available; }
1538 1539
1539 Mutex* mutex() { return &mutex_; } 1540 Mutex* mutex() { return &mutex_; }
1540 1541
1542 bool IsEmpty() {
1543 return top_ == NULL;
1544 }
1545
1541 #ifdef DEBUG 1546 #ifdef DEBUG
1542 intptr_t SumFreeList(); 1547 intptr_t SumFreeList();
1543 int FreeListLength(); 1548 int FreeListLength();
1544 #endif 1549 #endif
1545 1550
1546 private: 1551 private:
1547 FreeListNode* top_; 1552 FreeListNode* top_;
1548 FreeListNode* end_; 1553 FreeListNode* end_;
1549 Mutex mutex_; 1554 Mutex mutex_;
1550 1555
(...skipping 18 matching lines...) Expand all
1569 // limit when the object we need to allocate is 1-31 words in size. These 1574 // limit when the object we need to allocate is 1-31 words in size. These
1570 // spaces are called small. 1575 // spaces are called small.
1571 // 256-2047 words: There is a list of spaces this large. It is used for top and 1576 // 256-2047 words: There is a list of spaces this large. It is used for top and
1572 // limit when the object we need to allocate is 32-255 words in size. These 1577 // limit when the object we need to allocate is 32-255 words in size. These
1573 // spaces are called medium. 1578 // spaces are called medium.
1574 // 1048-16383 words: There is a list of spaces this large. It is used for top 1579 // 1048-16383 words: There is a list of spaces this large. It is used for top
1575 // and limit when the object we need to allocate is 256-2047 words in size. 1580 // and limit when the object we need to allocate is 256-2047 words in size.
1576 // These spaces are call large. 1581 // These spaces are call large.
1577 // At least 16384 words. This list is for objects of 2048 words or larger. 1582 // At least 16384 words. This list is for objects of 2048 words or larger.
1578 // Empty pages are added to this list. These spaces are called huge. 1583 // Empty pages are added to this list. These spaces are called huge.
1579 class FreeList BASE_EMBEDDED { 1584 class FreeList {
1580 public: 1585 public:
1581 explicit FreeList(PagedSpace* owner); 1586 explicit FreeList(PagedSpace* owner);
1582 1587
1583 intptr_t Concatenate(FreeList* free_list); 1588 intptr_t Concatenate(FreeList* free_list);
1584 1589
1585 // Clear the free list. 1590 // Clear the free list.
1586 void Reset(); 1591 void Reset();
1587 1592
1588 // Return the number of bytes available on the free list. 1593 // Return the number of bytes available on the free list.
1589 intptr_t available() { 1594 intptr_t available() {
1590 return small_list_.available() + medium_list_.available() + 1595 return small_list_.available() + medium_list_.available() +
1591 large_list_.available() + huge_list_.available(); 1596 large_list_.available() + huge_list_.available();
1592 } 1597 }
1593 1598
1594 // Place a node on the free list. The block of size 'size_in_bytes' 1599 // Place a node on the free list. The block of size 'size_in_bytes'
1595 // starting at 'start' is placed on the free list. The return value is the 1600 // starting at 'start' is placed on the free list. The return value is the
1596 // number of bytes that have been lost due to internal fragmentation by 1601 // number of bytes that have been lost due to internal fragmentation by
1597 // freeing the block. Bookkeeping information will be written to the block, 1602 // freeing the block. Bookkeeping information will be written to the block,
1598 // i.e., its contents will be destroyed. The start address should be word 1603 // i.e., its contents will be destroyed. The start address should be word
1599 // aligned, and the size should be a non-zero multiple of the word size. 1604 // aligned, and the size should be a non-zero multiple of the word size.
1600 int Free(Address start, int size_in_bytes); 1605 int Free(Address start, int size_in_bytes);
1601 1606
1602 // Allocate a block of size 'size_in_bytes' from the free list. The block 1607 // Allocate a block of size 'size_in_bytes' from the free list. The block
1603 // is unitialized. A failure is returned if no block is available. The 1608 // is unitialized. A failure is returned if no block is available. The
1604 // number of bytes lost to fragmentation is returned in the output parameter 1609 // number of bytes lost to fragmentation is returned in the output parameter
1605 // 'wasted_bytes'. The size should be a non-zero multiple of the word size. 1610 // 'wasted_bytes'. The size should be a non-zero multiple of the word size.
1606 MUST_USE_RESULT HeapObject* Allocate(int size_in_bytes); 1611 MUST_USE_RESULT HeapObject* Allocate(int size_in_bytes);
1607 1612
1613 bool IsEmpty() {
1614 return small_list_.IsEmpty() && medium_list_.IsEmpty() &&
1615 large_list_.IsEmpty() && huge_list_.IsEmpty();
1616 }
1617
1608 #ifdef DEBUG 1618 #ifdef DEBUG
1609 void Zap(); 1619 void Zap();
1610 intptr_t SumFreeLists(); 1620 intptr_t SumFreeLists();
1611 bool IsVeryLong(); 1621 bool IsVeryLong();
1612 #endif 1622 #endif
1613 1623
1614 // Used after booting the VM. 1624 // Used after booting the VM.
1615 void RepairLists(Heap* heap); 1625 void RepairLists(Heap* heap);
1616 1626
1617 intptr_t EvictFreeListItems(Page* p); 1627 intptr_t EvictFreeListItems(Page* p);
1628 bool ContainsPageFreeListItems(Page* p);
1618 1629
1619 FreeListCategory* small_list() { return &small_list_; } 1630 FreeListCategory* small_list() { return &small_list_; }
1620 FreeListCategory* medium_list() { return &medium_list_; } 1631 FreeListCategory* medium_list() { return &medium_list_; }
1621 FreeListCategory* large_list() { return &large_list_; } 1632 FreeListCategory* large_list() { return &large_list_; }
1622 FreeListCategory* huge_list() { return &huge_list_; } 1633 FreeListCategory* huge_list() { return &huge_list_; }
1623 1634
1624 private: 1635 private:
1625 // The size range of blocks, in bytes. 1636 // The size range of blocks, in bytes.
1626 static const int kMinBlockSize = 3 * kPointerSize; 1637 static const int kMinBlockSize = 3 * kPointerSize;
1627 static const int kMaxBlockSize = Page::kMaxNonCodeHeapObjectSize; 1638 static const int kMaxBlockSize = Page::kMaxNonCodeHeapObjectSize;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 bool Expand(); 1949 bool Expand();
1939 1950
1940 // Generic fast case allocation function that tries linear allocation at the 1951 // Generic fast case allocation function that tries linear allocation at the
1941 // address denoted by top in allocation_info_. 1952 // address denoted by top in allocation_info_.
1942 inline HeapObject* AllocateLinearly(int size_in_bytes); 1953 inline HeapObject* AllocateLinearly(int size_in_bytes);
1943 1954
1944 // Slow path of AllocateRaw. This function is space-dependent. 1955 // Slow path of AllocateRaw. This function is space-dependent.
1945 MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes); 1956 MUST_USE_RESULT virtual HeapObject* SlowAllocateRaw(int size_in_bytes);
1946 1957
1947 friend class PageIterator; 1958 friend class PageIterator;
1948 friend class SweeperThread; 1959 friend class MarkCompactCollector;
1949 }; 1960 };
1950 1961
1951 1962
1952 class NumberAndSizeInfo BASE_EMBEDDED { 1963 class NumberAndSizeInfo BASE_EMBEDDED {
1953 public: 1964 public:
1954 NumberAndSizeInfo() : number_(0), bytes_(0) {} 1965 NumberAndSizeInfo() : number_(0), bytes_(0) {}
1955 1966
1956 int number() const { return number_; } 1967 int number() const { return number_; }
1957 void increment_number(int num) { number_ += num; } 1968 void increment_number(int num) { number_ += num; }
1958 1969
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 } 2934 }
2924 // Must be small, since an iteration is used for lookup. 2935 // Must be small, since an iteration is used for lookup.
2925 static const int kMaxComments = 64; 2936 static const int kMaxComments = 64;
2926 }; 2937 };
2927 #endif 2938 #endif
2928 2939
2929 2940
2930 } } // namespace v8::internal 2941 } } // namespace v8::internal
2931 2942
2932 #endif // V8_SPACES_H_ 2943 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/scopes.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698