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

Side by Side Diff: src/heap/spaces.cc

Issue 1948893002: Make sure the heap is in consistent state when calling allocation observers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | 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 // 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/base/platform/semaphore.h" 9 #include "src/base/platform/semaphore.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 // if it is big enough. 2437 // if it is big enough.
2438 owner_->Free(owner_->top(), old_linear_size); 2438 owner_->Free(owner_->top(), old_linear_size);
2439 owner_->SetTopAndLimit(nullptr, nullptr); 2439 owner_->SetTopAndLimit(nullptr, nullptr);
2440 2440
2441 owner_->heap()->incremental_marking()->OldSpaceStep(size_in_bytes - 2441 owner_->heap()->incremental_marking()->OldSpaceStep(size_in_bytes -
2442 old_linear_size); 2442 old_linear_size);
2443 2443
2444 int new_node_size = 0; 2444 int new_node_size = 0;
2445 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size); 2445 FreeSpace* new_node = FindNodeFor(size_in_bytes, &new_node_size);
2446 if (new_node == nullptr) return nullptr; 2446 if (new_node == nullptr) return nullptr;
2447 owner_->AllocationStep(new_node->address(), size_in_bytes);
2448 2447
2449 int bytes_left = new_node_size - size_in_bytes; 2448 int bytes_left = new_node_size - size_in_bytes;
2450 DCHECK(bytes_left >= 0); 2449 DCHECK(bytes_left >= 0);
2451 2450
2452 #ifdef DEBUG 2451 #ifdef DEBUG
2453 for (int i = 0; i < size_in_bytes / kPointerSize; i++) { 2452 for (int i = 0; i < size_in_bytes / kPointerSize; i++) {
2454 reinterpret_cast<Object**>(new_node->address())[i] = 2453 reinterpret_cast<Object**>(new_node->address())[i] =
2455 Smi::FromInt(kCodeZapValue); 2454 Smi::FromInt(kCodeZapValue);
2456 } 2455 }
2457 #endif 2456 #endif
(...skipping 25 matching lines...) Expand all
2483 new_node_size - size_in_bytes - linear_size); 2482 new_node_size - size_in_bytes - linear_size);
2484 owner_->SetTopAndLimit(new_node->address() + size_in_bytes, 2483 owner_->SetTopAndLimit(new_node->address() + size_in_bytes,
2485 new_node->address() + size_in_bytes + linear_size); 2484 new_node->address() + size_in_bytes + linear_size);
2486 } else if (bytes_left > 0) { 2485 } else if (bytes_left > 0) {
2487 // Normally we give the rest of the node to the allocator as its new 2486 // Normally we give the rest of the node to the allocator as its new
2488 // linear allocation area. 2487 // linear allocation area.
2489 owner_->SetTopAndLimit(new_node->address() + size_in_bytes, 2488 owner_->SetTopAndLimit(new_node->address() + size_in_bytes,
2490 new_node->address() + new_node_size); 2489 new_node->address() + new_node_size);
2491 } 2490 }
2492 2491
2492 owner_->AllocationStep(new_node->address(), size_in_bytes);
2493
2493 return new_node; 2494 return new_node;
2494 } 2495 }
2495 2496
2496 intptr_t FreeList::EvictFreeListItems(Page* page) { 2497 intptr_t FreeList::EvictFreeListItems(Page* page) {
2497 intptr_t sum = 0; 2498 intptr_t sum = 0;
2498 page->ForAllFreeListCategories( 2499 page->ForAllFreeListCategories(
2499 [this, &sum, page](FreeListCategory* category) { 2500 [this, &sum, page](FreeListCategory* category) {
2500 DCHECK_EQ(this, category->owner()); 2501 DCHECK_EQ(this, category->owner());
2501 sum += category->available(); 2502 sum += category->available();
2502 RemoveCategory(category); 2503 RemoveCategory(category);
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 object->ShortPrint(); 3221 object->ShortPrint();
3221 PrintF("\n"); 3222 PrintF("\n");
3222 } 3223 }
3223 printf(" --------------------------------------\n"); 3224 printf(" --------------------------------------\n");
3224 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3225 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3225 } 3226 }
3226 3227
3227 #endif // DEBUG 3228 #endif // DEBUG
3228 } // namespace internal 3229 } // namespace internal
3229 } // namespace v8 3230 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698