Commit f60ae6ed authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

heap: Speed up GlobalHandles::DestroyTraced

Avoid the lookup via heap()->incremental_marking() and instead cache
the marking state on GlobalHandles itself.

Change-Id: I2665681ad38983bf16d22e0a82dd10743877e520
Bug: chromium:1294661
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3468903Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79138}
parent 6909711b
...@@ -880,6 +880,20 @@ void GlobalHandles::OnStackTracedNodeSpace::CleanupBelowCurrentStackPosition() { ...@@ -880,6 +880,20 @@ void GlobalHandles::OnStackTracedNodeSpace::CleanupBelowCurrentStackPosition() {
on_stack_nodes_.erase(on_stack_nodes_.begin(), it); on_stack_nodes_.erase(on_stack_nodes_.begin(), it);
} }
// static
void GlobalHandles::EnableMarkingBarrier(Isolate* isolate) {
auto* global_handles = isolate->global_handles();
DCHECK(!global_handles->is_marking_);
global_handles->is_marking_ = true;
}
// static
void GlobalHandles::DisableMarkingBarrier(Isolate* isolate) {
auto* global_handles = isolate->global_handles();
DCHECK(global_handles->is_marking_);
global_handles->is_marking_ = false;
}
// static // static
void GlobalHandles::TracedNode::Verify(GlobalHandles* global_handles, void GlobalHandles::TracedNode::Verify(GlobalHandles* global_handles,
const Address* const* slot) { const Address* const* slot) {
...@@ -1172,10 +1186,7 @@ void GlobalHandles::DestroyTraced(Address* location) { ...@@ -1172,10 +1186,7 @@ void GlobalHandles::DestroyTraced(Address* location) {
// When marking is off the handle may be freed immediately. Note that this // When marking is off the handle may be freed immediately. Note that this
// includes also the case when invoking the first pass callbacks during the // includes also the case when invoking the first pass callbacks during the
// atomic pause which requires releasing a node fully. // atomic pause which requires releasing a node fully.
if (!global_handles->isolate() if (!global_handles->is_marking_) {
->heap()
->incremental_marking()
->IsMarking()) {
NodeSpace<TracedNode>::Release(node); NodeSpace<TracedNode>::Release(node);
return; return;
} }
......
...@@ -45,6 +45,9 @@ enum WeaknessType { ...@@ -45,6 +45,9 @@ enum WeaknessType {
// callbacks and finalizers attached to them. // callbacks and finalizers attached to them.
class V8_EXPORT_PRIVATE GlobalHandles final { class V8_EXPORT_PRIVATE GlobalHandles final {
public: public:
static void EnableMarkingBarrier(Isolate*);
static void DisableMarkingBarrier(Isolate*);
GlobalHandles(const GlobalHandles&) = delete; GlobalHandles(const GlobalHandles&) = delete;
GlobalHandles& operator=(const GlobalHandles&) = delete; GlobalHandles& operator=(const GlobalHandles&) = delete;
...@@ -236,6 +239,7 @@ class V8_EXPORT_PRIVATE GlobalHandles final { ...@@ -236,6 +239,7 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
Node* node); Node* node);
Isolate* const isolate_; Isolate* const isolate_;
bool is_marking_ = false;
std::unique_ptr<NodeSpace<Node>> regular_nodes_; std::unique_ptr<NodeSpace<Node>> regular_nodes_;
// Contains all nodes holding young objects. Note: when the list // Contains all nodes holding young objects. Note: when the list
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "src/codegen/compilation-cache.h" #include "src/codegen/compilation-cache.h"
#include "src/execution/vm-state-inl.h" #include "src/execution/vm-state-inl.h"
#include "src/handles/global-handles.h"
#include "src/heap/concurrent-marking.h" #include "src/heap/concurrent-marking.h"
#include "src/heap/embedder-tracing.h" #include "src/heap/embedder-tracing.h"
#include "src/heap/gc-idle-time-handler.h" #include "src/heap/gc-idle-time-handler.h"
...@@ -251,6 +252,7 @@ void IncrementalMarking::StartMarking() { ...@@ -251,6 +252,7 @@ void IncrementalMarking::StartMarking() {
SetState(MARKING); SetState(MARKING);
MarkingBarrier::ActivateAll(heap(), is_compacting_); MarkingBarrier::ActivateAll(heap(), is_compacting_);
GlobalHandles::EnableMarkingBarrier(heap()->isolate());
heap_->isolate()->compilation_cache()->MarkCompactPrologue(); heap_->isolate()->compilation_cache()->MarkCompactPrologue();
......
...@@ -2440,6 +2440,7 @@ void MarkCompactCollector::MarkLiveObjects() { ...@@ -2440,6 +2440,7 @@ void MarkCompactCollector::MarkLiveObjects() {
} }
if (was_marked_incrementally_) { if (was_marked_incrementally_) {
MarkingBarrier::DeactivateAll(heap()); MarkingBarrier::DeactivateAll(heap());
GlobalHandles::DisableMarkingBarrier(heap()->isolate());
} }
epoch_++; epoch_++;
......
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