96f10b9044
This reverts commit 2b24cd035a
.
Reason for revert: Causes layout test failures
https://ci.chromium.org/p/chromium/builders/try/linux-chromeos-rel/275121
and https://ci.chromium.org/p/chromium/builders/try/win7-rel/86354
Original change's description:
> [heap] Skip read-only space in Heap::Contains
>
> Bug: v8:7464
> Change-Id: I27e82cdf0f8cc56ff68dcfaecab9644fe74916c7
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1559861
> Commit-Queue: Maciej Goszczycki <goszczycki@google.com>
> Reviewed-by: Dan Elphick <delphick@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#61350}
TBR=ulan@chromium.org,delphick@chromium.org,goszczycki@google.com
Change-Id: I13cc09dd44a10bad854fa861b6e43149babb1b5e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7464
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1601498
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61363}
101 lines
2.7 KiB
C++
101 lines
2.7 KiB
C++
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "include/v8.h"
|
|
#include "src/api-inl.h"
|
|
#include "src/heap/combined-heap.h"
|
|
#include "src/heap/heap.h"
|
|
#include "src/heap/read-only-heap.h"
|
|
#include "src/isolate.h"
|
|
#include "src/objects.h"
|
|
#include "src/objects/heap-object.h"
|
|
#include "src/roots-inl.h"
|
|
#include "test/cctest/cctest.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
namespace heap {
|
|
|
|
TEST(HeapIteratorNullPastEnd) {
|
|
HeapIterator iterator(CcTest::heap());
|
|
while (!iterator.next().is_null()) {
|
|
}
|
|
for (int i = 0; i < 20; i++) {
|
|
CHECK(iterator.next().is_null());
|
|
}
|
|
}
|
|
|
|
TEST(ReadOnlyHeapIteratorNullPastEnd) {
|
|
ReadOnlyHeapIterator iterator(CcTest::heap()->read_only_heap());
|
|
while (!iterator.next().is_null()) {
|
|
}
|
|
for (int i = 0; i < 20; i++) {
|
|
CHECK(iterator.next().is_null());
|
|
}
|
|
}
|
|
|
|
TEST(CombinedHeapIteratorNullPastEnd) {
|
|
CombinedHeapIterator iterator(CcTest::heap());
|
|
while (!iterator.next().is_null()) {
|
|
}
|
|
for (int i = 0; i < 20; i++) {
|
|
CHECK(iterator.next().is_null());
|
|
}
|
|
}
|
|
|
|
namespace {
|
|
// An arbitrary object guaranteed to live on the non-read-only heap.
|
|
Object CreateWritableObject() {
|
|
return *v8::Utils::OpenHandle(*v8::Object::New(CcTest::isolate()));
|
|
}
|
|
} // namespace
|
|
|
|
// TODO(v8:7464): Add more CHECKs once Contains doesn't include read-only space.
|
|
TEST(ReadOnlyHeapIterator) {
|
|
CcTest::InitializeVM();
|
|
HandleScope handle_scope(CcTest::i_isolate());
|
|
const Object sample_object = CreateWritableObject();
|
|
ReadOnlyHeapIterator iterator(CcTest::read_only_heap());
|
|
|
|
for (HeapObject obj = iterator.next(); !obj.is_null();
|
|
obj = iterator.next()) {
|
|
CHECK(ReadOnlyHeap::Contains(obj));
|
|
CHECK_NE(sample_object, obj);
|
|
}
|
|
}
|
|
|
|
TEST(HeapIterator) {
|
|
CcTest::InitializeVM();
|
|
HandleScope handle_scope(CcTest::i_isolate());
|
|
const Object sample_object = CreateWritableObject();
|
|
HeapIterator iterator(CcTest::heap());
|
|
bool seen_sample_object = false;
|
|
|
|
for (HeapObject obj = iterator.next(); !obj.is_null();
|
|
obj = iterator.next()) {
|
|
CHECK(!ReadOnlyHeap::Contains(obj));
|
|
if (sample_object == obj) seen_sample_object = true;
|
|
}
|
|
CHECK(seen_sample_object);
|
|
}
|
|
|
|
TEST(CombinedHeapIterator) {
|
|
CcTest::InitializeVM();
|
|
HandleScope handle_scope(CcTest::i_isolate());
|
|
const Object sample_object = CreateWritableObject();
|
|
CombinedHeapIterator iterator(CcTest::heap());
|
|
bool seen_sample_object = false;
|
|
|
|
for (HeapObject obj = iterator.next(); !obj.is_null();
|
|
obj = iterator.next()) {
|
|
CHECK(CcTest::heap()->Contains(obj));
|
|
if (sample_object == obj) seen_sample_object = true;
|
|
}
|
|
CHECK(seen_sample_object);
|
|
}
|
|
|
|
} // namespace heap
|
|
} // namespace internal
|
|
} // namespace v8
|