Allow allocations in spaces with constant allocation size use the

smallest possible size-class.

BUG=
R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/16957003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15129 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
hpayer@chromium.org 2013-06-13 17:03:57 +00:00
parent 69b43a07ec
commit ce6a0e4def
2 changed files with 15 additions and 1 deletions

View File

@ -2202,6 +2202,11 @@ int FreeList::Free(Address start, int size_in_bytes) {
// Insert other blocks at the head of a free list of the appropriate // Insert other blocks at the head of a free list of the appropriate
// magnitude. // magnitude.
if (size_in_bytes <= kSmallListMax) { if (size_in_bytes <= kSmallListMax) {
ASSERT(!owner_->ConstantAllocationSize() ||
(owner_->identity() == MAP_SPACE && size_in_bytes >= Map::kSize) ||
(owner_->identity() == CELL_SPACE && size_in_bytes >= Cell::kSize) ||
(owner_->identity() == PROPERTY_CELL_SPACE &&
size_in_bytes >= JSGlobalPropertyCell::kSize));
small_list_.Free(node, size_in_bytes); small_list_.Free(node, size_in_bytes);
page->add_available_in_small_free_list(size_in_bytes); page->add_available_in_small_free_list(size_in_bytes);
} else if (size_in_bytes <= kMediumListMax) { } else if (size_in_bytes <= kMediumListMax) {
@ -2224,9 +2229,11 @@ FreeListNode* FreeList::FindNodeFor(int size_in_bytes, int* node_size) {
FreeListNode* node = NULL; FreeListNode* node = NULL;
Page* page = NULL; Page* page = NULL;
if (size_in_bytes <= kSmallAllocationMax) { if ((owner_->ConstantAllocationSize() && size_in_bytes <= kSmallListMax) ||
size_in_bytes <= kSmallAllocationMax) {
node = small_list_.PickNodeFromList(node_size); node = small_list_.PickNodeFromList(node_size);
if (node != NULL) { if (node != NULL) {
ASSERT(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address()); page = Page::FromAddress(node->address());
page->add_available_in_small_free_list(-(*node_size)); page->add_available_in_small_free_list(-(*node_size));
return node; return node;
@ -2236,6 +2243,7 @@ FreeListNode* FreeList::FindNodeFor(int size_in_bytes, int* node_size) {
if (size_in_bytes <= kMediumAllocationMax) { if (size_in_bytes <= kMediumAllocationMax) {
node = medium_list_.PickNodeFromList(node_size); node = medium_list_.PickNodeFromList(node_size);
if (node != NULL) { if (node != NULL) {
ASSERT(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address()); page = Page::FromAddress(node->address());
page->add_available_in_medium_free_list(-(*node_size)); page->add_available_in_medium_free_list(-(*node_size));
return node; return node;
@ -2245,6 +2253,7 @@ FreeListNode* FreeList::FindNodeFor(int size_in_bytes, int* node_size) {
if (size_in_bytes <= kLargeAllocationMax) { if (size_in_bytes <= kLargeAllocationMax) {
node = large_list_.PickNodeFromList(node_size); node = large_list_.PickNodeFromList(node_size);
if (node != NULL) { if (node != NULL) {
ASSERT(size_in_bytes <= *node_size);
page = Page::FromAddress(node->address()); page = Page::FromAddress(node->address());
page->add_available_in_large_free_list(-(*node_size)); page->add_available_in_large_free_list(-(*node_size));
return node; return node;

View File

@ -1820,6 +1820,11 @@ class PagedSpace : public Space {
return area_size_; return area_size_;
} }
bool ConstantAllocationSize() {
return identity() == MAP_SPACE || identity() == CELL_SPACE ||
identity() == PROPERTY_CELL_SPACE;
}
protected: protected:
FreeList* free_list() { return &free_list_; } FreeList* free_list() { return &free_list_; }