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/+/3468903
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79138}
This commit is contained in:
Michael Lippautz 2022-02-16 16:59:57 +01:00 committed by V8 LUCI CQ
parent 6909711b88
commit f60ae6ed71
4 changed files with 22 additions and 4 deletions

View File

@ -880,6 +880,20 @@ void GlobalHandles::OnStackTracedNodeSpace::CleanupBelowCurrentStackPosition() {
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
void GlobalHandles::TracedNode::Verify(GlobalHandles* global_handles,
const Address* const* slot) {
@ -1172,10 +1186,7 @@ void GlobalHandles::DestroyTraced(Address* location) {
// 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
// atomic pause which requires releasing a node fully.
if (!global_handles->isolate()
->heap()
->incremental_marking()
->IsMarking()) {
if (!global_handles->is_marking_) {
NodeSpace<TracedNode>::Release(node);
return;
}

View File

@ -45,6 +45,9 @@ enum WeaknessType {
// callbacks and finalizers attached to them.
class V8_EXPORT_PRIVATE GlobalHandles final {
public:
static void EnableMarkingBarrier(Isolate*);
static void DisableMarkingBarrier(Isolate*);
GlobalHandles(const GlobalHandles&) = delete;
GlobalHandles& operator=(const GlobalHandles&) = delete;
@ -236,6 +239,7 @@ class V8_EXPORT_PRIVATE GlobalHandles final {
Node* node);
Isolate* const isolate_;
bool is_marking_ = false;
std::unique_ptr<NodeSpace<Node>> regular_nodes_;
// Contains all nodes holding young objects. Note: when the list

View File

@ -6,6 +6,7 @@
#include "src/codegen/compilation-cache.h"
#include "src/execution/vm-state-inl.h"
#include "src/handles/global-handles.h"
#include "src/heap/concurrent-marking.h"
#include "src/heap/embedder-tracing.h"
#include "src/heap/gc-idle-time-handler.h"
@ -251,6 +252,7 @@ void IncrementalMarking::StartMarking() {
SetState(MARKING);
MarkingBarrier::ActivateAll(heap(), is_compacting_);
GlobalHandles::EnableMarkingBarrier(heap()->isolate());
heap_->isolate()->compilation_cache()->MarkCompactPrologue();

View File

@ -2440,6 +2440,7 @@ void MarkCompactCollector::MarkLiveObjects() {
}
if (was_marked_incrementally_) {
MarkingBarrier::DeactivateAll(heap());
GlobalHandles::DisableMarkingBarrier(heap()->isolate());
}
epoch_++;