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 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 | 1511 |
1512 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeListNode); | 1512 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeListNode); |
1513 }; | 1513 }; |
1514 | 1514 |
1515 | 1515 |
1516 // The free list category holds a pointer to the top element and a pointer to | 1516 // The free list category holds a pointer to the top element and a pointer to |
1517 // the end element of the linked list of free memory blocks. | 1517 // the end element of the linked list of free memory blocks. |
1518 class FreeListCategory { | 1518 class FreeListCategory { |
1519 public: | 1519 public: |
1520 FreeListCategory() : | 1520 FreeListCategory() : |
1521 top_(NULL), | 1521 top_(0), |
1522 end_(NULL), | 1522 end_(NULL), |
1523 available_(0) {} | 1523 available_(0) {} |
1524 | 1524 |
1525 intptr_t Concatenate(FreeListCategory* category); | 1525 intptr_t Concatenate(FreeListCategory* category); |
1526 | 1526 |
1527 void Reset(); | 1527 void Reset(); |
1528 | 1528 |
1529 void Free(FreeListNode* node, int size_in_bytes); | 1529 void Free(FreeListNode* node, int size_in_bytes); |
1530 | 1530 |
1531 FreeListNode* PickNodeFromList(int *node_size); | 1531 FreeListNode* PickNodeFromList(int *node_size); |
1532 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size); | 1532 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size); |
1533 | 1533 |
1534 intptr_t EvictFreeListItemsInList(Page* p); | 1534 intptr_t EvictFreeListItemsInList(Page* p); |
1535 bool ContainsPageFreeListItemsInList(Page* p); | 1535 bool ContainsPageFreeListItemsInList(Page* p); |
1536 | 1536 |
1537 void RepairFreeList(Heap* heap); | 1537 void RepairFreeList(Heap* heap); |
1538 | 1538 |
1539 FreeListNode** GetTopAddress() { return &top_; } | 1539 FreeListNode* top() const { |
1540 FreeListNode* top() const { return top_; } | 1540 return reinterpret_cast<FreeListNode*>(NoBarrier_Load(&top_)); |
1541 void set_top(FreeListNode* top) { top_ = top; } | 1541 } |
| 1542 |
| 1543 void set_top(FreeListNode* top) { |
| 1544 NoBarrier_Store(&top_, reinterpret_cast<AtomicWord>(top)); |
| 1545 } |
1542 | 1546 |
1543 FreeListNode** GetEndAddress() { return &end_; } | 1547 FreeListNode** GetEndAddress() { return &end_; } |
1544 FreeListNode* end() const { return end_; } | 1548 FreeListNode* end() const { return end_; } |
1545 void set_end(FreeListNode* end) { end_ = end; } | 1549 void set_end(FreeListNode* end) { end_ = end; } |
1546 | 1550 |
1547 int* GetAvailableAddress() { return &available_; } | 1551 int* GetAvailableAddress() { return &available_; } |
1548 int available() const { return available_; } | 1552 int available() const { return available_; } |
1549 void set_available(int available) { available_ = available; } | 1553 void set_available(int available) { available_ = available; } |
1550 | 1554 |
1551 Mutex* mutex() { return &mutex_; } | 1555 Mutex* mutex() { return &mutex_; } |
1552 | 1556 |
1553 bool IsEmpty() { | 1557 bool IsEmpty() { |
1554 return top_ == NULL; | 1558 return top() == 0; |
1555 } | 1559 } |
1556 | 1560 |
1557 #ifdef DEBUG | 1561 #ifdef DEBUG |
1558 intptr_t SumFreeList(); | 1562 intptr_t SumFreeList(); |
1559 int FreeListLength(); | 1563 int FreeListLength(); |
1560 #endif | 1564 #endif |
1561 | 1565 |
1562 private: | 1566 private: |
1563 FreeListNode* top_; | 1567 // top_ points to the top FreeListNode* in the free list category. |
| 1568 AtomicWord top_; |
1564 FreeListNode* end_; | 1569 FreeListNode* end_; |
1565 Mutex mutex_; | 1570 Mutex mutex_; |
1566 | 1571 |
1567 // Total available bytes in all blocks of this free list category. | 1572 // Total available bytes in all blocks of this free list category. |
1568 int available_; | 1573 int available_; |
1569 }; | 1574 }; |
1570 | 1575 |
1571 | 1576 |
1572 // The free list for the old space. The free list is organized in such a way | 1577 // The free list for the old space. The free list is organized in such a way |
1573 // as to encourage objects allocated around the same time to be near each | 1578 // as to encourage objects allocated around the same time to be near each |
(...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2957 } | 2962 } |
2958 // Must be small, since an iteration is used for lookup. | 2963 // Must be small, since an iteration is used for lookup. |
2959 static const int kMaxComments = 64; | 2964 static const int kMaxComments = 64; |
2960 }; | 2965 }; |
2961 #endif | 2966 #endif |
2962 | 2967 |
2963 | 2968 |
2964 } } // namespace v8::internal | 2969 } } // namespace v8::internal |
2965 | 2970 |
2966 #endif // V8_SPACES_H_ | 2971 #endif // V8_SPACES_H_ |
OLD | NEW |