@@ -839,34 +839,33 @@ InstanceType HeapObjectData::GetMapInstanceType() const {
839839
840840namespace {
841841
842- bool IsReadOnlyLengthDescriptor (Isolate* isolate,
843- DirectHandle<Map> jsarray_map) {
844- DCHECK (!jsarray_map->is_dictionary_map ());
845- Tagged<DescriptorArray> descriptors =
846- jsarray_map->instance_descriptors (isolate, kRelaxedLoad );
842+ bool IsReadOnlyLengthDescriptor (JSHeapBroker* broker, MapRef jsarray_map) {
843+ DCHECK (!jsarray_map.is_dictionary_map ());
844+ DescriptorArrayRef descriptors = jsarray_map.instance_descriptors (broker);
847845 static_assert (
848846 JSArray::kLengthOffset == JSObject::kHeaderSize ,
849847 " The length should be the first property on the descriptor array" );
850848 InternalIndex offset (0 );
851- return descriptors-> GetDetails (offset).IsReadOnly ();
849+ return descriptors. GetPropertyDetails (offset).IsReadOnly ();
852850}
853851
854852// Important: this predicate does not check Protectors::IsNoElementsIntact. The
855853// compiler checks protectors through the compilation dependency mechanism; it
856854// doesn't make sense to do that here as part of every MapData construction.
857855// Callers *must* take care to take the correct dependency themselves.
858- bool SupportsFastArrayIteration (JSHeapBroker* broker, DirectHandle<Map> map) {
859- return map->instance_type () == JS_ARRAY_TYPE &&
860- IsFastElementsKind (map->elements_kind ()) &&
861- IsJSArray (map->prototype ()) &&
862- broker->IsArrayOrObjectPrototype (broker->CanonicalPersistentHandle (
863- Cast<JSArray>(map->prototype ())));
856+ bool SupportsFastArrayIteration (JSHeapBroker* broker, MapRef map) {
857+ if (map.instance_type () != JS_ARRAY_TYPE ||
858+ !IsFastElementsKind (map.elements_kind ())) {
859+ return false ;
860+ }
861+ HeapObjectRef prototype = map.prototype (broker);
862+ return prototype.IsJSArray () &&
863+ prototype.AsJSArray ().IsArrayOrObjectPrototype (broker);
864864}
865865
866- bool SupportsFastArrayResize (JSHeapBroker* broker, DirectHandle<Map> map) {
867- return SupportsFastArrayIteration (broker, map) && map->is_extensible () &&
868- !map->is_dictionary_map () &&
869- !IsReadOnlyLengthDescriptor (broker->isolate (), map);
866+ bool SupportsFastArrayResize (JSHeapBroker* broker, MapRef map) {
867+ return SupportsFastArrayIteration (broker, map) && map.is_extensible () &&
868+ !map.is_dictionary_map () && !IsReadOnlyLengthDescriptor (broker, map);
870869}
871870
872871} // namespace
@@ -1248,11 +1247,11 @@ bool MapRef::PrototypesElementsDoNotHaveAccessorsOrThrow(
12481247}
12491248
12501249bool MapRef::supports_fast_array_iteration (JSHeapBroker* broker) const {
1251- return SupportsFastArrayIteration (broker, object () );
1250+ return SupportsFastArrayIteration (broker, * this );
12521251}
12531252
12541253bool MapRef::supports_fast_array_resize (JSHeapBroker* broker) const {
1255- return SupportsFastArrayResize (broker, object () );
1254+ return SupportsFastArrayResize (broker, * this );
12561255}
12571256
12581257namespace {
@@ -1624,6 +1623,7 @@ HEAP_ACCESSOR_B(Map, bit_field3, NumberOfOwnDescriptors,
16241623 Map::Bits3::NumberOfOwnDescriptorsBits)
16251624HEAP_ACCESSOR_B (Map, bit_field3, is_migration_target,
16261625 Map::Bits3::IsMigrationTargetBit)
1626+ BIMODAL_ACCESSOR_B (Map, bit_field3, is_extensible, Map::Bits3::IsExtensibleBit)
16271627BIMODAL_ACCESSOR_B (Map, bit_field3, construction_counter,
16281628 Map::Bits3::ConstructionCounterBits)
16291629HEAP_ACCESSOR_B (Map, bit_field, has_prototype_slot,
@@ -1805,6 +1805,11 @@ ObjectRef MapRef::GetConstructor(JSHeapBroker* broker) const {
18051805 return MakeRefAssumeMemoryFence (broker, object ()->GetConstructor ());
18061806}
18071807
1808+ NativeContextRef MapRef::native_context (JSHeapBroker* broker) const {
1809+ // Immutable after initialization.
1810+ return MakeRefAssumeMemoryFence (broker, object ()->native_context ());
1811+ }
1812+
18081813HeapObjectRef MapRef::GetBackPointer (JSHeapBroker* broker) const {
18091814 // Immutable after initialization.
18101815 return MakeRefAssumeMemoryFence (broker,
@@ -2459,6 +2464,19 @@ OptionalMapRef JSObjectRef::GetObjectCreateMap(JSHeapBroker* broker) const {
24592464 maybe_object_create_map.GetHeapObjectAssumeWeak (), kAssumeMemoryFence ));
24602465}
24612466
2467+ bool JSObjectRef::IsArrayOrObjectPrototype (JSHeapBroker* broker) const {
2468+ MapRef map = this ->map (broker);
2469+ if (map.instance_type () == JS_OBJECT_PROTOTYPE_TYPE ) return true ;
2470+ // Keep in sync with Isolate::IsInCreationContext:
2471+ MapRef metamap = map.map (broker);
2472+ // Filter out native-context independent objects.
2473+ if (*metamap.object () == ReadOnlyRoots (broker->isolate ()).meta_map ())
2474+ return false ;
2475+ OptionalNativeContextRef native_context = metamap.native_context (broker);
2476+ if (!native_context.has_value ()) return false ;
2477+ return native_context->initial_array_prototype (broker).equals (*this );
2478+ }
2479+
24622480bool PropertyCellRef::Cache (JSHeapBroker* broker) const {
24632481 if (data_->should_access_heap ()) return true ;
24642482 CHECK (broker->mode () == JSHeapBroker::kSerializing ||
0 commit comments