Commit 52baa131 authored by Javad Amiri's avatar Javad Amiri Committed by Commit Bot

[heap] Add missing third-party heap guards

Bug: v8:9533
Change-Id: I912bd5acd2cdb4c9d111711d17a01ba635b76660
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2463006
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70523}
parent 04c85d7c
......@@ -968,7 +968,8 @@ void Code::CodeVerify(Isolate* isolate) {
// everything is set up.
// CHECK_EQ(ReadOnlyHeap::Contains(*this), !IsExecutable());
relocation_info().ObjectVerify(isolate);
CHECK(Code::SizeFor(body_size()) <= kMaxRegularHeapObjectSize ||
CHECK(V8_ENABLE_THIRD_PARTY_HEAP_BOOL ||
Code::SizeFor(body_size()) <= kMaxRegularHeapObjectSize ||
isolate->heap()->InSpace(*this, CODE_LO_SPACE));
Address last_gc_pc = kNullAddress;
......
......@@ -283,13 +283,11 @@ class BasicMemoryChunk {
// Only works if the pointer is in the first kPageSize of the MemoryChunk.
static BasicMemoryChunk* FromAddress(Address a) {
DCHECK(!V8_ENABLE_THIRD_PARTY_HEAP_BOOL);
return reinterpret_cast<BasicMemoryChunk*>(BaseAddress(a));
}
// Only works if the object is in the first kPageSize of the MemoryChunk.
static BasicMemoryChunk* FromHeapObject(HeapObject o) {
DCHECK(!V8_ENABLE_THIRD_PARTY_HEAP_BOOL);
return reinterpret_cast<BasicMemoryChunk*>(BaseAddress(o.ptr()));
}
......
......@@ -777,7 +777,8 @@ template <typename Impl>
HeapObject FactoryBase<Impl>::AllocateRawArray(int size,
AllocationType allocation) {
HeapObject result = AllocateRaw(size, allocation);
if (size > kMaxRegularHeapObjectSize && FLAG_use_marking_progress_bar) {
if (!V8_ENABLE_THIRD_PARTY_HEAP_BOOL &&
size > kMaxRegularHeapObjectSize && FLAG_use_marking_progress_bar) {
BasicMemoryChunk* chunk = BasicMemoryChunk::FromHeapObject(result);
chunk->SetFlag<AccessMode::ATOMIC>(MemoryChunk::HAS_PROGRESS_BAR);
}
......
......@@ -2151,6 +2151,7 @@ Handle<Code> Factory::CopyCode(Handle<Code> code) {
#endif
DCHECK(IsAligned(new_code->address(), kCodeAlignment));
DCHECK_IMPLIES(
!V8_ENABLE_THIRD_PARTY_HEAP_BOOL &&
!heap->memory_allocator()->code_range().is_empty(),
heap->memory_allocator()->code_range().contains(new_code->address()));
return new_code;
......
......@@ -186,6 +186,7 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type,
#endif
size_t large_object_threshold =
!V8_ENABLE_THIRD_PARTY_HEAP_BOOL &&
AllocationType::kCode == type
? std::min(kMaxRegularHeapObjectSize, code_space()->AreaSize())
: kMaxRegularHeapObjectSize;
......@@ -275,14 +276,10 @@ HeapObject Heap::AllocateRawWith(int size, AllocationType allocation,
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(AllowHeapAllocation::IsAllowed());
DCHECK(AllowGarbageCollection::IsAllowed());
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
AllocationResult result = AllocateRaw(size, allocation, origin, alignment);
DCHECK(!result.IsRetry());
return result.ToObjectChecked();
}
DCHECK_EQ(gc_state(), NOT_IN_GC);
Heap* heap = isolate()->heap();
if (allocation == AllocationType::kYoung &&
if (!V8_ENABLE_THIRD_PARTY_HEAP_BOOL &&
allocation == AllocationType::kYoung &&
alignment == AllocationAlignment::kWordAligned &&
size <= kMaxRegularHeapObjectSize) {
Address* top = heap->NewSpaceAllocationTopAddress();
......
......@@ -191,6 +191,7 @@ inline bool ObjectInYoungGeneration(Object object) {
}
inline bool IsReadOnlyHeapObject(HeapObject object) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return ReadOnlyHeap::Contains(object);
heap_internals::MemoryChunk* chunk =
heap_internals::MemoryChunk::FromHeapObject(object);
return chunk->InReadOnlySpace();
......
......@@ -2963,6 +2963,7 @@ class LeftTrimmerVerifierRootVisitor : public RootVisitor {
namespace {
bool MayContainRecordedSlots(HeapObject object) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return false;
// New space object do not have recorded slots.
if (BasicMemoryChunk::FromHeapObject(object)->InYoungGeneration())
return false;
......
......@@ -59,7 +59,6 @@ class MemoryChunk : public BasicMemoryChunk {
// Only works if the object is in the first kPageSize of the MemoryChunk.
static MemoryChunk* FromHeapObject(HeapObject o) {
DCHECK(!V8_ENABLE_THIRD_PARTY_HEAP_BOOL);
return cast(BasicMemoryChunk::FromHeapObject(o));
}
......
......@@ -219,7 +219,11 @@ void ReadOnlyHeap::PopulateReadOnlySpaceStatistics(
// static
bool ReadOnlyHeap::Contains(Address address) {
return BasicMemoryChunk::FromAddress(address)->InReadOnlySpace();
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
return third_party_heap::Heap::InReadOnlySpace(address);
} else {
return BasicMemoryChunk::FromAddress(address)->InReadOnlySpace();
}
}
// static
......
......@@ -722,6 +722,7 @@ size_t ReadOnlyPage::ShrinkToHighWaterMark() {
}
void ReadOnlySpace::ShrinkPages() {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return;
BasicMemoryChunk::UpdateHighWaterMark(top_);
heap()->CreateFillerObjectAt(top_, static_cast<int>(limit_ - top_),
ClearRecordedSlots::kNo);
......
......@@ -698,7 +698,7 @@ void Serializer::ObjectSerializer::Serialize() {
namespace {
SnapshotSpace GetSnapshotSpace(Handle<HeapObject> object) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
if (third_party_heap::Heap::InCodeSpace(object.address())) {
if (object->IsCode()) {
return SnapshotSpace::kCode;
} else if (ReadOnlyHeap::Contains(*object)) {
return SnapshotSpace::kReadOnlyHeap;
......
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