#include "src/objects/map.h"
#include <optional>
#include "src/common/assert-scope.h"
#include "src/common/globals.h"
#include "src/execution/frames.h"
#include "src/execution/isolate.h"
#include "src/handles/handles-inl.h"
#include "src/handles/maybe-handles.h"
#include "src/heap/heap-write-barrier-inl.h"
#include "src/init/bootstrapper.h"
#include "src/logging/log.h"
#include "src/logging/runtime-call-stats-scope.h"
#include "src/objects/arguments-inl.h"
#include "src/objects/descriptor-array.h"
#include "src/objects/elements-kind.h"
#include "src/objects/field-type.h"
#include "src/objects/instance-type.h"
#include "src/objects/js-objects.h"
#include "src/objects/map-updater.h"
#include "src/objects/maybe-object.h"
#include "src/objects/oddball.h"
#include "src/objects/property.h"
#include "src/objects/transitions-inl.h"
#include "src/roots/roots.h"
#include "src/utils/ostreams.h"
#include "src/zone/zone-containers.h"
namespace v8::internal {
Tagged<Map> Map::GetPrototypeChainRootMap(Isolate* isolate) const { … }
std::optional<Tagged<JSFunction>> Map::GetConstructorFunction(
Tagged<Map> map, Tagged<Context> native_context) { … }
VisitorId Map::GetVisitorId(Tagged<Map> map) { … }
MaybeObjectHandle Map::WrapFieldType(Handle<FieldType> type) { … }
Tagged<FieldType> Map::UnwrapFieldType(Tagged<MaybeObject> wrapped_type) { … }
MaybeHandle<Map> Map::CopyWithField(Isolate* isolate, Handle<Map> map,
Handle<Name> name, Handle<FieldType> type,
PropertyAttributes attributes,
PropertyConstness constness,
Representation representation,
TransitionFlag flag) { … }
MaybeHandle<Map> Map::CopyWithConstant(Isolate* isolate, Handle<Map> map,
Handle<Name> name,
DirectHandle<Object> constant,
PropertyAttributes attributes,
TransitionFlag flag) { … }
bool Map::InstancesNeedRewriting(Tagged<Map> target,
ConcurrencyMode cmode) const { … }
bool Map::InstancesNeedRewriting(Tagged<Map> target,
int target_number_of_fields,
int target_inobject, int target_unused,
int* old_number_of_fields,
ConcurrencyMode cmode) const { … }
int Map::NumberOfFields(ConcurrencyMode cmode) const { … }
Map::FieldCounts Map::GetFieldCounts() const { … }
void Map::DeprecateTransitionTree(Isolate* isolate) { … }
void Map::ReplaceDescriptors(Isolate* isolate,
Tagged<DescriptorArray> new_descriptors) { … }
Tagged<Map> Map::FindRootMap(PtrComprCageBase cage_base) const { … }
Tagged<Map> Map::FindFieldOwner(PtrComprCageBase cage_base,
InternalIndex descriptor) const { … }
namespace {
Tagged<Map> SearchMigrationTarget(Isolate* isolate, Tagged<Map> old_map) { … }
}
MaybeHandle<Map> Map::TryUpdate(Isolate* isolate, Handle<Map> old_map) { … }
Tagged<Map> Map::TryReplayPropertyTransitions(Isolate* isolate,
Tagged<Map> old_map,
ConcurrencyMode cmode) { … }
Handle<Map> Map::Update(Isolate* isolate, Handle<Map> map) { … }
void Map::EnsureDescriptorSlack(Isolate* isolate, DirectHandle<Map> map,
int slack) { … }
Handle<Map> Map::GetObjectCreateMap(Isolate* isolate,
Handle<HeapObject> prototype) { … }
Handle<Map> Map::GetDerivedMap(Isolate* isolate, Handle<Map> from,
Handle<JSReceiver> prototype) { … }
static bool ContainsMap(MapHandlesSpan maps, Tagged<Map> map) { … }
static bool HasElementsKind(MapHandlesSpan maps, ElementsKind elements_kind) { … }
Tagged<Map> Map::FindElementsKindTransitionedMap(Isolate* isolate,
MapHandlesSpan candidates,
ConcurrencyMode cmode) { … }
static Tagged<Map> FindClosestElementsTransition(Isolate* isolate,
Tagged<Map> map,
ElementsKind to_kind,
ConcurrencyMode cmode) { … }
Tagged<Map> Map::LookupElementsTransitionMap(Isolate* isolate,
ElementsKind to_kind,
ConcurrencyMode cmode) { … }
bool Map::IsMapInArrayPrototypeChain(Isolate* isolate) const { … }
Handle<Map> Map::TransitionElementsTo(Isolate* isolate, Handle<Map> map,
ElementsKind to_kind) { … }
static Handle<Map> AddMissingElementsTransitions(Isolate* isolate,
Handle<Map> map,
ElementsKind to_kind) { … }
std::optional<Tagged<Map>> Map::TryAsElementsKind(Isolate* isolate,
DirectHandle<Map> map,
ElementsKind kind,
ConcurrencyMode cmode) { … }
Handle<Map> Map::AsElementsKind(Isolate* isolate, DirectHandle<Map> map,
ElementsKind kind) { … }
int Map::NumberOfEnumerableProperties() const { … }
int Map::NextFreePropertyIndex() const { … }
bool Map::OnlyHasSimpleProperties() const { … }
bool Map::ShouldCheckForReadOnlyElementsInPrototypeChain(Isolate* isolate) { … }
Handle<Map> Map::RawCopy(Isolate* isolate, Handle<Map> src_handle,
int instance_size, int inobject_properties) { … }
Handle<Map> Map::Normalize(Isolate* isolate, Handle<Map> fast_map,
ElementsKind new_elements_kind,
Handle<HeapObject> new_prototype,
PropertyNormalizationMode mode, bool use_cache,
const char* reason) { … }
Handle<Map> Map::CopyNormalized(Isolate* isolate, Handle<Map> map,
PropertyNormalizationMode mode) { … }
Handle<Map> Map::TransitionToImmutableProto(Isolate* isolate, Handle<Map> map) { … }
namespace {
void EnsureInitialMap(Isolate* isolate, DirectHandle<Map> map) { … }
}
Handle<Map> Map::CopyInitialMapNormalized(Isolate* isolate, Handle<Map> map,
PropertyNormalizationMode mode) { … }
Handle<Map> Map::CopyInitialMap(Isolate* isolate, Handle<Map> map,
int instance_size, int inobject_properties,
int unused_property_fields) { … }
Handle<Map> Map::CopyDropDescriptors(Isolate* isolate, Handle<Map> map) { … }
Handle<Map> Map::ShareDescriptor(Isolate* isolate, Handle<Map> map,
DirectHandle<DescriptorArray> descriptors,
Descriptor* descriptor) { … }
void Map::ConnectTransition(Isolate* isolate, Handle<Map> parent,
Handle<Map> child, Handle<Name> name,
TransitionKindFlag transition_kind,
bool force_connect) { … }
Handle<Map> Map::CopyReplaceDescriptors(
Isolate* isolate, Handle<Map> map,
DirectHandle<DescriptorArray> descriptors, TransitionFlag flag,
MaybeHandle<Name> maybe_name, const char* reason,
TransitionKindFlag transition_kind) { … }
Handle<Map> Map::AddMissingTransitions(
Isolate* isolate, Handle<Map> split_map,
DirectHandle<DescriptorArray> descriptors) { … }
void Map::InstallDescriptors(Isolate* isolate, Handle<Map> parent,
Handle<Map> child, InternalIndex new_descriptor,
DirectHandle<DescriptorArray> descriptors,
bool force_connect) { … }
Handle<Map> Map::CopyAsElementsKind(Isolate* isolate, Handle<Map> map,
ElementsKind kind, TransitionFlag flag) { … }
Handle<Map> Map::AsLanguageMode(Isolate* isolate, Handle<Map> initial_map,
DirectHandle<SharedFunctionInfo> shared_info) { … }
Handle<Map> Map::CopyForElementsTransition(Isolate* isolate, Handle<Map> map) { … }
Handle<Map> Map::CopyForPrototypeTransition(Isolate* isolate, Handle<Map> map,
Handle<HeapObject> prototype) { … }
Handle<Map> Map::Copy(Isolate* isolate, Handle<Map> map, const char* reason,
TransitionKindFlag kind) { … }
Handle<Map> Map::Create(Isolate* isolate, int inobject_properties) { … }
Handle<Map> Map::CopyForPreventExtensions(
Isolate* isolate, Handle<Map> map, PropertyAttributes attrs_to_add,
Handle<Symbol> transition_marker, const char* reason,
bool old_map_is_dictionary_elements_kind) { … }
namespace {
bool CanHoldValue(Tagged<DescriptorArray> descriptors, InternalIndex descriptor,
PropertyConstness constness, Tagged<Object> value) { … }
Handle<Map> UpdateDescriptorForValue(Isolate* isolate, Handle<Map> map,
InternalIndex descriptor,
PropertyConstness constness,
DirectHandle<Object> value) { … }
}
Handle<Map> Map::PrepareForDataProperty(Isolate* isolate, Handle<Map> map,
InternalIndex descriptor,
PropertyConstness constness,
DirectHandle<Object> value) { … }
Handle<Map> Map::TransitionToDataProperty(Isolate* isolate, Handle<Map> map,
Handle<Name> name,
DirectHandle<Object> value,
PropertyAttributes attributes,
PropertyConstness constness,
StoreOrigin store_origin) { … }
Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
Handle<Name> name,
InternalIndex descriptor,
DirectHandle<Object> getter,
DirectHandle<Object> setter,
PropertyAttributes attributes) { … }
Handle<Map> Map::CopyAddDescriptor(Isolate* isolate, Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag) { … }
Handle<Map> Map::CopyInsertDescriptor(Isolate* isolate, Handle<Map> map,
Descriptor* descriptor,
TransitionFlag flag) { … }
Handle<Map> Map::CopyReplaceDescriptor(
Isolate* isolate, Handle<Map> map,
DirectHandle<DescriptorArray> descriptors, Descriptor* descriptor,
InternalIndex insertion_index, TransitionFlag flag) { … }
int Map::Hash() { … }
int Map::Hash(Tagged<HeapObject> prototype) { … }
namespace {
bool CheckEquivalentModuloProto(const Tagged<Map> first,
const Tagged<Map> second) { … }
}
bool Map::EquivalentToForTransition(const Tagged<Map> other,
ConcurrencyMode cmode,
Handle<HeapObject> new_prototype) const { … }
bool Map::EquivalentToForElementsKindTransition(const Tagged<Map> other,
ConcurrencyMode cmode) const { … }
bool Map::EquivalentToForNormalization(const Tagged<Map> other,
ElementsKind elements_kind,
Tagged<HeapObject> other_prototype,
PropertyNormalizationMode mode) const { … }
int Map::ComputeMinObjectSlack(Isolate* isolate) { … }
void Map::SetInstanceDescriptors(Isolate* isolate,
Tagged<DescriptorArray> descriptors,
int number_of_own_descriptors) { … }
Handle<PrototypeInfo> Map::GetOrCreatePrototypeInfo(
DirectHandle<JSObject> prototype, Isolate* isolate) { … }
Handle<PrototypeInfo> Map::GetOrCreatePrototypeInfo(
DirectHandle<Map> prototype_map, Isolate* isolate) { … }
void Map::SetShouldBeFastPrototypeMap(DirectHandle<Map> map, bool value,
Isolate* isolate) { … }
Handle<UnionOf<Smi, Cell>> Map::GetOrCreatePrototypeChainValidityCell(
DirectHandle<Map> map, Isolate* isolate) { … }
bool Map::IsPrototypeChainInvalidated(Tagged<Map> map) { … }
void Map::SetPrototype(Isolate* isolate, DirectHandle<Map> map,
Handle<HeapObject> prototype,
bool enable_prototype_setup_mode) { … }
void Map::StartInobjectSlackTracking() { … }
Handle<Map> Map::TransitionRootMapToPrototypeForNewObject(
Isolate* isolate, Handle<Map> map, Handle<HeapObject> prototype) { … }
Handle<Map> Map::TransitionToUpdatePrototype(Isolate* isolate, Handle<Map> map,
Handle<HeapObject> prototype) { … }
Handle<NormalizedMapCache> NormalizedMapCache::New(Isolate* isolate) { … }
MaybeHandle<Map> NormalizedMapCache::Get(DirectHandle<Map> fast_map,
ElementsKind elements_kind,
Tagged<HeapObject> prototype,
PropertyNormalizationMode mode) { … }
void NormalizedMapCache::Set(DirectHandle<Map> fast_map,
DirectHandle<Map> normalized_map) { … }
}