chromium/v8/src/objects/objects-body-descriptors-inl.h

// Copyright 2015 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_OBJECTS_OBJECTS_BODY_DESCRIPTORS_INL_H_
#define V8_OBJECTS_OBJECTS_BODY_DESCRIPTORS_INL_H_

#include <algorithm>

#include "include/v8-internal.h"
#include "src/base/logging.h"
#include "src/codegen/reloc-info.h"
#include "src/common/globals.h"
#include "src/ic/handler-configuration.h"
#include "src/objects/arguments-inl.h"
#include "src/objects/bigint.h"
#include "src/objects/call-site-info-inl.h"
#include "src/objects/call-site-info.h"
#include "src/objects/cell.h"
#include "src/objects/data-handler.h"
#include "src/objects/embedder-data-array-inl.h"
#include "src/objects/fixed-array.h"
#include "src/objects/foreign-inl.h"
#include "src/objects/free-space-inl.h"
#include "src/objects/hash-table.h"
#include "src/objects/heap-number.h"
#include "src/objects/instance-type.h"
#include "src/objects/js-array-buffer.h"
#include "src/objects/js-atomics-synchronization-inl.h"
#include "src/objects/js-collection.h"
#include "src/objects/js-objects.h"
#include "src/objects/js-weak-refs.h"
#include "src/objects/literal-objects.h"
#include "src/objects/megadom-handler-inl.h"
#include "src/objects/objects-body-descriptors.h"
#include "src/objects/ordered-hash-table-inl.h"
#include "src/objects/property-descriptor-object.h"
#include "src/objects/source-text-module.h"
#include "src/objects/swiss-name-dictionary-inl.h"
#include "src/objects/synthetic-module.h"
#include "src/objects/template-objects-inl.h"
#include "src/objects/torque-defined-classes-inl.h"
#include "src/objects/transitions.h"
#include "src/objects/turbofan-types-inl.h"
#include "src/objects/turboshaft-types-inl.h"

#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-objects-inl.h"
#endif  // V8_ENABLE_WEBASSEMBLY

