[serializer] DCHECK deserializer allocations are initialized
Add a DCHECK during deserializer allocation that the previous allocation is sufficiently initialized to be iterable. This is an step towards allowing GC during deserializer execution. Bug: v8:10815 Change-Id: I29da21b93e6b826bdb7b5f9f5a9723da1698a225 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2396079 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#69802}
This commit is contained in:
parent
6798619a69
commit
fbc1f32d8e
@ -64,6 +64,22 @@ Address DeserializerAllocator::AllocateRaw(SnapshotSpace space, int size) {
|
||||
}
|
||||
|
||||
Address DeserializerAllocator::Allocate(SnapshotSpace space, int size) {
|
||||
#ifdef DEBUG
|
||||
if (previous_allocation_start_ != kNullAddress) {
|
||||
// Make sure that the previous allocation is initialized sufficiently to
|
||||
// be iterated over by the GC.
|
||||
Address object_address = previous_allocation_start_;
|
||||
Address previous_allocation_end =
|
||||
previous_allocation_start_ + previous_allocation_size_;
|
||||
while (object_address != previous_allocation_end) {
|
||||
int object_size = HeapObject::FromAddress(object_address).Size();
|
||||
DCHECK_GT(object_size, 0);
|
||||
DCHECK_LE(object_address + object_size, previous_allocation_end);
|
||||
object_address += object_size;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Address address;
|
||||
HeapObject obj;
|
||||
// TODO(steveblackburn) Note that the third party heap allocates objects
|
||||
@ -80,9 +96,9 @@ Address DeserializerAllocator::Allocate(SnapshotSpace space, int size) {
|
||||
// abstracting away the details of the memory allocator from this code.
|
||||
// At each allocation, the regular allocator performs allocation,
|
||||
// and a fixed-sized table is used to track and fix all back references.
|
||||
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return AllocateRaw(space, size);
|
||||
|
||||
if (next_alignment_ != kWordAligned) {
|
||||
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
|
||||
address = AllocateRaw(space, size);
|
||||
} else if (next_alignment_ != kWordAligned) {
|
||||
const int reserved = size + Heap::GetMaximumFillToAlign(next_alignment_);
|
||||
address = AllocateRaw(space, reserved);
|
||||
obj = HeapObject::FromAddress(address);
|
||||
@ -95,10 +111,16 @@ Address DeserializerAllocator::Allocate(SnapshotSpace space, int size) {
|
||||
obj = Heap::AlignWithFiller(roots_, obj, size, reserved, next_alignment_);
|
||||
address = obj.address();
|
||||
next_alignment_ = kWordAligned;
|
||||
return address;
|
||||
} else {
|
||||
return AllocateRaw(space, size);
|
||||
address = AllocateRaw(space, size);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
previous_allocation_start_ = address;
|
||||
previous_allocation_size_ = size;
|
||||
#endif
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
void DeserializerAllocator::MoveToNextChunk(SnapshotSpace space) {
|
||||
|
@ -73,6 +73,12 @@ class DeserializerAllocator final {
|
||||
uint32_t current_chunk_[kNumberOfPreallocatedSpaces];
|
||||
Address high_water_[kNumberOfPreallocatedSpaces];
|
||||
|
||||
#ifdef DEBUG
|
||||
// Record the previous object allocated for DCHECKs.
|
||||
Address previous_allocation_start_ = kNullAddress;
|
||||
int previous_allocation_size_ = 0;
|
||||
#endif
|
||||
|
||||
// The alignment of the next allocation.
|
||||
AllocationAlignment next_alignment_ = kWordAligned;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user