summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/heap/unified_heap_marking_visitor.h
blob: 32c88b955197317e79b23c8e43e9cc168a61760f (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
39
40
41
42
43
44
45
46
47
// Copyright 2018 The Chromium 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_UNIFIED_HEAP_MARKING_VISITOR_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_UNIFIED_HEAP_MARKING_VISITOR_H_

#include "base/macros.h"
#include "third_party/blink/renderer/platform/heap/marking_visitor.h"

namespace blink {

struct WrapperTypeInfo;

// Marking visitor for unified heap garbage collections. Extends the regular
// Oilpan marking visitor by also providing write barriers and visitation
// methods that allow for announcing reachable objects to V8.
class PLATFORM_EXPORT UnifiedHeapMarkingVisitor final : public MarkingVisitor {
 public:
  static std::unique_ptr<UnifiedHeapMarkingVisitor> Create(ThreadState*,
                                                           MarkingMode,
                                                           v8::Isolate*);
  // Write barriers for annotating a write during incremental marking.
  static void WriteBarrier(v8::Isolate*,
                           const TraceWrapperV8Reference<v8::Value>&);
  static void WriteBarrier(v8::Isolate*,
                           DOMWrapperMap<ScriptWrappable>*,
                           ScriptWrappable*);
  static void WriteBarrier(v8::Isolate*, const WrapperTypeInfo*, void*);

  ~UnifiedHeapMarkingVisitor() override = default;

  // Visitation methods that announce reachable wrappers to V8.
  void Visit(const TraceWrapperV8Reference<v8::Value>&) final;
  void Visit(DOMWrapperMap<ScriptWrappable>*, const ScriptWrappable*) final;

 private:
  UnifiedHeapMarkingVisitor(ThreadState*, MarkingMode, v8::Isolate*);

  v8::Isolate* const isolate_;

  DISALLOW_COPY_AND_ASSIGN(UnifiedHeapMarkingVisitor);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_UNIFIED_HEAP_MARKING_VISITOR_H_