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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 case OLD_DATA_SPACE: | 1038 case OLD_DATA_SPACE: |
1039 size = 192 * KB; | 1039 size = 192 * KB; |
1040 break; | 1040 break; |
1041 case MAP_SPACE: | 1041 case MAP_SPACE: |
1042 size = 16 * kPointerSize * KB; | 1042 size = 16 * kPointerSize * KB; |
1043 break; | 1043 break; |
1044 case CELL_SPACE: | 1044 case CELL_SPACE: |
1045 size = 16 * kPointerSize * KB; | 1045 size = 16 * kPointerSize * KB; |
1046 break; | 1046 break; |
1047 case PROPERTY_CELL_SPACE: | 1047 case PROPERTY_CELL_SPACE: |
1048 size = 8 * kPointerSize * KB; | 1048 size = 16 * kPointerSize * KB; |
1049 break; | 1049 break; |
1050 case CODE_SPACE: | 1050 case CODE_SPACE: |
1051 if (heap()->isolate()->code_range()->exists()) { | 1051 if (heap()->isolate()->code_range()->exists()) { |
1052 // When code range exists, code pages are allocated in a special way | 1052 // When code range exists, code pages are allocated in a special way |
1053 // (from the reserved code range). That part of the code is not yet | 1053 // (from the reserved code range). That part of the code is not yet |
1054 // upgraded to handle small pages. | 1054 // upgraded to handle small pages. |
1055 size = AreaSize(); | 1055 size = AreaSize(); |
1056 } else { | 1056 } else { |
1057 size = 384 * KB; | 1057 size = 384 * KB; |
1058 } | 1058 } |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 } | 2111 } |
2112 | 2112 |
2113 | 2113 |
2114 FreeListNode* FreeListCategory::PickNodeFromList(int *node_size) { | 2114 FreeListNode* FreeListCategory::PickNodeFromList(int *node_size) { |
2115 FreeListNode* node = top_; | 2115 FreeListNode* node = top_; |
2116 | 2116 |
2117 if (node == NULL) return NULL; | 2117 if (node == NULL) return NULL; |
2118 | 2118 |
2119 while (node != NULL && | 2119 while (node != NULL && |
2120 Page::FromAddress(node->address())->IsEvacuationCandidate()) { | 2120 Page::FromAddress(node->address())->IsEvacuationCandidate()) { |
2121 available_ -= reinterpret_cast<FreeSpace*>(node)->Size(); | 2121 available_ -= node->Size(); |
2122 node = node->next(); | 2122 node = node->next(); |
2123 } | 2123 } |
2124 | 2124 |
2125 if (node != NULL) { | 2125 if (node != NULL) { |
2126 set_top(node->next()); | 2126 set_top(node->next()); |
2127 *node_size = reinterpret_cast<FreeSpace*>(node)->Size(); | 2127 *node_size = node->Size(); |
2128 available_ -= *node_size; | 2128 available_ -= *node_size; |
2129 } else { | 2129 } else { |
2130 set_top(NULL); | 2130 set_top(NULL); |
2131 } | 2131 } |
2132 | 2132 |
2133 if (top() == NULL) { | 2133 if (top() == NULL) { |
2134 set_end(NULL); | 2134 set_end(NULL); |
2135 } | 2135 } |
2136 | 2136 |
2137 return node; | 2137 return node; |
2138 } | 2138 } |
2139 | 2139 |
2140 | 2140 |
2141 FreeListNode* FreeListCategory::PickNodeFromList(int size_in_bytes, | |
2142 int *node_size) { | |
2143 FreeListNode* node = PickNodeFromList(node_size); | |
2144 if (node != NULL && *node_size < size_in_bytes) { | |
2145 Free(node, *node_size); | |
2146 *node_size = 0; | |
2147 return NULL; | |
2148 } | |
2149 return node; | |
2150 } | |
2151 | |
2152 | |
2153 void FreeListCategory::Free(FreeListNode* node, int size_in_bytes) { | 2141 void FreeListCategory::Free(FreeListNode* node, int size_in_bytes) { |
2154 node->set_next(top_); | 2142 node->set_next(top_); |
2155 top_ = node; | 2143 top_ = node; |
2156 if (end_ == NULL) { | 2144 if (end_ == NULL) { |
2157 end_ = node; | 2145 end_ = node; |
2158 } | 2146 } |
2159 available_ += size_in_bytes; | 2147 available_ += size_in_bytes; |
2160 } | 2148 } |
2161 | 2149 |
2162 | 2150 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 } | 2220 } |
2233 | 2221 |
2234 | 2222 |
2235 FreeListNode* FreeList::FindNodeFor(int size_in_bytes, int* node_size) { | 2223 FreeListNode* FreeList::FindNodeFor(int size_in_bytes, int* node_size) { |
2236 FreeListNode* node = NULL; | 2224 FreeListNode* node = NULL; |
2237 Page* page = NULL; | 2225 Page* page = NULL; |
2238 | 2226 |
2239 if (size_in_bytes <= kSmallAllocationMax) { | 2227 if (size_in_bytes <= kSmallAllocationMax) { |
2240 node = small_list_.PickNodeFromList(node_size); | 2228 node = small_list_.PickNodeFromList(node_size); |
2241 if (node != NULL) { | 2229 if (node != NULL) { |
2242 ASSERT(size_in_bytes <= *node_size); | |
2243 page = Page::FromAddress(node->address()); | 2230 page = Page::FromAddress(node->address()); |
2244 page->add_available_in_small_free_list(-(*node_size)); | 2231 page->add_available_in_small_free_list(-(*node_size)); |
2245 ASSERT(IsVeryLong() || available() == SumFreeLists()); | |
2246 return node; | 2232 return node; |
2247 } | 2233 } |
2248 } | 2234 } |
2249 | 2235 |
2250 if (size_in_bytes <= kMediumAllocationMax) { | 2236 if (size_in_bytes <= kMediumAllocationMax) { |
2251 node = medium_list_.PickNodeFromList(node_size); | 2237 node = medium_list_.PickNodeFromList(node_size); |
2252 if (node != NULL) { | 2238 if (node != NULL) { |
2253 ASSERT(size_in_bytes <= *node_size); | |
2254 page = Page::FromAddress(node->address()); | 2239 page = Page::FromAddress(node->address()); |
2255 page->add_available_in_medium_free_list(-(*node_size)); | 2240 page->add_available_in_medium_free_list(-(*node_size)); |
2256 ASSERT(IsVeryLong() || available() == SumFreeLists()); | |
2257 return node; | 2241 return node; |
2258 } | 2242 } |
2259 } | 2243 } |
2260 | 2244 |
2261 if (size_in_bytes <= kLargeAllocationMax) { | 2245 if (size_in_bytes <= kLargeAllocationMax) { |
2262 node = large_list_.PickNodeFromList(node_size); | 2246 node = large_list_.PickNodeFromList(node_size); |
2263 if (node != NULL) { | 2247 if (node != NULL) { |
2264 ASSERT(size_in_bytes <= *node_size); | |
2265 page = Page::FromAddress(node->address()); | 2248 page = Page::FromAddress(node->address()); |
2266 page->add_available_in_large_free_list(-(*node_size)); | 2249 page->add_available_in_large_free_list(-(*node_size)); |
2267 ASSERT(IsVeryLong() || available() == SumFreeLists()); | |
2268 return node; | 2250 return node; |
2269 } | 2251 } |
2270 } | 2252 } |
2271 | 2253 |
2272 int huge_list_available = huge_list_.available(); | 2254 int huge_list_available = huge_list_.available(); |
2273 for (FreeListNode** cur = huge_list_.GetTopAddress(); | 2255 for (FreeListNode** cur = huge_list_.GetTopAddress(); |
2274 *cur != NULL; | 2256 *cur != NULL; |
2275 cur = (*cur)->next_address()) { | 2257 cur = (*cur)->next_address()) { |
2276 FreeListNode* cur_node = *cur; | 2258 FreeListNode* cur_node = *cur; |
2277 while (cur_node != NULL && | 2259 while (cur_node != NULL && |
(...skipping 22 matching lines...) Expand all Loading... |
2300 huge_list_available -= size; | 2282 huge_list_available -= size; |
2301 page = Page::FromAddress(node->address()); | 2283 page = Page::FromAddress(node->address()); |
2302 page->add_available_in_huge_free_list(-size); | 2284 page->add_available_in_huge_free_list(-size); |
2303 break; | 2285 break; |
2304 } | 2286 } |
2305 } | 2287 } |
2306 | 2288 |
2307 if (huge_list_.top() == NULL) { | 2289 if (huge_list_.top() == NULL) { |
2308 huge_list_.set_end(NULL); | 2290 huge_list_.set_end(NULL); |
2309 } | 2291 } |
| 2292 |
2310 huge_list_.set_available(huge_list_available); | 2293 huge_list_.set_available(huge_list_available); |
| 2294 ASSERT(IsVeryLong() || available() == SumFreeLists()); |
2311 | 2295 |
2312 if (node != NULL) { | |
2313 ASSERT(IsVeryLong() || available() == SumFreeLists()); | |
2314 return node; | |
2315 } | |
2316 | |
2317 if (size_in_bytes <= kSmallListMax) { | |
2318 node = small_list_.PickNodeFromList(size_in_bytes, node_size); | |
2319 if (node != NULL) { | |
2320 ASSERT(size_in_bytes <= *node_size); | |
2321 page = Page::FromAddress(node->address()); | |
2322 page->add_available_in_small_free_list(-(*node_size)); | |
2323 } | |
2324 } else if (size_in_bytes <= kMediumListMax) { | |
2325 node = medium_list_.PickNodeFromList(size_in_bytes, node_size); | |
2326 if (node != NULL) { | |
2327 ASSERT(size_in_bytes <= *node_size); | |
2328 page = Page::FromAddress(node->address()); | |
2329 page->add_available_in_medium_free_list(-(*node_size)); | |
2330 } | |
2331 } else if (size_in_bytes <= kLargeListMax) { | |
2332 node = large_list_.PickNodeFromList(size_in_bytes, node_size); | |
2333 if (node != NULL) { | |
2334 ASSERT(size_in_bytes <= *node_size); | |
2335 page = Page::FromAddress(node->address()); | |
2336 page->add_available_in_large_free_list(-(*node_size)); | |
2337 } | |
2338 } | |
2339 | |
2340 ASSERT(IsVeryLong() || available() == SumFreeLists()); | |
2341 return node; | 2296 return node; |
2342 } | 2297 } |
2343 | 2298 |
2344 | 2299 |
2345 // Allocation on the old space free list. If it succeeds then a new linear | 2300 // Allocation on the old space free list. If it succeeds then a new linear |
2346 // allocation space has been set up with the top and limit of the space. If | 2301 // allocation space has been set up with the top and limit of the space. If |
2347 // the allocation fails then NULL is returned, and the caller can perform a GC | 2302 // the allocation fails then NULL is returned, and the caller can perform a GC |
2348 // or allocate a new page before retrying. | 2303 // or allocate a new page before retrying. |
2349 HeapObject* FreeList::Allocate(int size_in_bytes) { | 2304 HeapObject* FreeList::Allocate(int size_in_bytes) { |
2350 ASSERT(0 < size_in_bytes); | 2305 ASSERT(0 < size_in_bytes); |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3234 object->ShortPrint(); | 3189 object->ShortPrint(); |
3235 PrintF("\n"); | 3190 PrintF("\n"); |
3236 } | 3191 } |
3237 printf(" --------------------------------------\n"); | 3192 printf(" --------------------------------------\n"); |
3238 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3193 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3239 } | 3194 } |
3240 | 3195 |
3241 #endif // DEBUG | 3196 #endif // DEBUG |
3242 | 3197 |
3243 } } // namespace v8::internal | 3198 } } // namespace v8::internal |
OLD | NEW |