Commit 49f60a3b authored by Steve Blackburn's avatar Steve Blackburn Committed by Commit Bot

Refactor deserialization allocation.

Deserialization bypasses the heap allocators, bumping pointers into the
spaces directly, instead.  So the deserializer is tightly coupled to the
implementation of the existing collector.

Here I've added an interface to heap.h for this purpose.  This CL
leaves things as-is unless the TPH is enabled, in which case the new
interface is used.

Future work: use the heap.h interface in all cases.

Bug: v8:9533

Change-Id: I3b1cc81870b347fbfb509ddb4031bd3781710240
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2019482
Commit-Queue: Steve Blackburn <steveblackburn@google.com>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65992}
parent 73f4ac62
......@@ -283,6 +283,16 @@ HeapObject Heap::AllocateRawWith(int size, AllocationType allocation,
UNREACHABLE();
}
Address Heap::DeserializerAllocate(AllocationType type, int size_in_bytes) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
AllocationResult allocation = tp_heap_->Allocate(
size_in_bytes, type, AllocationAlignment::kWordAligned);
return allocation.ToObjectChecked().ptr();
} else {
UNIMPLEMENTED(); // unimplemented
}
}
void Heap::OnAllocationEvent(HeapObject object, int size_in_bytes) {
for (auto& tracker : allocation_trackers_) {
tracker->AllocationEvent(object.address(), size_in_bytes);
......
......@@ -463,6 +463,11 @@ class Heap {
static bool IsLargeObject(HeapObject object);
// This method supports the deserialization allocator. All allocations
// are word-aligned. The method should never fail to allocate since the
// total space requirements of the deserializer are known at build time.
inline Address DeserializerAllocate(AllocationType type, int size_in_bytes);
// Trim the given array from the left. Note that this relocates the object
// start and hence is only valid if there is only a single reference to it.
V8_EXPORT_PRIVATE FixedArrayBase LeftTrimFixedArray(FixedArrayBase obj,
......
......@@ -57,6 +57,12 @@ Address DeserializerAllocator::Allocate(SnapshotSpace space, int size) {
Address address;
HeapObject obj;
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
AllocationType type = (space == SnapshotSpace::kCode)
? AllocationType::kCode
: AllocationType::kYoung;
return heap_->DeserializerAllocate(type, size);
}
if (next_alignment_ != kWordAligned) {
const int reserved = size + Heap::GetMaximumFillToAlign(next_alignment_);
address = AllocateRaw(space, reserved);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment