[heap] Move base::List to heap::List
base::List is only used inside of heap and has some pretty strange semantics that don't lend themselves to it being a general purpose data structure so this moves it to heap where it can be safe isolated. Bug: v8:10454 Change-Id: I7921c22286276432956005c72143b22b0364fc93 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2170029 Auto-Submit: Dan Elphick <delphick@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#67448}
This commit is contained in:
parent
b98b462163
commit
9827c7168b
2
BUILD.gn
2
BUILD.gn
@ -2411,6 +2411,7 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/heap/invalidated-slots.h",
|
||||
"src/heap/item-parallel-job.cc",
|
||||
"src/heap/item-parallel-job.h",
|
||||
"src/heap/list.h",
|
||||
"src/heap/local-allocator-inl.h",
|
||||
"src/heap/local-allocator.h",
|
||||
"src/heap/local-heap.cc",
|
||||
@ -3733,7 +3734,6 @@ v8_component("v8_libbase") {
|
||||
"src/base/ieee754.h",
|
||||
"src/base/iterator.h",
|
||||
"src/base/lazy-instance.h",
|
||||
"src/base/list.h",
|
||||
"src/base/logging.cc",
|
||||
"src/base/logging.h",
|
||||
"src/base/lsan.h",
|
||||
|
@ -2,15 +2,16 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_BASE_LIST_H_
|
||||
#define V8_BASE_LIST_H_
|
||||
#ifndef V8_HEAP_LIST_H_
|
||||
#define V8_HEAP_LIST_H_
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include "src/base/logging.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
namespace internal {
|
||||
namespace heap {
|
||||
|
||||
template <class T>
|
||||
class List {
|
||||
@ -142,7 +143,8 @@ class ListNode {
|
||||
|
||||
friend class List<T>;
|
||||
};
|
||||
} // namespace base
|
||||
} // namespace heap
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_BASE_LIST_H_
|
||||
#endif // V8_HEAP_LIST_H_
|
@ -4048,7 +4048,7 @@ void ReadOnlyArtifacts::set_read_only_heap(
|
||||
SharedReadOnlySpace::~SharedReadOnlySpace() {
|
||||
// Clear the memory chunk list before the space is deleted, so that the
|
||||
// inherited destructors don't try to destroy the MemoryChunks themselves.
|
||||
memory_chunk_list_ = base::List<MemoryChunk>();
|
||||
memory_chunk_list_ = heap::List<MemoryChunk>();
|
||||
}
|
||||
|
||||
SharedReadOnlySpace::SharedReadOnlySpace(
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "src/base/bounded-page-allocator.h"
|
||||
#include "src/base/export-template.h"
|
||||
#include "src/base/iterator.h"
|
||||
#include "src/base/list.h"
|
||||
#include "src/base/macros.h"
|
||||
#include "src/base/optional.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
@ -26,6 +25,7 @@
|
||||
#include "src/heap/basic-memory-chunk.h"
|
||||
#include "src/heap/heap.h"
|
||||
#include "src/heap/invalidated-slots.h"
|
||||
#include "src/heap/list.h"
|
||||
#include "src/heap/marking.h"
|
||||
#include "src/heap/slot-set.h"
|
||||
#include "src/objects/free-space.h"
|
||||
@ -497,7 +497,7 @@ class V8_EXPORT_PRIVATE Space : public Malloced {
|
||||
MemoryChunk* first_page() { return memory_chunk_list_.front(); }
|
||||
MemoryChunk* last_page() { return memory_chunk_list_.back(); }
|
||||
|
||||
base::List<MemoryChunk>& memory_chunk_list() { return memory_chunk_list_; }
|
||||
heap::List<MemoryChunk>& memory_chunk_list() { return memory_chunk_list_; }
|
||||
|
||||
FreeList* free_list() { return free_list_.get(); }
|
||||
|
||||
@ -516,7 +516,7 @@ class V8_EXPORT_PRIVATE Space : public Malloced {
|
||||
std::vector<AllocationObserver*> allocation_observers_;
|
||||
|
||||
// The List manages the pages that belong to the given space.
|
||||
base::List<MemoryChunk> memory_chunk_list_;
|
||||
heap::List<MemoryChunk> memory_chunk_list_;
|
||||
|
||||
// Tracks off-heap memory used by this space.
|
||||
std::atomic<size_t>* external_backing_store_bytes_;
|
||||
@ -627,7 +627,7 @@ class MemoryChunk : public BasicMemoryChunk {
|
||||
// std::atomic<size_t> external_backing_store_bytes_
|
||||
+ kSizetSize // size_t allocated_bytes_
|
||||
+ kSizetSize // size_t wasted_memory_
|
||||
+ kSystemPointerSize * 2 // base::ListNode
|
||||
+ kSystemPointerSize * 2 // heap::ListNode
|
||||
+ kSystemPointerSize // FreeListCategory** categories__
|
||||
+ kSystemPointerSize // LocalArrayBufferTracker* local_tracker_
|
||||
+ kIntptrSize // std::atomic<intptr_t> young_generation_live_byte_count_
|
||||
@ -877,7 +877,7 @@ class MemoryChunk : public BasicMemoryChunk {
|
||||
}
|
||||
}
|
||||
|
||||
base::ListNode<MemoryChunk>& list_node() { return list_node_; }
|
||||
heap::ListNode<MemoryChunk>& list_node() { return list_node_; }
|
||||
|
||||
CodeObjectRegistry* GetCodeObjectRegistry() { return code_object_registry_; }
|
||||
|
||||
@ -971,7 +971,7 @@ class MemoryChunk : public BasicMemoryChunk {
|
||||
// Freed memory that was not added to the free list.
|
||||
size_t wasted_memory_;
|
||||
|
||||
base::ListNode<MemoryChunk> list_node_;
|
||||
heap::ListNode<MemoryChunk> list_node_;
|
||||
|
||||
FreeListCategory** categories_;
|
||||
|
||||
@ -3251,8 +3251,8 @@ class ReadOnlyArtifacts {
|
||||
return shared_read_only_space_.get();
|
||||
}
|
||||
|
||||
base::List<MemoryChunk>& pages() { return pages_; }
|
||||
void TransferPages(base::List<MemoryChunk>&& pages) {
|
||||
heap::List<MemoryChunk>& pages() { return pages_; }
|
||||
void TransferPages(heap::List<MemoryChunk>&& pages) {
|
||||
pages_ = std::move(pages);
|
||||
}
|
||||
|
||||
@ -3262,7 +3262,7 @@ class ReadOnlyArtifacts {
|
||||
ReadOnlyHeap* read_only_heap() { return read_only_heap_.get(); }
|
||||
|
||||
private:
|
||||
base::List<MemoryChunk> pages_;
|
||||
heap::List<MemoryChunk> pages_;
|
||||
AllocationStats stats_;
|
||||
std::unique_ptr<SharedReadOnlySpace> shared_read_only_space_;
|
||||
std::unique_ptr<ReadOnlyHeap> read_only_heap_;
|
||||
|
@ -134,7 +134,6 @@ v8_source_set("unittests_sources") {
|
||||
"base/functional-unittest.cc",
|
||||
"base/ieee754-unittest.cc",
|
||||
"base/iterator-unittest.cc",
|
||||
"base/list-unittest.cc",
|
||||
"base/logging-unittest.cc",
|
||||
"base/macros-unittest.cc",
|
||||
"base/ostreams-unittest.cc",
|
||||
@ -227,6 +226,7 @@ v8_source_set("unittests_sources") {
|
||||
"heap/heap-controller-unittest.cc",
|
||||
"heap/heap-unittest.cc",
|
||||
"heap/item-parallel-job-unittest.cc",
|
||||
"heap/list-unittest.cc",
|
||||
"heap/local-heap-unittest.cc",
|
||||
"heap/marking-unittest.cc",
|
||||
"heap/marking-worklist-unittest.cc",
|
||||
|
@ -2,16 +2,17 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/base/list.h"
|
||||
#include "src/heap/list.h"
|
||||
#include "testing/gtest-support.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace base {
|
||||
namespace internal {
|
||||
namespace heap {
|
||||
|
||||
class TestChunk {
|
||||
public:
|
||||
base::ListNode<TestChunk>& list_node() { return list_node_; }
|
||||
base::ListNode<TestChunk> list_node_;
|
||||
heap::ListNode<TestChunk>& list_node() { return list_node_; }
|
||||
heap::ListNode<TestChunk> list_node_;
|
||||
};
|
||||
|
||||
TEST(List, InsertAtTailAndRemove) {
|
||||
@ -88,5 +89,6 @@ TEST(List, InsertMultipleAtTailAndRemoveFromMiddle) {
|
||||
EXPECT_TRUE(list.Empty());
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
} // namespace heap
|
||||
} // namespace internal
|
||||
} // namespace v8
|
Loading…
Reference in New Issue
Block a user