summaryrefslogtreecommitdiffstats
path: root/chromium/v8/src/compiler/js-heap-broker-inl.h
blob: f0e392e3df6cb1d30fcc3e9bab8fbe413e48f1a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2023 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.

#ifndef V8_COMPILER_JS_HEAP_BROKER_INL_H_
#define V8_COMPILER_JS_HEAP_BROKER_INL_H_

#include "src/compiler/js-heap-broker.h"
#include "src/heap/parked-scope-inl.h"

namespace v8::internal::compiler {

V8_INLINE JSHeapBroker::RecursiveSharedMutexGuardIfNeeded::
    RecursiveSharedMutexGuardIfNeeded(LocalIsolate* local_isolate,
                                      base::SharedMutex* mutex,
                                      int* mutex_depth_address)
    : mutex_depth_address_(mutex_depth_address),
      initial_mutex_depth_(*mutex_depth_address_),
      shared_mutex_guard_(local_isolate, mutex, initial_mutex_depth_ == 0) {
  (*mutex_depth_address_)++;
}

V8_INLINE JSHeapBroker::MapUpdaterGuardIfNeeded::MapUpdaterGuardIfNeeded(
    JSHeapBroker* broker)
    : RecursiveSharedMutexGuardIfNeeded(broker->local_isolate_or_isolate(),
                                        broker->isolate()->map_updater_access(),
                                        &broker->map_updater_mutex_depth_) {}

V8_INLINE JSHeapBroker::BoilerplateMigrationGuardIfNeeded::
    BoilerplateMigrationGuardIfNeeded(JSHeapBroker* broker)
    : RecursiveSharedMutexGuardIfNeeded(
          broker->local_isolate_or_isolate(),
          broker->isolate()->boilerplate_migration_access(),
          &broker->boilerplate_migration_mutex_depth_) {}

}  // namespace v8::internal::compiler

#endif  // V8_COMPILER_JS_HEAP_BROKER_INL_H_