| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
| 10 #include "src/heap/slots-buffer.h" | 10 #include "src/heap/slots-buffer.h" |
| (...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2085 | 2085 |
| 2086 | 2086 |
| 2087 void FreeListCategory::Reset() { | 2087 void FreeListCategory::Reset() { |
| 2088 set_top(nullptr); | 2088 set_top(nullptr); |
| 2089 set_end(nullptr); | 2089 set_end(nullptr); |
| 2090 available_ = 0; | 2090 available_ = 0; |
| 2091 } | 2091 } |
| 2092 | 2092 |
| 2093 | 2093 |
| 2094 intptr_t FreeListCategory::EvictFreeListItemsInList(Page* p) { | 2094 intptr_t FreeListCategory::EvictFreeListItemsInList(Page* p) { |
| 2095 int sum = 0; | 2095 intptr_t sum = 0; |
| 2096 FreeSpace* t = top(); | 2096 FreeSpace* prev_node = nullptr; |
| 2097 FreeSpace** n = &t; | 2097 for (FreeSpace* cur_node = top(); cur_node != nullptr; |
| 2098 while (*n != NULL) { | 2098 cur_node = cur_node->next()) { |
| 2099 if (Page::FromAddress((*n)->address()) == p) { | 2099 Page* page_for_node = Page::FromAddress(cur_node->address()); |
| 2100 FreeSpace* free_space = *n; | 2100 if (page_for_node == p) { |
| 2101 sum += free_space->Size(); | 2101 // FreeSpace node on eviction page found, unlink it. |
| 2102 *n = (*n)->next(); | 2102 int size = cur_node->size(); |
| 2103 } else { | 2103 sum += size; |
| 2104 n = (*n)->next_address(); | 2104 DCHECK((prev_node != nullptr) || (top() == cur_node)); |
| 2105 if (cur_node == top()) { |
| 2106 set_top(cur_node->next()); |
| 2107 } |
| 2108 if (cur_node == end()) { |
| 2109 set_end(prev_node); |
| 2110 } |
| 2111 if (prev_node != nullptr) { |
| 2112 prev_node->set_next(cur_node->next()); |
| 2113 } |
| 2114 continue; |
| 2105 } | 2115 } |
| 2116 prev_node = cur_node; |
| 2106 } | 2117 } |
| 2107 set_top(t); | 2118 DCHECK_EQ(p->available_in_free_list(type_), sum); |
| 2108 if (top() == NULL) { | 2119 p->add_available_in_free_list(type_, -sum); |
| 2109 set_end(NULL); | |
| 2110 } | |
| 2111 available_ -= sum; | 2120 available_ -= sum; |
| 2112 return sum; | 2121 return sum; |
| 2113 } | 2122 } |
| 2114 | 2123 |
| 2115 | 2124 |
| 2116 bool FreeListCategory::ContainsPageFreeListItemsInList(Page* p) { | 2125 bool FreeListCategory::ContainsPageFreeListItemsInList(Page* p) { |
| 2117 FreeSpace* node = top(); | 2126 FreeSpace* node = top(); |
| 2118 while (node != NULL) { | 2127 while (node != NULL) { |
| 2119 if (Page::FromAddress(node->address()) == p) return true; | 2128 if (Page::FromAddress(node->address()) == p) return true; |
| 2120 node = node->next(); | 2129 node = node->next(); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2439 owner_->SetTopAndLimit(new_node->address() + size_in_bytes, | 2448 owner_->SetTopAndLimit(new_node->address() + size_in_bytes, |
| 2440 new_node->address() + new_node_size); | 2449 new_node->address() + new_node_size); |
| 2441 } | 2450 } |
| 2442 | 2451 |
| 2443 return new_node; | 2452 return new_node; |
| 2444 } | 2453 } |
| 2445 | 2454 |
| 2446 | 2455 |
| 2447 intptr_t FreeList::EvictFreeListItems(Page* p) { | 2456 intptr_t FreeList::EvictFreeListItems(Page* p) { |
| 2448 intptr_t sum = huge_list_.EvictFreeListItemsInList(p); | 2457 intptr_t sum = huge_list_.EvictFreeListItemsInList(p); |
| 2449 p->set_available_in_huge_free_list(0); | |
| 2450 | |
| 2451 if (sum < p->area_size()) { | 2458 if (sum < p->area_size()) { |
| 2452 sum += small_list_.EvictFreeListItemsInList(p) + | 2459 sum += small_list_.EvictFreeListItemsInList(p) + |
| 2453 medium_list_.EvictFreeListItemsInList(p) + | 2460 medium_list_.EvictFreeListItemsInList(p) + |
| 2454 large_list_.EvictFreeListItemsInList(p); | 2461 large_list_.EvictFreeListItemsInList(p); |
| 2455 p->set_available_in_small_free_list(0); | |
| 2456 p->set_available_in_medium_free_list(0); | |
| 2457 p->set_available_in_large_free_list(0); | |
| 2458 } | 2462 } |
| 2459 | |
| 2460 return sum; | 2463 return sum; |
| 2461 } | 2464 } |
| 2462 | 2465 |
| 2463 | 2466 |
| 2464 bool FreeList::ContainsPageFreeListItems(Page* p) { | 2467 bool FreeList::ContainsPageFreeListItems(Page* p) { |
| 2465 return huge_list_.EvictFreeListItemsInList(p) || | 2468 return huge_list_.EvictFreeListItemsInList(p) || |
| 2466 small_list_.EvictFreeListItemsInList(p) || | 2469 small_list_.EvictFreeListItemsInList(p) || |
| 2467 medium_list_.EvictFreeListItemsInList(p) || | 2470 medium_list_.EvictFreeListItemsInList(p) || |
| 2468 large_list_.EvictFreeListItemsInList(p); | 2471 large_list_.EvictFreeListItemsInList(p); |
| 2469 } | 2472 } |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3136 object->ShortPrint(); | 3139 object->ShortPrint(); |
| 3137 PrintF("\n"); | 3140 PrintF("\n"); |
| 3138 } | 3141 } |
| 3139 printf(" --------------------------------------\n"); | 3142 printf(" --------------------------------------\n"); |
| 3140 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3143 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3141 } | 3144 } |
| 3142 | 3145 |
| 3143 #endif // DEBUG | 3146 #endif // DEBUG |
| 3144 } // namespace internal | 3147 } // namespace internal |
| 3145 } // namespace v8 | 3148 } // namespace v8 |
| OLD | NEW |