v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
weak-code-registry.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_PROFILER_WEAK_CODE_REGISTRY_H_
6#define V8_PROFILER_WEAK_CODE_REGISTRY_H_
7
8#include <vector>
9
11#include "src/objects/objects.h"
13
14namespace v8 {
15namespace internal {
16
18 public:
19 struct Listener {
20 virtual void OnHeapObjectDeletion(CodeEntry* entry) = 0;
21 };
22
23 explicit WeakCodeRegistry(Isolate* isolate) : isolate_(isolate) {}
24 ~WeakCodeRegistry() { Clear(); }
25
26 void Track(CodeEntry* entry, DirectHandle<AbstractCode> code);
27
28 // Removes all dead code objects from the registry, invoking the provided
29 // listener for each new CodeEntry that is no longer referenced on the heap
30 // (if set).
31 void Sweep(Listener* listener);
32
33 // Removes all heap object tracking from stored CodeEntries.
34 void Clear();
35
36 private:
38 // Invariant: Entries will always be removed here before the
39 // InstructionStreamMap is destroyed. CodeEntries should not be freed while
40 // their heap objects exist.
41 std::vector<CodeEntry*> entries_;
42};
43
44} // namespace internal
45} // namespace v8
46
47#endif // V8_PROFILER_WEAK_CODE_REGISTRY_H_
Isolate * isolate_
std::vector< CodeEntry * > entries_
#define V8_EXPORT_PRIVATE
Definition macros.h:460
virtual void OnHeapObjectDeletion(CodeEntry *entry)=0