Lines Matching defs:isolate
8 #include "src/execution/isolate.h"
32 Map Map::GetPrototypeChainRootMap(Isolate* isolate) const {
39 Context native_context = isolate->context().native_context();
44 return ReadOnlyRoots(isolate).null_value().map();
413 MaybeObjectHandle Map::WrapFieldType(Isolate* isolate, Handle<FieldType> type) {
415 return MaybeObjectHandle::Weak(type->AsClass(), isolate);
432 MaybeHandle<Map> Map::CopyWithField(Isolate* isolate, Handle<Map> map,
438 DCHECK(map->instance_descriptors(isolate)
453 type = FieldType::Any(isolate);
456 isolate, map->instance_type(), &representation, &type);
459 MaybeObjectHandle wrapped_type = WrapFieldType(isolate, type);
463 Handle<Map> new_map = Map::CopyAddDescriptor(isolate, map, &d, flag);
468 MaybeHandle<Map> Map::CopyWithConstant(Isolate* isolate, Handle<Map> map,
478 Representation representation = constant->OptimalRepresentation(isolate);
479 Handle<FieldType> type = constant->OptimalType(isolate, representation);
480 return CopyWithField(isolate, map, name, type, attributes,
570 void Map::DeprecateTransitionTree(Isolate* isolate) {
572 TransitionsAccessor transitions(isolate, *this);
575 transitions.GetTarget(i).DeprecateTransitionTree(isolate);
581 LOG(isolate, MapEvent("Deprecate", handle(*this, isolate), Handle<Map>()));
584 isolate, DependentCode::kTransitionGroup);
585 NotifyLeafMapLayoutChange(isolate);
590 void Map::ReplaceDescriptors(Isolate* isolate,
594 GetBackPointer(isolate).IsUndefined(isolate)) {
598 DescriptorArray to_replace = instance_descriptors(isolate);
606 while (current.instance_descriptors(isolate) == to_replace) {
607 Object next = current.GetBackPointer(isolate);
608 if (next.IsUndefined(isolate)) break; // Stop overwriting at initial map.
610 current.UpdateDescriptors(isolate, new_descriptors,
617 Map Map::FindRootMap(Isolate* isolate) const {
620 PtrComprCageBase cage_base(isolate);
623 if (back.IsUndefined(isolate)) {
635 Map Map::FindFieldOwner(Isolate* isolate, InternalIndex descriptor) const {
638 instance_descriptors(isolate, kRelaxedLoad)
643 Object back = result.GetBackPointer(isolate);
644 if (back.IsUndefined(isolate)) break;
654 Map SearchMigrationTarget(Isolate* isolate, Map old_map) {
659 target = TransitionsAccessor(isolate, target).GetMigrationTarget();
671 DescriptorArray old_descriptors = old_map.instance_descriptors(isolate);
684 isolate, old_map, ConcurrencyMode::kSynchronous) == target);
690 MaybeHandle<Map> Map::TryUpdate(Isolate* isolate, Handle<Map> old_map) {
692 DisallowDeoptimization no_deoptimization(isolate);
697 Map target_map = SearchMigrationTarget(isolate, *old_map);
699 return handle(target_map, isolate);
704 isolate, *old_map, ConcurrencyMode::kSynchronous);
707 TransitionsAccessor::SetMigrationTarget(isolate, old_map, new_map.value());
709 return handle(new_map.value(), isolate);
712 Map Map::TryReplayPropertyTransitions(Isolate* isolate, Map old_map,
722 old_map.instance_descriptors(isolate, kAcquireLoad);
728 TransitionsAccessor(isolate, new_map, IsConcurrent(cmode))
734 new_map.instance_descriptors(isolate, kAcquireLoad);
783 Handle<Map> Map::Update(Isolate* isolate, Handle<Map> map) {
786 Map target_map = SearchMigrationTarget(isolate, *map);
788 return handle(target_map, isolate);
791 MapUpdater mu(isolate, map);
795 void Map::EnsureDescriptorSlack(Isolate* isolate, Handle<Map> map, int slack) {
799 Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
800 isolate);
805 DescriptorArray::CopyUpTo(isolate, descriptors, old_size, slack);
809 map->UpdateDescriptors(isolate, *new_descriptors,
830 map->UpdateDescriptors(isolate, *new_descriptors,
833 if (next.IsUndefined(isolate)) return;
836 while (current.instance_descriptors(isolate) == *descriptors) {
838 if (next.IsUndefined(isolate)) break;
839 current.UpdateDescriptors(isolate, *new_descriptors,
846 Handle<Map> Map::GetObjectCreateMap(Isolate* isolate,
848 Handle<Map> map(isolate->native_context()->object_function().initial_map(),
849 isolate);
851 if (prototype->IsNull(isolate)) {
852 return isolate->slow_object_with_null_prototype_map();
860 Map::GetOrCreatePrototypeInfo(js_prototype, isolate);
863 map = handle(info->ObjectCreateMap(), isolate);
865 map = Map::CopyInitialMap(isolate, map);
866 Map::SetPrototype(isolate, map, prototype);
872 return Map::TransitionToPrototype(isolate, map, prototype);
892 Map Map::FindElementsKindTransitionedMap(Isolate* isolate,
897 if (IsDetached(isolate)) return Map();
905 Map root_map = FindRootMap(isolate);
907 root_map = root_map.LookupElementsTransitionMap(isolate, kind, cmode);
912 for (root_map = root_map.ElementsTransitionMap(isolate, cmode);
914 root_map = root_map.ElementsTransitionMap(isolate, cmode)) {
919 root_map.TryReplayPropertyTransitions(isolate, *this, cmode);
935 static Map FindClosestElementsTransition(Isolate* isolate, Map map,
940 DCHECK_EQ(map.FindRootMap(isolate).NumberOfOwnDescriptors(),
946 Map next_map = current_map.ElementsTransitionMap(isolate, cmode);
956 Map Map::LookupElementsTransitionMap(Isolate* isolate, ElementsKind to_kind,
958 Map to_map = FindClosestElementsTransition(isolate, *this, to_kind, cmode);
963 bool Map::IsMapInArrayPrototypeChain(Isolate* isolate) const {
964 if (isolate->initial_array_prototype()->map() == *this) {
968 if (isolate->initial_object_prototype()->map() == *this) {
975 Handle<Map> Map::TransitionElementsTo(Isolate* isolate, Handle<Map> map,
980 Context native_context = isolate->context().native_context();
984 return handle(native_context.slow_aliased_arguments_map(), isolate);
989 return handle(native_context.fast_aliased_arguments_map(), isolate);
998 return handle(Map::cast(maybe_transitioned_map), isolate);
1003 DCHECK(!map->IsUndefined(isolate));
1009 return handle(Map::cast(map->GetBackPointer()), isolate);
1021 return Map::CopyAsElementsKind(isolate, map, to_kind, OMIT_TRANSITION);
1024 return MapUpdater{isolate, map}.ReconfigureElementsKind(to_kind);
1027 static Handle<Map> AddMissingElementsTransitions(Isolate* isolate,
1036 if (map->IsDetached(isolate)) {
1043 current_map = Map::CopyAsElementsKind(isolate, current_map, kind, flag);
1051 current_map = Map::CopyAsElementsKind(isolate, current_map, to_kind, flag);
1059 base::Optional<Map> Map::TryAsElementsKind(Isolate* isolate, Handle<Map> map,
1062 Map closest_map = FindClosestElementsTransition(isolate, *map, kind, cmode);
1068 Handle<Map> Map::AsElementsKind(Isolate* isolate, Handle<Map> map,
1071 FindClosestElementsTransition(isolate, *map, kind,
1073 isolate);
1079 return AddMissingElementsTransitions(isolate, closest_map, kind);
1114 bool Map::MayHaveReadOnlyElementsInPrototypeChain(Isolate* isolate) {
1115 for (PrototypeIterator iter(isolate, *this); !iter.IsAtEnd();
1123 ElementsKind elements_kind = current.GetElementsKind(isolate);
1127 current.element_dictionary(isolate).requires_slow_elements()) {
1133 SloppyArgumentsElements::cast(current.elements(isolate));
1144 Handle<Map> Map::RawCopy(Isolate* isolate, Handle<Map> src_handle,
1146 Handle<Map> result = isolate->factory()->NewMap(
1174 Handle<HeapObject> prototype(src_handle->prototype(), isolate);
1175 Map::SetPrototype(isolate, result, prototype);
1179 Handle<Map> Map::Normalize(Isolate* isolate, Handle<Map> fast_map,
1184 Handle<Object> maybe_cache(isolate->native_context()->normalized_map_cache(),
1185 isolate);
1187 !fast_map->is_prototype_map() && !maybe_cache->IsUndefined(isolate);
1195 if (FLAG_verify_heap) new_map->DictionaryMapVerify(isolate);
1202 Handle<Map> fresh = Map::CopyNormalized(isolate, fast_map, mode);
1239 LOG(isolate, MapEvent("NormalizeCached", fast_map, new_map, reason));
1242 new_map = Map::CopyNormalized(isolate, fast_map, mode);
1246 isolate->counters()->maps_normalized()->Increment();
1249 LOG(isolate, MapEvent("Normalize", fast_map, new_map, reason));
1252 fast_map->NotifyLeafMapLayoutChange(isolate);
1256 Handle<Map> Map::CopyNormalized(Isolate* isolate, Handle<Map> map,
1264 isolate, map, new_instance_size,
1279 if (FLAG_verify_heap) result->DictionaryMapVerify(isolate);
1291 Handle<Map> Map::TransitionToImmutableProto(Isolate* isolate, Handle<Map> map) {
1292 Handle<Map> new_map = Map::Copy(isolate, map, "ImmutablePrototype");
1298 void EnsureInitialMap(Isolate* isolate, Handle<Map> map) {
1306 *map == *isolate->strict_function_map() ||
1307 *map == *isolate->strict_function_with_name_map() ||
1309 *map == *isolate->generator_function_map() ||
1310 *map == *isolate->generator_function_with_name_map() ||
1312 *map == *isolate->async_function_map() ||
1313 *map == *isolate->async_function_with_name_map());
1318 map->instance_descriptors(isolate).number_of_descriptors());
1323 Handle<Map> Map::CopyInitialMapNormalized(Isolate* isolate, Handle<Map> map,
1325 EnsureInitialMap(isolate, map);
1326 return CopyNormalized(isolate, map, mode);
1330 Handle<Map> Map::CopyInitialMap(Isolate* isolate, Handle<Map> map,
1333 EnsureInitialMap(isolate, map);
1336 RawCopy(isolate, map, instance_size, inobject_properties);
1344 DescriptorArray descriptors = map->instance_descriptors(isolate);
1346 result->UpdateDescriptors(isolate, descriptors, number_of_own_descriptors);
1355 Handle<Map> Map::CopyDropDescriptors(Isolate* isolate, Handle<Map> map) {
1357 RawCopy(isolate, map, map->instance_size(),
1364 map->NotifyLeafMapLayoutChange(isolate);
1368 Handle<Map> Map::ShareDescriptor(Isolate* isolate, Handle<Map> map,
1375 map->instance_descriptors(isolate).number_of_descriptors());
1377 Handle<Map> result = CopyDropDescriptors(isolate, map);
1389 descriptors = DescriptorArray::Allocate(isolate, 0, 1);
1392 EnsureDescriptorSlack(isolate, map, slack);
1393 descriptors = handle(map->instance_descriptors(isolate), isolate);
1400 result->InitializeDescriptors(isolate, *descriptors);
1404 ConnectTransition(isolate, map, result, name, SIMPLE_PROPERTY_TRANSITION);
1409 void Map::ConnectTransition(Isolate* isolate, Handle<Map> parent,
1416 if (!parent->GetBackPointer().IsUndefined(isolate)) {
1418 } else if (!parent->IsDetached(isolate)) {
1422 parent->instance_descriptors(isolate).number_of_descriptors());
1424 if (parent->IsDetached(isolate)) {
1425 DCHECK(child->IsDetached(isolate));
1427 LOG(isolate, MapEvent("Transition", parent, child, "prototype", name));
1430 TransitionsAccessor::Insert(isolate, parent, name, child, flag);
1432 LOG(isolate, MapEvent("Transition", parent, child, "", name));
1437 Handle<Map> Map::CopyReplaceDescriptors(Isolate* isolate, Handle<Map> map,
1445 Handle<Map> result = CopyDropDescriptors(isolate, map);
1455 result->InitializeDescriptors(isolate, *descriptors);
1458 TransitionsAccessor::CanHaveMoreTransitions(isolate, map)) {
1459 result->InitializeDescriptors(isolate, *descriptors);
1462 ConnectTransition(isolate, map, result, name, simple_flag);
1466 result->InitializeDescriptors(isolate, *descriptors);
1470 LOG(isolate, MapEvent("ReplaceDescriptors", map, result, reason,
1480 Handle<Map> Map::AddMissingTransitions(Isolate* isolate, Handle<Map> split_map,
1496 Handle<Map> last_map = CopyDropDescriptors(isolate, split_map);
1497 last_map->InitializeDescriptors(isolate, *descriptors);
1508 Handle<Map> new_map = CopyDropDescriptors(isolate, map);
1509 InstallDescriptors(isolate, map, new_map, i, descriptors);
1513 map->NotifyLeafMapLayoutChange(isolate);
1515 InstallDescriptors(isolate, map, last_map, InternalIndex(nof_descriptors - 1),
1522 void Map::InstallDescriptors(Isolate* isolate, Handle<Map> parent,
1527 child->SetInstanceDescriptors(isolate, *descriptors,
1535 Handle<Name> name = handle(descriptors->GetKey(new_descriptor), isolate);
1539 ConnectTransition(isolate, parent, child, name, SIMPLE_PROPERTY_TRANSITION);
1542 Handle<Map> Map::CopyAsElementsKind(Isolate* isolate, Handle<Map> map,
1554 DCHECK_EQ(map->FindRootMap(isolate).NumberOfOwnDescriptors(),
1558 map->ElementsTransitionMap(isolate, ConcurrencyMode::kSynchronous);
1570 TransitionsAccessor::CanHaveMoreTransitions(isolate, map) &&
1574 Handle<Map> new_map = CopyForElementsTransition(isolate, map);
1577 Handle<Name> name = isolate->factory()->elements_transition_symbol();
1578 ConnectTransition(isolate, map, new_map, name, SPECIAL_TRANSITION);
1583 Handle<Map> new_map = Copy(isolate, map, "CopyAsElementsKind");
1588 Handle<Map> Map::AsLanguageMode(Isolate* isolate, Handle<Map> initial_map,
1596 Handle<Map> function_map(Map::cast(isolate->native_context()->get(
1598 isolate);
1603 isolate->factory()->strict_function_transition_symbol();
1605 isolate, initial_map, *transition_symbol);
1609 initial_map->NotifyLeafMapLayoutChange(isolate);
1614 Map::CopyInitialMap(isolate, function_map, initial_map->instance_size(),
1621 if (TransitionsAccessor::CanHaveMoreTransitions(isolate, initial_map)) {
1622 Map::ConnectTransition(isolate, initial_map, map, transition_symbol,
1628 Handle<Map> Map::CopyForElementsTransition(Isolate* isolate, Handle<Map> map) {
1629 DCHECK(!map->IsDetached(isolate));
1630 Handle<Map> new_map = CopyDropDescriptors(isolate, map);
1637 new_map->InitializeDescriptors(isolate, map->instance_descriptors(isolate));
1641 Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
1642 isolate);
1645 isolate, descriptors, number_of_own_descriptors);
1646 new_map->InitializeDescriptors(isolate, *new_descriptors);
1651 Handle<Map> Map::Copy(Isolate* isolate, Handle<Map> map, const char* reason) {
1652 Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
1653 isolate);
1656 isolate, descriptors, number_of_own_descriptors);
1657 return CopyReplaceDescriptors(isolate, map, new_descriptors, OMIT_TRANSITION,
1662 Handle<Map> Map::Create(Isolate* isolate, int inobject_properties) {
1664 Copy(isolate, handle(isolate->object_function()->initial_map(), isolate),
1690 Isolate* isolate, Handle<Map> map, PropertyAttributes attrs_to_add,
1695 isolate, handle(map->instance_descriptors(isolate), isolate),
1699 isolate->bootstrapper()->IsActive() ? OMIT_TRANSITION : INSERT_TRANSITION;
1701 CopyReplaceDescriptors(isolate, map, new_desc, flag, transition_marker,
1786 Handle<Map> UpdateDescriptorForValue(Isolate* isolate, Handle<Map> map,
1790 if (CanHoldValue(map->instance_descriptors(isolate), descriptor, constness,
1796 map->instance_descriptors(isolate).GetDetails(descriptor).attributes();
1797 Representation representation = value->OptimalRepresentation(isolate);
1798 Handle<FieldType> type = value->OptimalType(isolate, representation);
1800 MapUpdater mu(isolate, map);
1808 Handle<Map> Map::PrepareForDataProperty(Isolate* isolate, Handle<Map> map,
1813 map = Update(isolate, map);
1816 return UpdateDescriptorForValue(isolate, map, descriptor, constness, value);
1819 Handle<Map> Map::TransitionToDataProperty(Isolate* isolate, Handle<Map> map,
1825 RCS_SCOPE(isolate,
1826 map->IsDetached(isolate)
1834 map = Update(isolate, map);
1837 isolate, map, *name, PropertyKind::kData, attributes);
1842 DCHECK_EQ(attributes, transition->instance_descriptors(isolate)
1846 return UpdateDescriptorForValue(isolate, transition, descriptor, constness,
1852 isolate->bootstrapper()->IsActive() ? OMIT_TRANSITION : INSERT_TRANSITION;
1855 Representation representation = value->OptimalRepresentation(isolate);
1856 Handle<FieldType> type = value->OptimalType(isolate, representation);
1857 maybe_map = Map::CopyWithField(isolate, map, name, type, attributes,
1874 Handle<Object> maybe_constructor(map->GetConstructor(), isolate);
1881 Handle<Map> initial_map(constructor->initial_map(), isolate);
1882 result = Map::Normalize(isolate, initial_map, CLEAR_INOBJECT_PROPERTIES,
1884 initial_map->DeprecateTransitionTree(isolate);
1885 Handle<HeapObject> prototype(result->prototype(), isolate);
1886 JSFunction::SetInitialMap(isolate, constructor, result, prototype);
1890 isolate, DependentCode::kInitialMapChangedGroup);
1894 Map::Normalize(isolate, map, CLEAR_INOBJECT_PROPERTIES, reason);
1897 result = Map::Normalize(isolate, map, CLEAR_INOBJECT_PROPERTIES, reason);
1904 Handle<Map> Map::TransitionToAccessorProperty(Isolate* isolate, Handle<Map> map,
1911 isolate,
1912 map->IsDetached(isolate)
1917 DCHECK(!getter->IsNull(isolate) || !setter->IsNull(isolate));
1921 map = Update(isolate, map);
1931 isolate, map, *name, PropertyKind::kAccessor, attributes);
1934 DescriptorArray descriptors = transition->instance_descriptors(isolate);
1943 isolate);
1945 return Map::Normalize(isolate, map, mode,
1951 return Map::Normalize(isolate, map, mode,
1959 DescriptorArray old_descriptors = map->instance_descriptors(isolate);
1962 return Map::Normalize(isolate, map, mode, "AccessorsOverwritingNonLast");
1966 return Map::Normalize(isolate, map, mode,
1971 return Map::Normalize(isolate, map, mode, "AccessorsWithAttributes");
1975 isolate);
1977 return Map::Normalize(isolate, map, mode, "AccessorsOverwritingNonPair");
1984 if (!getter->IsNull(isolate) &&
1985 !current_pair->get(ACCESSOR_GETTER).IsNull(isolate) &&
1989 if (!setter->IsNull(isolate) &&
1990 !current_pair->get(ACCESSOR_SETTER).IsNull(isolate) &&
1995 return Map::Normalize(isolate, map, mode,
1999 pair = AccessorPair::Copy(isolate, Handle<AccessorPair>::cast(maybe_pair));
2002 return Map::Normalize(isolate, map, CLEAR_INOBJECT_PROPERTIES,
2005 pair = isolate->factory()->NewAccessorPair();
2012 isolate->bootstrapper()->IsActive() ? OMIT_TRANSITION : INSERT_TRANSITION;
2014 return Map::CopyInsertDescriptor(isolate, map, &d, flag);
2017 Handle<Map> Map::CopyAddDescriptor(Isolate* isolate, Handle<Map> map,
2020 Handle<DescriptorArray> descriptors(map->instance_descriptors(isolate),
2021 isolate);
2025 !map->GetBackPointer().IsUndefined(isolate) &&
2026 TransitionsAccessor::CanHaveMoreTransitions(isolate, map)) {
2027 return ShareDescriptor(isolate, map, descriptors, descriptor);
2032 DescriptorArray::CopyUpTo(isolate, descriptors, nof, 1);
2035 return CopyReplaceDescriptors(isolate, map, new_descriptors, flag,
2040 Handle<Map> Map::CopyInsertDescriptor(Isolate* isolate, Handle<Map> map,
2043 Handle<DescriptorArray> old_descriptors(map->instance_descriptors(isolate),
2044 isolate);
2048 old_descriptors->SearchWithCache(isolate, *descriptor->GetKey(), *map);
2050 return CopyReplaceDescriptor(isolate, map, old_descriptors, descriptor,
2053 return CopyAddDescriptor(isolate, map, descriptor, flag);
2056 Handle<Map> Map::CopyReplaceDescriptor(Isolate* isolate, Handle<Map> map,
2070 isolate, descriptors, map->NumberOfOwnDescriptors());
2078 return CopyReplaceDescriptors(isolate, map, new_descriptors, flag, key,
2094 Isolate* isolate = GetIsolateFromWritableObject(receiver);
2095 prototype_hash = receiver.GetOrCreateIdentityHash(isolate).value();
2176 int Map::ComputeMinObjectSlack(Isolate* isolate) {
2178 DCHECK(GetBackPointer().IsUndefined(isolate));
2181 TransitionsAccessor transitions(isolate, *this);
2189 void Map::SetInstanceDescriptors(Isolate* isolate, DescriptorArray descriptors,
2200 Isolate* isolate) {
2203 return handle(PrototypeInfo::cast(maybe_proto_info), isolate);
2205 Handle<PrototypeInfo> proto_info = isolate->factory()->NewPrototypeInfo();
2212 Isolate* isolate) {
2215 return handle(PrototypeInfo::cast(maybe_proto_info), isolate);
2217 Handle<PrototypeInfo> proto_info = isolate->factory()->NewPrototypeInfo();
2224 Isolate* isolate) {
2229 GetOrCreatePrototypeInfo(map, isolate)->set_should_be_fast_map(value);
2234 Isolate* isolate) {
2240 maybe_prototype = isolate->global_object();
2243 handle(map->GetPrototypeChainRootMap(isolate).prototype(), isolate);
2246 return handle(Smi::FromInt(Map::kPrototypeChainValid), isolate);
2251 JSObject::LazyRegisterPrototypeUser(handle(prototype->map(), isolate),
2252 isolate);
2257 Handle<Cell> cell(Cell::cast(maybe_cell), isolate);
2263 Handle<Cell> cell = isolate->factory()->NewCell(
2264 handle(Smi::FromInt(Map::kPrototypeChainValid), isolate));
2281 void Map::SetPrototype(Isolate* isolate, Handle<Map> map,
2284 RCS_SCOPE(isolate, RuntimeCallCounterId::kMap_SetPrototype);
2290 DCHECK(prototype->IsNull(isolate) || prototype->IsJSProxy());
2294 prototype->IsNull(isolate) ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER;
2304 Handle<Map> Map::TransitionToPrototype(Isolate* isolate, Handle<Map> map,
2307 TransitionsAccessor::GetPrototypeTransition(isolate, map, prototype);
2309 new_map = Copy(isolate, map, "TransitionToPrototype");
2310 TransitionsAccessor::PutPrototypeTransition(isolate, map, prototype,
2312 Map::SetPrototype(isolate, new_map, prototype);
2317 Handle<NormalizedMapCache> NormalizedMapCache::New(Isolate* isolate) {
2319 isolate->factory()->NewWeakFixedArray(kEntries, AllocationType::kOld));