2020-04-09 07:18:50 +00:00
|
|
|
// Copyright 2020 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 "src/heap/cppgc/heap-page.h"
|
2020-04-27 23:24:31 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2020-04-09 09:25:41 +00:00
|
|
|
#include "include/cppgc/allocation.h"
|
|
|
|
#include "include/cppgc/internal/accessors.h"
|
2020-04-27 23:24:31 +00:00
|
|
|
#include "include/cppgc/persistent.h"
|
|
|
|
#include "src/base/macros.h"
|
|
|
|
#include "src/heap/cppgc/globals.h"
|
|
|
|
#include "src/heap/cppgc/heap-object-header-inl.h"
|
|
|
|
#include "src/heap/cppgc/heap-object-header.h"
|
|
|
|
#include "src/heap/cppgc/page-memory-inl.h"
|
2020-06-10 07:10:20 +00:00
|
|
|
#include "src/heap/cppgc/page-memory.h"
|
2020-04-27 23:24:31 +00:00
|
|
|
#include "src/heap/cppgc/raw-heap.h"
|
2020-04-09 07:18:50 +00:00
|
|
|
#include "test/unittests/heap/cppgc/tests.h"
|
|
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
|
|
|
|
namespace cppgc {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2020-04-27 23:24:31 +00:00
|
|
|
class PageTest : public testing::TestWithHeap {
|
|
|
|
public:
|
|
|
|
RawHeap& GetRawHeap() { return Heap::From(GetHeap())->raw_heap(); }
|
2020-06-10 07:10:20 +00:00
|
|
|
PageBackend* GetPageBackend() {
|
|
|
|
return Heap::From(GetHeap())->page_backend();
|
|
|
|
}
|
2020-04-27 23:24:31 +00:00
|
|
|
};
|
2020-04-09 07:18:50 +00:00
|
|
|
|
2020-04-27 23:24:31 +00:00
|
|
|
template <size_t Size>
|
|
|
|
class GCed : public GarbageCollected<GCed<Size>> {
|
|
|
|
public:
|
|
|
|
virtual void Trace(cppgc::Visitor*) const {}
|
|
|
|
char array[Size];
|
|
|
|
};
|
2020-04-09 09:25:41 +00:00
|
|
|
|
2020-04-09 07:18:50 +00:00
|
|
|
} // namespace
|
|
|
|
|
2020-04-09 09:25:41 +00:00
|
|
|
TEST_F(PageTest, GetHeapForAllocatedObject) {
|
2020-04-27 23:24:31 +00:00
|
|
|
auto* gced = MakeGarbageCollected<GCed<1>>(GetHeap());
|
2020-04-09 09:25:41 +00:00
|
|
|
EXPECT_EQ(GetHeap(), GetHeapFromPayload(gced));
|
|
|
|
}
|
|
|
|
|
2020-04-27 23:24:31 +00:00
|
|
|
TEST_F(PageTest, SpaceIndexing) {
|
|
|
|
RawHeap& heap = GetRawHeap();
|
|
|
|
size_t space = 0u;
|
|
|
|
for (const auto& ptr : heap) {
|
|
|
|
EXPECT_EQ(&heap, ptr.get()->raw_heap());
|
|
|
|
EXPECT_EQ(space, ptr->index());
|
|
|
|
++space;
|
|
|
|
}
|
2020-05-07 20:36:03 +00:00
|
|
|
EXPECT_GE(space, RawHeap::kNumberOfRegularSpaces);
|
2020-04-27 23:24:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PageTest, PredefinedSpaces) {
|
2020-05-07 20:36:03 +00:00
|
|
|
using SpaceType = RawHeap::RegularSpaceType;
|
2020-04-27 23:24:31 +00:00
|
|
|
RawHeap& heap = GetRawHeap();
|
|
|
|
{
|
|
|
|
auto* gced = MakeGarbageCollected<GCed<1>>(GetHeap());
|
|
|
|
BaseSpace* space = NormalPage::FromPayload(gced)->space();
|
|
|
|
EXPECT_EQ(heap.Space(SpaceType::kNormal1), space);
|
|
|
|
EXPECT_EQ(0u, space->index());
|
|
|
|
EXPECT_FALSE(space->is_large());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto* gced = MakeGarbageCollected<GCed<32>>(GetHeap());
|
|
|
|
BaseSpace* space = NormalPage::FromPayload(gced)->space();
|
|
|
|
EXPECT_EQ(heap.Space(SpaceType::kNormal2), space);
|
|
|
|
EXPECT_EQ(1u, space->index());
|
|
|
|
EXPECT_FALSE(space->is_large());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto* gced = MakeGarbageCollected<GCed<64>>(GetHeap());
|
|
|
|
BaseSpace* space = NormalPage::FromPayload(gced)->space();
|
|
|
|
EXPECT_EQ(heap.Space(SpaceType::kNormal3), space);
|
|
|
|
EXPECT_EQ(2u, space->index());
|
|
|
|
EXPECT_FALSE(space->is_large());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto* gced = MakeGarbageCollected<GCed<128>>(GetHeap());
|
|
|
|
BaseSpace* space = NormalPage::FromPayload(gced)->space();
|
|
|
|
EXPECT_EQ(heap.Space(SpaceType::kNormal4), space);
|
|
|
|
EXPECT_EQ(3u, space->index());
|
|
|
|
EXPECT_FALSE(space->is_large());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto* gced =
|
|
|
|
MakeGarbageCollected<GCed<2 * kLargeObjectSizeThreshold>>(GetHeap());
|
|
|
|
BaseSpace* space = NormalPage::FromPayload(gced)->space();
|
|
|
|
EXPECT_EQ(heap.Space(SpaceType::kLarge), space);
|
|
|
|
EXPECT_EQ(4u, space->index());
|
|
|
|
EXPECT_TRUE(space->is_large());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PageTest, NormalPageIndexing) {
|
2020-05-07 20:36:03 +00:00
|
|
|
using SpaceType = RawHeap::RegularSpaceType;
|
2020-04-27 23:24:31 +00:00
|
|
|
constexpr size_t kExpectedNumberOfPages = 10u;
|
|
|
|
constexpr size_t kObjectSize = 8u;
|
|
|
|
using Type = GCed<kObjectSize>;
|
|
|
|
static const size_t kNumberOfObjects =
|
|
|
|
(kExpectedNumberOfPages * NormalPage::PayloadSize() /
|
2020-05-06 15:44:06 +00:00
|
|
|
(sizeof(Type) + sizeof(HeapObjectHeader))) -
|
|
|
|
kExpectedNumberOfPages;
|
2020-04-27 23:24:31 +00:00
|
|
|
|
|
|
|
std::vector<Persistent<Type>> persistents(kNumberOfObjects);
|
|
|
|
for (auto& p : persistents) {
|
|
|
|
p = MakeGarbageCollected<Type>(GetHeap());
|
|
|
|
}
|
|
|
|
|
|
|
|
const RawHeap& heap = GetRawHeap();
|
|
|
|
const BaseSpace* space = heap.Space(SpaceType::kNormal1);
|
|
|
|
EXPECT_EQ(kExpectedNumberOfPages, space->size());
|
|
|
|
|
|
|
|
size_t page_n = 0;
|
|
|
|
for (const BasePage* page : *space) {
|
|
|
|
EXPECT_FALSE(page->is_large());
|
|
|
|
EXPECT_EQ(space, page->space());
|
|
|
|
++page_n;
|
|
|
|
}
|
|
|
|
EXPECT_EQ(page_n, space->size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PageTest, LargePageIndexing) {
|
2020-05-07 20:36:03 +00:00
|
|
|
using SpaceType = RawHeap::RegularSpaceType;
|
2020-04-27 23:24:31 +00:00
|
|
|
constexpr size_t kExpectedNumberOfPages = 10u;
|
|
|
|
constexpr size_t kObjectSize = 2 * kLargeObjectSizeThreshold;
|
|
|
|
using Type = GCed<kObjectSize>;
|
|
|
|
const size_t kNumberOfObjects = kExpectedNumberOfPages;
|
|
|
|
|
|
|
|
std::vector<Persistent<Type>> persistents(kNumberOfObjects);
|
|
|
|
for (auto& p : persistents) {
|
|
|
|
p = MakeGarbageCollected<Type>(GetHeap());
|
|
|
|
}
|
|
|
|
|
|
|
|
const RawHeap& heap = GetRawHeap();
|
|
|
|
const BaseSpace* space = heap.Space(SpaceType::kLarge);
|
|
|
|
EXPECT_EQ(kExpectedNumberOfPages, space->size());
|
|
|
|
|
|
|
|
size_t page_n = 0;
|
|
|
|
for (const BasePage* page : *space) {
|
|
|
|
EXPECT_TRUE(page->is_large());
|
|
|
|
++page_n;
|
|
|
|
}
|
|
|
|
EXPECT_EQ(page_n, space->size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PageTest, HeapObjectHeaderOnBasePageIndexing) {
|
|
|
|
constexpr size_t kObjectSize = 8;
|
|
|
|
using Type = GCed<kObjectSize>;
|
|
|
|
const size_t kNumberOfObjects =
|
|
|
|
NormalPage::PayloadSize() / (sizeof(Type) + sizeof(HeapObjectHeader));
|
|
|
|
const size_t kLeftSpace =
|
|
|
|
NormalPage::PayloadSize() % (sizeof(Type) + sizeof(HeapObjectHeader));
|
|
|
|
|
|
|
|
std::vector<Persistent<Type>> persistents(kNumberOfObjects);
|
|
|
|
for (auto& p : persistents) {
|
|
|
|
p = MakeGarbageCollected<Type>(GetHeap());
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto* page =
|
|
|
|
static_cast<NormalPage*>(BasePage::FromPayload(persistents[0].Get()));
|
|
|
|
size_t size = 0;
|
|
|
|
size_t num = 0;
|
|
|
|
for (const HeapObjectHeader& header : *page) {
|
|
|
|
EXPECT_EQ(reinterpret_cast<Address>(persistents[num].Get()),
|
|
|
|
header.Payload());
|
|
|
|
size += header.GetSize();
|
|
|
|
++num;
|
|
|
|
}
|
|
|
|
EXPECT_EQ(num, persistents.size());
|
|
|
|
EXPECT_EQ(size + kLeftSpace, NormalPage::PayloadSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PageTest, HeapObjectHeaderOnLargePageIndexing) {
|
|
|
|
constexpr size_t kObjectSize = 2 * kLargeObjectSizeThreshold;
|
|
|
|
using Type = GCed<kObjectSize>;
|
|
|
|
auto* gced = MakeGarbageCollected<Type>(GetHeap());
|
|
|
|
|
|
|
|
const auto* page = static_cast<LargePage*>(BasePage::FromPayload(gced));
|
|
|
|
const size_t expected_payload_size =
|
|
|
|
RoundUp(sizeof(Type) + sizeof(HeapObjectHeader), kAllocationGranularity);
|
|
|
|
EXPECT_EQ(expected_payload_size, page->PayloadSize());
|
|
|
|
|
|
|
|
const HeapObjectHeader* header = page->ObjectHeader();
|
|
|
|
EXPECT_EQ(reinterpret_cast<Address>(gced), header->Payload());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PageTest, NormalPageCreationDestruction) {
|
|
|
|
RawHeap& heap = GetRawHeap();
|
|
|
|
const PageBackend* backend = Heap::From(GetHeap())->page_backend();
|
2020-05-07 20:36:03 +00:00
|
|
|
auto* space = static_cast<NormalPageSpace*>(
|
|
|
|
heap.Space(RawHeap::RegularSpaceType::kNormal1));
|
2020-06-10 07:10:20 +00:00
|
|
|
auto* page = NormalPage::Create(GetPageBackend(), space);
|
|
|
|
EXPECT_NE(nullptr, backend->Lookup(page->PayloadStart()));
|
|
|
|
|
|
|
|
space->AddPage(page);
|
2020-04-27 23:24:31 +00:00
|
|
|
EXPECT_NE(space->end(), std::find(space->begin(), space->end(), page));
|
2020-06-10 07:10:20 +00:00
|
|
|
|
|
|
|
space->free_list().Add({page->PayloadStart(), page->PayloadSize()});
|
2020-04-27 23:24:31 +00:00
|
|
|
EXPECT_TRUE(
|
|
|
|
space->free_list().Contains({page->PayloadStart(), page->PayloadSize()}));
|
|
|
|
|
|
|
|
space->free_list().Clear();
|
|
|
|
EXPECT_FALSE(
|
|
|
|
space->free_list().Contains({page->PayloadStart(), page->PayloadSize()}));
|
|
|
|
space->RemovePage(page);
|
|
|
|
EXPECT_EQ(space->end(), std::find(space->begin(), space->end(), page));
|
|
|
|
NormalPage::Destroy(page);
|
|
|
|
EXPECT_EQ(nullptr, backend->Lookup(page->PayloadStart()));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(PageTest, LargePageCreationDestruction) {
|
|
|
|
constexpr size_t kObjectSize = 2 * kLargeObjectSizeThreshold;
|
|
|
|
RawHeap& heap = GetRawHeap();
|
|
|
|
const PageBackend* backend = Heap::From(GetHeap())->page_backend();
|
2020-05-07 20:36:03 +00:00
|
|
|
auto* space = static_cast<LargePageSpace*>(
|
|
|
|
heap.Space(RawHeap::RegularSpaceType::kLarge));
|
2020-06-10 07:10:20 +00:00
|
|
|
auto* page = LargePage::Create(GetPageBackend(), space, kObjectSize);
|
2020-04-27 23:24:31 +00:00
|
|
|
EXPECT_NE(nullptr, backend->Lookup(page->PayloadStart()));
|
|
|
|
|
2020-06-10 07:10:20 +00:00
|
|
|
space->AddPage(page);
|
|
|
|
EXPECT_NE(space->end(), std::find(space->begin(), space->end(), page));
|
|
|
|
|
2020-04-27 23:24:31 +00:00
|
|
|
space->RemovePage(page);
|
|
|
|
EXPECT_EQ(space->end(), std::find(space->begin(), space->end(), page));
|
|
|
|
LargePage::Destroy(page);
|
|
|
|
EXPECT_EQ(nullptr, backend->Lookup(page->PayloadStart()));
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
TEST_F(PageTest, UnsweptPageDestruction) {
|
|
|
|
RawHeap& heap = GetRawHeap();
|
|
|
|
{
|
2020-05-07 20:36:03 +00:00
|
|
|
auto* space = static_cast<NormalPageSpace*>(
|
|
|
|
heap.Space(RawHeap::RegularSpaceType::kNormal1));
|
2020-06-10 07:10:20 +00:00
|
|
|
auto* page = NormalPage::Create(GetPageBackend(), space);
|
|
|
|
space->AddPage(page);
|
2020-04-27 23:24:31 +00:00
|
|
|
EXPECT_DEATH_IF_SUPPORTED(NormalPage::Destroy(page), "");
|
|
|
|
}
|
|
|
|
{
|
2020-05-07 20:36:03 +00:00
|
|
|
auto* space = static_cast<LargePageSpace*>(
|
|
|
|
heap.Space(RawHeap::RegularSpaceType::kLarge));
|
2020-06-10 07:10:20 +00:00
|
|
|
auto* page = LargePage::Create(GetPageBackend(), space,
|
|
|
|
2 * kLargeObjectSizeThreshold);
|
|
|
|
space->AddPage(page);
|
2020-04-27 23:24:31 +00:00
|
|
|
EXPECT_DEATH_IF_SUPPORTED(LargePage::Destroy(page), "");
|
2020-05-05 21:34:20 +00:00
|
|
|
// Detach page and really destroy page in the parent process so that sweeper
|
|
|
|
// doesn't consider it.
|
|
|
|
space->RemovePage(page);
|
|
|
|
LargePage::Destroy(page);
|
2020-04-27 23:24:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-05-13 10:35:58 +00:00
|
|
|
TEST_F(PageTest, ObjectHeaderFromInnerAddress) {
|
|
|
|
{
|
|
|
|
auto* object = MakeGarbageCollected<GCed<64>>(GetHeap());
|
|
|
|
const HeapObjectHeader& expected = HeapObjectHeader::FromPayload(object);
|
|
|
|
|
|
|
|
for (auto* inner_ptr = reinterpret_cast<ConstAddress>(object);
|
|
|
|
inner_ptr < reinterpret_cast<ConstAddress>(object + 1); ++inner_ptr) {
|
Reland "cppgc: Stack scanning using ObjectStartBitmap"
This reverts commit 580917d252da46a95114089cfc6407050542d363.
Reason for revert: fix in patchset 2
Original change's description:
> Revert "cppgc: Stack scanning using ObjectStartBitmap"
>
> This reverts commit d3a72e3c2a23167d7ddc8cb7ffb541e23bfb9dcd.
>
> Reason for revert: MSAN failures (https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20MSAN/32360)
>
> Original change's description:
> > cppgc: Stack scanning using ObjectStartBitmap
> >
> > This CL implements stack scanning for cppgc.
> > Given a value on the stack, the MarkingVisitor uses
> > PageBackend::Lookup to checks whether that address is on
> > the heap. If it is, BasePage::TryObjectHeaderFromInnerAddress
> > (introduced in this CL) is used to get the relevant object
> > header. Note that random addresses on the heap might point to
> > free memory, object-start-bitmap, etc.
> >
> > If a valid object header is found:
> > * If the object is not in construction, the GCInfoIndex is used
> > the get the relevant Trace method and the object is traced.
> > * Otherwise, the object is conservatively scanned - i.e. the
> > payload of the object is iterated word by word and each word is
> > treated as a possible pointer.
> >
> > Only addresses pointing to the payload on non-free objects are
> > traced.
> >
> > BasePage::TryObjectHeaderFromInnerAddress assumes on LAB on the
> > relevant space, thus all LABs are reset before scanning the stack.
> >
> > Bug: chromium:1056170
> > Change-Id: I172850f6f1bbb6f0efca8e44ad8fdfe222977b9f
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190426
> > Commit-Queue: Omer Katz <omerkatz@chromium.org>
> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#67795}
>
> TBR=ulan@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
>
> Change-Id: I3caef6f9f55911fd1a86e895c3495d1b98b1eac2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1056170
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201136
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Commit-Queue: Leszek Swirski <leszeks@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67796}
TBR=ulan@chromium.org,mlippautz@chromium.org,leszeks@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
# Not skipping CQ checks because this is a reland.
Bug: chromium:1056170
Change-Id: If7ea4fe5cb794c07544d5545f5d6548e3375d3ae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201137
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67803}
2020-05-14 11:26:29 +00:00
|
|
|
const HeapObjectHeader& hoh =
|
2020-05-13 10:35:58 +00:00
|
|
|
BasePage::FromPayload(object)->ObjectHeaderFromInnerAddress(
|
|
|
|
inner_ptr);
|
Reland "cppgc: Stack scanning using ObjectStartBitmap"
This reverts commit 580917d252da46a95114089cfc6407050542d363.
Reason for revert: fix in patchset 2
Original change's description:
> Revert "cppgc: Stack scanning using ObjectStartBitmap"
>
> This reverts commit d3a72e3c2a23167d7ddc8cb7ffb541e23bfb9dcd.
>
> Reason for revert: MSAN failures (https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20MSAN/32360)
>
> Original change's description:
> > cppgc: Stack scanning using ObjectStartBitmap
> >
> > This CL implements stack scanning for cppgc.
> > Given a value on the stack, the MarkingVisitor uses
> > PageBackend::Lookup to checks whether that address is on
> > the heap. If it is, BasePage::TryObjectHeaderFromInnerAddress
> > (introduced in this CL) is used to get the relevant object
> > header. Note that random addresses on the heap might point to
> > free memory, object-start-bitmap, etc.
> >
> > If a valid object header is found:
> > * If the object is not in construction, the GCInfoIndex is used
> > the get the relevant Trace method and the object is traced.
> > * Otherwise, the object is conservatively scanned - i.e. the
> > payload of the object is iterated word by word and each word is
> > treated as a possible pointer.
> >
> > Only addresses pointing to the payload on non-free objects are
> > traced.
> >
> > BasePage::TryObjectHeaderFromInnerAddress assumes on LAB on the
> > relevant space, thus all LABs are reset before scanning the stack.
> >
> > Bug: chromium:1056170
> > Change-Id: I172850f6f1bbb6f0efca8e44ad8fdfe222977b9f
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190426
> > Commit-Queue: Omer Katz <omerkatz@chromium.org>
> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#67795}
>
> TBR=ulan@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
>
> Change-Id: I3caef6f9f55911fd1a86e895c3495d1b98b1eac2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1056170
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201136
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Commit-Queue: Leszek Swirski <leszeks@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67796}
TBR=ulan@chromium.org,mlippautz@chromium.org,leszeks@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
# Not skipping CQ checks because this is a reland.
Bug: chromium:1056170
Change-Id: If7ea4fe5cb794c07544d5545f5d6548e3375d3ae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201137
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67803}
2020-05-14 11:26:29 +00:00
|
|
|
EXPECT_EQ(&expected, &hoh);
|
2020-05-13 10:35:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
auto* object =
|
|
|
|
MakeGarbageCollected<GCed<2 * kLargeObjectSizeThreshold>>(GetHeap());
|
|
|
|
const HeapObjectHeader& expected = HeapObjectHeader::FromPayload(object);
|
|
|
|
|
Reland "cppgc: Stack scanning using ObjectStartBitmap"
This reverts commit 580917d252da46a95114089cfc6407050542d363.
Reason for revert: fix in patchset 2
Original change's description:
> Revert "cppgc: Stack scanning using ObjectStartBitmap"
>
> This reverts commit d3a72e3c2a23167d7ddc8cb7ffb541e23bfb9dcd.
>
> Reason for revert: MSAN failures (https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20MSAN/32360)
>
> Original change's description:
> > cppgc: Stack scanning using ObjectStartBitmap
> >
> > This CL implements stack scanning for cppgc.
> > Given a value on the stack, the MarkingVisitor uses
> > PageBackend::Lookup to checks whether that address is on
> > the heap. If it is, BasePage::TryObjectHeaderFromInnerAddress
> > (introduced in this CL) is used to get the relevant object
> > header. Note that random addresses on the heap might point to
> > free memory, object-start-bitmap, etc.
> >
> > If a valid object header is found:
> > * If the object is not in construction, the GCInfoIndex is used
> > the get the relevant Trace method and the object is traced.
> > * Otherwise, the object is conservatively scanned - i.e. the
> > payload of the object is iterated word by word and each word is
> > treated as a possible pointer.
> >
> > Only addresses pointing to the payload on non-free objects are
> > traced.
> >
> > BasePage::TryObjectHeaderFromInnerAddress assumes on LAB on the
> > relevant space, thus all LABs are reset before scanning the stack.
> >
> > Bug: chromium:1056170
> > Change-Id: I172850f6f1bbb6f0efca8e44ad8fdfe222977b9f
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190426
> > Commit-Queue: Omer Katz <omerkatz@chromium.org>
> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#67795}
>
> TBR=ulan@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
>
> Change-Id: I3caef6f9f55911fd1a86e895c3495d1b98b1eac2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1056170
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201136
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Commit-Queue: Leszek Swirski <leszeks@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67796}
TBR=ulan@chromium.org,mlippautz@chromium.org,leszeks@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
# Not skipping CQ checks because this is a reland.
Bug: chromium:1056170
Change-Id: If7ea4fe5cb794c07544d5545f5d6548e3375d3ae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201137
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67803}
2020-05-14 11:26:29 +00:00
|
|
|
const HeapObjectHeader& hoh =
|
2020-05-13 10:35:58 +00:00
|
|
|
BasePage::FromPayload(object)->ObjectHeaderFromInnerAddress(
|
|
|
|
reinterpret_cast<ConstAddress>(object) + kLargeObjectSizeThreshold);
|
Reland "cppgc: Stack scanning using ObjectStartBitmap"
This reverts commit 580917d252da46a95114089cfc6407050542d363.
Reason for revert: fix in patchset 2
Original change's description:
> Revert "cppgc: Stack scanning using ObjectStartBitmap"
>
> This reverts commit d3a72e3c2a23167d7ddc8cb7ffb541e23bfb9dcd.
>
> Reason for revert: MSAN failures (https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20MSAN/32360)
>
> Original change's description:
> > cppgc: Stack scanning using ObjectStartBitmap
> >
> > This CL implements stack scanning for cppgc.
> > Given a value on the stack, the MarkingVisitor uses
> > PageBackend::Lookup to checks whether that address is on
> > the heap. If it is, BasePage::TryObjectHeaderFromInnerAddress
> > (introduced in this CL) is used to get the relevant object
> > header. Note that random addresses on the heap might point to
> > free memory, object-start-bitmap, etc.
> >
> > If a valid object header is found:
> > * If the object is not in construction, the GCInfoIndex is used
> > the get the relevant Trace method and the object is traced.
> > * Otherwise, the object is conservatively scanned - i.e. the
> > payload of the object is iterated word by word and each word is
> > treated as a possible pointer.
> >
> > Only addresses pointing to the payload on non-free objects are
> > traced.
> >
> > BasePage::TryObjectHeaderFromInnerAddress assumes on LAB on the
> > relevant space, thus all LABs are reset before scanning the stack.
> >
> > Bug: chromium:1056170
> > Change-Id: I172850f6f1bbb6f0efca8e44ad8fdfe222977b9f
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2190426
> > Commit-Queue: Omer Katz <omerkatz@chromium.org>
> > Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Reviewed-by: Anton Bikineev <bikineev@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#67795}
>
> TBR=ulan@chromium.org,mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
>
> Change-Id: I3caef6f9f55911fd1a86e895c3495d1b98b1eac2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1056170
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201136
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Commit-Queue: Leszek Swirski <leszeks@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67796}
TBR=ulan@chromium.org,mlippautz@chromium.org,leszeks@chromium.org,bikineev@chromium.org,omerkatz@chromium.org
# Not skipping CQ checks because this is a reland.
Bug: chromium:1056170
Change-Id: If7ea4fe5cb794c07544d5545f5d6548e3375d3ae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2201137
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67803}
2020-05-14 11:26:29 +00:00
|
|
|
EXPECT_EQ(&expected, &hoh);
|
2020-05-13 10:35:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-09 07:18:50 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace cppgc
|