[handles] Improve node bounds allocation

Reserve node bounds upfront instead of growing the vector.

Bug: v8:13372, chromium:1379837
Change-Id: Ibf2e9b984c476358f9f5cc7f11feeac620ae40ae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3998817
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84010}
This commit is contained in:
Michael Lippautz 2022-11-02 13:57:52 +01:00 committed by V8 LUCI CQ
parent 2792a669e4
commit c0dba826d8
3 changed files with 6 additions and 5 deletions

View File

@ -414,7 +414,7 @@ class TracedHandlesImpl final {
void SetIsMarking(bool);
void SetIsSweepingOnMutatorThread(bool);
TracedHandles::NodeBounds GetNodeBounds() const;
const TracedHandles::NodeBounds GetNodeBounds() const;
void UpdateListOfYoungNodes();
void ClearListOfYoungNodes();
@ -592,8 +592,9 @@ void TracedHandlesImpl::SetIsSweepingOnMutatorThread(bool value) {
is_sweeping_on_mutator_thread_ = value;
}
TracedHandles::NodeBounds TracedHandlesImpl::GetNodeBounds() const {
const TracedHandles::NodeBounds TracedHandlesImpl::GetNodeBounds() const {
TracedHandles::NodeBounds block_bounds;
block_bounds.reserve(blocks_.Size());
for (const auto* block : blocks_) {
block_bounds.push_back(
{block->nodes_begin_address(), block->nodes_end_address()});
@ -765,7 +766,7 @@ void TracedHandles::SetIsSweepingOnMutatorThread(bool value) {
impl_->SetIsSweepingOnMutatorThread(value);
}
TracedHandles::NodeBounds TracedHandles::GetNodeBounds() const {
const TracedHandles::NodeBounds TracedHandles::GetNodeBounds() const {
return impl_->GetNodeBounds();
}

View File

@ -45,7 +45,7 @@ class V8_EXPORT_PRIVATE TracedHandles final {
GlobalHandleStoreMode store_mode);
using NodeBounds = std::vector<std::pair<const void*, const void*>>;
NodeBounds GetNodeBounds() const;
const NodeBounds GetNodeBounds() const;
void SetIsMarking(bool);
void SetIsSweepingOnMutatorThread(bool);

View File

@ -27,7 +27,7 @@ class GlobalHandleMarkingVisitor final : public ::heap::base::StackVisitor {
Heap& heap_;
MarkingState& marking_state_;
MarkingWorklists::Local& local_marking_worklist_;
TracedHandles::NodeBounds traced_node_bounds_;
const TracedHandles::NodeBounds traced_node_bounds_;
};
#endif // V8_HEAP_GLOBAL_HANDLE_MARKING_VISITOR_H_