namespace v8 {
namespace internal {

template <int start_offset>
int FlexibleBodyDescriptor<start_offset>::SizeOf(Tagged<Map> map,
                                                 Tagged<HeapObject> object) {}

template <int start_offset>
int FlexibleWeakBodyDescriptor<start_offset>::SizeOf(
    Tagged<Map> map, Tagged<HeapObject> object) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IterateJSObjectBodyImpl(Tagged<Map> map,
                                                 Tagged<HeapObject> obj,
                                                 int start_offset,
                                                 int end_offset,
                                                 ObjectVisitor* v) {}

template <typename ObjectVisitor>
// static
void BodyDescriptorBase::IterateJSObjectBodyWithoutEmbedderFieldsImpl(
    Tagged<Map> map, Tagged<HeapObject> obj, int start_offset, int end_offset,
    ObjectVisitor* v) {}

// This is a BodyDescriptor helper for usage within JSAPIObjectWithEmbedderSlots
// and JSSpecialObject. The class hierarchies are separate but
// `kCppHeapWrappableOffset` is the same for both.
class JSAPIObjectWithEmbedderSlotsOrJSSpecialObjectBodyDescriptor
    : public BodyDescriptorBase {};

class JSAPIObjectWithEmbedderSlots::BodyDescriptor
    : public JSAPIObjectWithEmbedderSlotsOrJSSpecialObjectBodyDescriptor {};

template <typename ObjectVisitor>
DISABLE_CFI_PERF void BodyDescriptorBase::IteratePointers(
    Tagged<HeapObject> obj, int start_offset, int end_offset,
    ObjectVisitor* v) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IteratePointer(Tagged<HeapObject> obj, int offset,
                                        ObjectVisitor* v) {}

template <typename ObjectVisitor>
DISABLE_CFI_PERF void BodyDescriptorBase::IterateMaybeWeakPointers(
    Tagged<HeapObject> obj, int start_offset, int end_offset,
    ObjectVisitor* v) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IterateMaybeWeakPointer(Tagged<HeapObject> obj,
                                                 int offset, ObjectVisitor* v) {}

template <typename ObjectVisitor>
DISABLE_CFI_PERF void BodyDescriptorBase::IterateCustomWeakPointers(
    Tagged<HeapObject> obj, int start_offset, int end_offset,
    ObjectVisitor* v) {}

template <typename ObjectVisitor>
DISABLE_CFI_PERF void BodyDescriptorBase::IterateEphemeron(
    Tagged<HeapObject> obj, int index, int key_offset, int value_offset,
    ObjectVisitor* v) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IterateCustomWeakPointer(Tagged<HeapObject> obj,
                                                  int offset,
                                                  ObjectVisitor* v) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IterateTrustedPointer(Tagged<HeapObject> obj,
                                               int offset, ObjectVisitor* v,
                                               IndirectPointerMode mode,
                                               IndirectPointerTag tag) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IterateCodePointer(Tagged<HeapObject> obj, int offset,
                                            ObjectVisitor* v,
                                            IndirectPointerMode mode) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IterateSelfIndirectPointer(Tagged<HeapObject> obj,
                                                    IndirectPointerTag tag,
                                                    ObjectVisitor* v) {}

template <typename ObjectVisitor>
void BodyDescriptorBase::IterateProtectedPointer(Tagged<HeapObject> obj,
                                                 int offset, ObjectVisitor* v) {}

#ifdef V8_ENABLE_LEAPTIERING
template <typename ObjectVisitor>
void BodyDescriptorBase::IterateJSDispatchEntry(Tagged<HeapObject> obj,
                                                int offset, ObjectVisitor* v) {
  JSDispatchHandle handle = obj->Relaxed_ReadField<JSDispatchHandle>(offset);
  v->VisitJSDispatchTableEntry(obj, handle);
}
#endif  // V8_ENABLE_LEAPTIERING

class HeapNumber::BodyDescriptor final : public DataOnlyBodyDescriptor {};

// This is a descriptor for one/two pointer fillers.
class FreeSpaceFillerBodyDescriptor final : public DataOnlyBodyDescriptor {};

class FreeSpace::BodyDescriptor final : public DataOnlyBodyDescriptor {};

class JSObject::BodyDescriptor final : public BodyDescriptorBase {};

class JSObject::FastBodyDescriptor final : public BodyDescriptorBase {};

class JSDate::BodyDescriptor final : public BodyDescriptorBase {};

class JSRegExp::BodyDescriptor final : public BodyDescriptorBase {};

class RegExpData::BodyDescriptor final : public BodyDescriptorBase {};

class AtomRegExpData::BodyDescriptor final : public BodyDescriptorBase {};

class IrRegExpData::BodyDescriptor final : public BodyDescriptorBase {};

class RegExpDataWrapper::BodyDescriptor final : public BodyDescriptorBase {};

class WeakCell::BodyDescriptor final : public BodyDescriptorBase {};

class JSWeakRef::BodyDescriptor final : public BodyDescriptorBase {};

class JSFinalizationRegistry::BodyDescriptor final : public BodyDescriptorBase {};

class AllocationSite::BodyDescriptor final : public BodyDescriptorBase {};

class JSFunction::BodyDescriptor final : public BodyDescriptorBase {};

class JSArrayBuffer::BodyDescriptor final
    : public JSAPIObjectWithEmbedderSlots::BodyDescriptor {};

class JSArrayBufferView::BodyDescriptor
    : public JSAPIObjectWithEmbedderSlots::BodyDescriptor {};

class JSTypedArray::BodyDescriptor : public JSArrayBufferView::BodyDescriptor {};

class JSDataViewOrRabGsabDataView::BodyDescriptor final
    : public JSArrayBufferView::BodyDescriptor {};

class JSExternalObject::BodyDescriptor final : public BodyDescriptorBase {};

template <typename Derived>
class V8_EXPORT_PRIVATE SmallOrderedHashTable<Derived>::BodyDescriptor final
    : public BodyDescriptorBase {};

class V8_EXPORT_PRIVATE SwissNameDictionary::BodyDescriptor final
    : public BodyDescriptorBase {};

class ByteArray::BodyDescriptor final : public DataOnlyBodyDescriptor {};

class TrustedByteArray::BodyDescriptor final : public DataOnlyBodyDescriptor {};

class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase {};

class BytecodeWrapper::BodyDescriptor final : public BodyDescriptorBase {};

class BigInt::BodyDescriptor final : public DataOnlyBodyDescriptor {};

class FixedDoubleArray::BodyDescriptor final : public DataOnlyBodyDescriptor {};

class FeedbackMetadata::BodyDescriptor final : public DataOnlyBodyDescriptor {};

class PreparseData::BodyDescriptor final : public BodyDescriptorBase {};

class InterpreterData::BodyDescriptor final : public BodyDescriptorBase {};

class UncompiledDataWithoutPreparseData::BodyDescriptor final
    : public BodyDescriptorBase {};

class UncompiledDataWithPreparseData::BodyDescriptor final
    : public BodyDescriptorBase {};

class UncompiledDataWithoutPreparseDataWithJob::BodyDescriptor final
    : public BodyDescriptorBase {};

class UncompiledDataWithPreparseDataAndJob::BodyDescriptor final
    : public BodyDescriptorBase {};

class SharedFunctionInfo::BodyDescriptor final : public BodyDescriptorBase {};

class SharedFunctionInfoWrapper::BodyDescriptor final
    : public BodyDescriptorBase {};

class DebugInfo::BodyDescriptor final : public BodyDescriptorBase {};

class CallSiteInfo::BodyDescriptor final : public BodyDescriptorBase {};

class PrototypeInfo::BodyDescriptor final : public BodyDescriptorBase {};

class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase {};

class JSSynchronizationPrimitive::BodyDescriptor final
    : public BodyDescriptorBase {};

#if V8_ENABLE_WEBASSEMBLY
class WasmTypeInfo::BodyDescriptor final : public BodyDescriptorBase {};

class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase {};

class WasmTrustedInstanceData::BodyDescriptor final
    : public BodyDescriptorBase {};

class WasmTableObject::BodyDescriptor final : public BodyDescriptorBase {};

class WasmTagObject::BodyDescriptor final : public BodyDescriptorBase {};

class WasmGlobalObject::BodyDescriptor final : public BodyDescriptorBase {};

class WasmDispatchTable::BodyDescriptor final : public BodyDescriptorBase {};

class WasmArray::BodyDescriptor final : public BodyDescriptorBase {};

class WasmStruct::BodyDescriptor final : public BodyDescriptorBase {};

class WasmNull::BodyDescriptor : public DataOnlyBodyDescriptor {};

#endif  // V8_ENABLE_WEBASSEMBLY

class ExternalString::BodyDescriptor final : public BodyDescriptorBase {};

class CoverageInfo::BodyDescriptor final : public DataOnlyBodyDescriptor {};

class InstructionStream::BodyDescriptor final : public BodyDescriptorBase {};

class Map::BodyDescriptor final : public BodyDescriptorBase {};

class DataHandler::BodyDescriptor final : public BodyDescriptorBase {};

class NativeContext::BodyDescriptor final : public BodyDescriptorBase {};

class Code::BodyDescriptor final : public BodyDescriptorBase {};

class CodeWrapper::BodyDescriptor final : public BodyDescriptorBase {};

class EmbedderDataArray::BodyDescriptor final : public BodyDescriptorBase {};

template <typename Op, typename... Args>
auto BodyDescriptorApply(InstanceType type, Args&&... args) {}

template <typename ObjectVisitor>
void HeapObject::IterateFast(PtrComprCageBase cage_base, ObjectVisitor* v) {}

template <typename ObjectVisitor>
void HeapObject::IterateFast(Tagged<Map> map, ObjectVisitor* v) {}

template <typename ObjectVisitor>
void HeapObject::IterateFast(Tagged<Map> map, int object_size,
                             ObjectVisitor* v) {}

template <typename ObjectVisitor>
void HeapObject::IterateBodyFast(PtrComprCageBase cage_base, ObjectVisitor* v) {}

struct CallIterateBody {};

template <typename ObjectVisitor>
void HeapObject::IterateBodyFast(Tagged<Map> map, int object_size,
                                 ObjectVisitor* v) {}

class EphemeronHashTable::BodyDescriptor final : public BodyDescriptorBase {};

class AccessorInfo::BodyDescriptor final : public BodyDescriptorBase {};

class FunctionTemplateInfo::BodyDescriptor final : public BodyDescriptorBase {};

// TODO(jgruber): Combine these into generic Suffix descriptors.
class FixedArray::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<HeapObject::kHeaderSize> {};

class TrustedFixedArray::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<TrustedObject::kHeaderSize> {};

class ProtectedFixedArray::BodyDescriptor final : public BodyDescriptorBase {};

class SloppyArgumentsElements::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<HeapObject::kHeaderSize> {};

class RegExpMatchInfo::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<HeapObject::kHeaderSize> {};

class ArrayList::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<HeapObject::kHeaderSize> {};

class ObjectBoilerplateDescription::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<HeapObject::kHeaderSize> {};

class FeedbackCell::BodyDescriptor final : public BodyDescriptorBase {};

class ClosureFeedbackCellArray::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<HeapObject::kHeaderSize> {};

class ScriptContextTable::BodyDescriptor final
    : public SuffixRangeBodyDescriptor<HeapObject::kHeaderSize> {};

class WeakFixedArray::BodyDescriptor final
    : public SuffixRangeWeakBodyDescriptor<HeapObject::kHeaderSize> {};

class TrustedWeakFixedArray::BodyDescriptor final
    : public SuffixRangeWeakBodyDescriptor<HeapObject::kHeaderSize> {};

#include "torque-generated/objects-body-descriptors-inl.inc"

}  // namespace internal
}  // namespace v8

#endif  // V8_OBJECTS_OBJECTS_BODY_DESCRIPTORS_INL_H_