Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-06 10:14:47

0001 // Copyright 2021 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef INCLUDE_V8_EMBEDDER_HEAP_H_
0006 #define INCLUDE_V8_EMBEDDER_HEAP_H_
0007 
0008 #include "v8-traced-handle.h"  // NOLINT(build/include_directory)
0009 #include "v8config.h"          // NOLINT(build/include_directory)
0010 
0011 namespace v8 {
0012 namespace internal {
0013 class TracedHandles;
0014 }  // namespace internal
0015 
0016 class Isolate;
0017 class Value;
0018 
0019 /**
0020  * Handler for embedder roots on non-unified heap garbage collections.
0021  */
0022 class V8_EXPORT EmbedderRootsHandler {
0023  public:
0024   virtual ~EmbedderRootsHandler() = default;
0025 
0026   EmbedderRootsHandler() = default;
0027 
0028   /**
0029    * Used in combination with |IsRoot|. Called by V8 when an
0030    * object that is backed by a handle is reclaimed by a non-tracing garbage
0031    * collection. It is up to the embedder to reset the original handle.
0032    *
0033    * Note that the |handle| is different from the handle that the embedder holds
0034    * for retaining the object. It is up to the embedder to find the original
0035    * handle via the object or class id.
0036    */
0037   virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
0038 
0039   /**
0040    * Similar to |ResetRoot()|, but opportunistic. The function is called in
0041    * parallel for different handles and as such must be thread-safe. In case,
0042    * |false| is returned, |ResetRoot()| will be recalled for the same handle.
0043    */
0044   virtual bool TryResetRoot(const v8::TracedReference<v8::Value>& handle) {
0045     return false;
0046   }
0047 
0048  private:
0049   friend class internal::TracedHandles;
0050 };
0051 
0052 }  // namespace v8
0053 
0054 #endif  // INCLUDE_V8_EMBEDDER_HEAP_H_