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

Side by Side Diff: src/spaces.cc

Issue 16957003: Allow allocations in spaces with constant allocation size use the (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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/spaces.h ('k') | no next file » | 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 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 2195
2196 // Early return to drop too-small blocks on the floor. 2196 // Early return to drop too-small blocks on the floor.
2197 if (size_in_bytes < kSmallListMin) { 2197 if (size_in_bytes < kSmallListMin) {
2198 page->add_non_available_small_blocks(size_in_bytes); 2198 page->add_non_available_small_blocks(size_in_bytes);
2199 return size_in_bytes; 2199 return size_in_bytes;
2200 } 2200 }
2201 2201
2202 // Insert other blocks at the head of a free list of the appropriate 2202 // Insert other blocks at the head of a free list of the appropriate
2203 // magnitude. 2203 // magnitude.
2204 if (size_in_bytes <= kSmallListMax) { 2204 if (size_in_bytes <= kSmallListMax) {
2205 ASSERT(!owner_->ConstantAllocationSize() ||
2206 (owner_->identity() == MAP_SPACE && size_in_bytes >= Map::kSize) ||
2207 (owner_->identity() == CELL_SPACE && size_in_bytes >= Cell::kSize) ||
2208 (owner_->identity() == PROPERTY_CELL_SPACE &&
2209 size_in_bytes >= JSGlobalPropertyCell::kSize));
2205 small_list_.Free(node, size_in_bytes); 2210 small_list_.Free(node, size_in_bytes);
2206 page->add_available_in_small_free_list(size_in_bytes); 2211 page->add_available_in_small_free_list(size_in_bytes);
2207 } else if (size_in_bytes <= kMediumListMax) { 2212 } else if (size_in_bytes <= kMediumListMax) {
2208 medium_list_.Free(node, size_in_bytes); 2213 medium_list_.Free(node, size_in_bytes);
2209 page->add_available_in_medium_free_list(size_in_bytes); 2214 page->add_available_in_medium_free_list(size_in_bytes);
2210 } else if (size_in_bytes <= kLargeListMax) { 2215 } else if (size_in_bytes <= kLargeListMax) {
2211 large_list_.Free(node, size_in_bytes); 2216 large_list_.Free(node, size_in_bytes);
2212 page->add_available_in_large_free_list(size_in_bytes); 2217 page->add_available_in_large_free_list(size_in_bytes);
2213 } else { 2218 } else {
2214 huge_list_.Free(node, size_in_bytes); 2219 huge_list_.Free(node, size_in_bytes);
2215 page->add_available_in_huge_free_list(size_in_bytes); 2220 page->add_available_in_huge_free_list(size_in_bytes);
2216 } 2221 }
2217 2222
2218 ASSERT(IsVeryLong() || available() == SumFreeLists()); 2223 ASSERT(IsVeryLong() || available() == SumFreeLists());
2219 return 0; 2224 return 0;
2220 } 2225 }
2221 2226
2222 2227
2223 FreeListNode* FreeList::FindNodeFor(int size_in_bytes, int* node_size) { 2228 FreeListNode* FreeList::FindNodeFor(int size_in_bytes, int* node_size) {
2224 FreeListNode* node = NULL; 2229 FreeListNode* node = NULL;
2225 Page* page = NULL; 2230 Page* page = NULL;
2226 2231
2227 if (size_in_bytes <= kSmallAllocationMax) { 2232 if ((owner_->ConstantAllocationSize() && size_in_bytes <= kSmallListMax) ||
2233 size_in_bytes <= kSmallAllocationMax) {
2228 node = small_list_.PickNodeFromList(node_size); 2234 node = small_list_.PickNodeFromList(node_size);
2229 if (node != NULL) { 2235 if (node != NULL) {
2236 ASSERT(size_in_bytes <= *node_size);
2230 page = Page::FromAddress(node->address()); 2237 page = Page::FromAddress(node->address());
2231 page->add_available_in_small_free_list(-(*node_size)); 2238 page->add_available_in_small_free_list(-(*node_size));
2232 return node; 2239 return node;
2233 } 2240 }
2234 } 2241 }
2235 2242
2236 if (size_in_bytes <= kMediumAllocationMax) { 2243 if (size_in_bytes <= kMediumAllocationMax) {
2237 node = medium_list_.PickNodeFromList(node_size); 2244 node = medium_list_.PickNodeFromList(node_size);
2238 if (node != NULL) { 2245 if (node != NULL) {
2246 ASSERT(size_in_bytes <= *node_size);
2239 page = Page::FromAddress(node->address()); 2247 page = Page::FromAddress(node->address());
2240 page->add_available_in_medium_free_list(-(*node_size)); 2248 page->add_available_in_medium_free_list(-(*node_size));
2241 return node; 2249 return node;
2242 } 2250 }
2243 } 2251 }
2244 2252
2245 if (size_in_bytes <= kLargeAllocationMax) { 2253 if (size_in_bytes <= kLargeAllocationMax) {
2246 node = large_list_.PickNodeFromList(node_size); 2254 node = large_list_.PickNodeFromList(node_size);
2247 if (node != NULL) { 2255 if (node != NULL) {
2256 ASSERT(size_in_bytes <= *node_size);
2248 page = Page::FromAddress(node->address()); 2257 page = Page::FromAddress(node->address());
2249 page->add_available_in_large_free_list(-(*node_size)); 2258 page->add_available_in_large_free_list(-(*node_size));
2250 return node; 2259 return node;
2251 } 2260 }
2252 } 2261 }
2253 2262
2254 int huge_list_available = huge_list_.available(); 2263 int huge_list_available = huge_list_.available();
2255 for (FreeListNode** cur = huge_list_.GetTopAddress(); 2264 for (FreeListNode** cur = huge_list_.GetTopAddress();
2256 *cur != NULL; 2265 *cur != NULL;
2257 cur = (*cur)->next_address()) { 2266 cur = (*cur)->next_address()) {
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
3189 object->ShortPrint(); 3198 object->ShortPrint();
3190 PrintF("\n"); 3199 PrintF("\n");
3191 } 3200 }
3192 printf(" --------------------------------------\n"); 3201 printf(" --------------------------------------\n");
3193 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3202 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3194 } 3203 }
3195 3204
3196 #endif // DEBUG 3205 #endif // DEBUG
3197 3206
3198 } } // namespace v8::internal 3207 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698