// 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 INCLUDE_V8_HANDLE_BASE_H_ #define INCLUDE_V8_HANDLE_BASE_H_ #include "v8-internal.h" // NOLINT(build/include_directory) namespace v8 { namespace internal { // Helper functions about values contained in handles. // A value is either an indirect pointer or a direct pointer, depending on // whether direct local support is enabled. class ValueHelper final { public: #ifdef V8_ENABLE_DIRECT_LOCAL static constexpr Address kTaggedNullAddress = 1; static constexpr Address kEmpty = kTaggedNullAddress; #else static constexpr Address kEmpty = kNullAddress; #endif // V8_ENABLE_DIRECT_LOCAL template V8_INLINE static bool IsEmpty(T* value) { return reinterpret_cast
(value) == kEmpty; } // Returns a handle's "value" for all kinds of abstract handles. For Local, // it is equivalent to `*handle`. The variadic parameters support handle // types with extra type parameters, like `Persistent`. template