@@ -3185,18 +3185,22 @@ bool CanFastCloneObjectWithDifferentMaps(Handle<Map> source_map,
31853185 Handle<Map> target_map,
31863186 Isolate* isolate) {
31873187 DisallowGarbageCollection no_gc;
3188- // TODO(olivf): Add support for non JS_OBJECT_TYPE source maps. The reason for
3189- // this restriction is that the IC does not initialize the target object and
3190- // instead relies on copying the source objects bytes. Thus they need to have
3191- // the same binary layout.
3188+ // Ensure source and target have identical binary represenation of properties
3189+ // and elements as the IC relies on copying the raw bytes. This also excludes
3190+ // cases with non-enumerable properties or accessors on the source object.
31923191 if (source_map->instance_type () != JS_OBJECT_TYPE ||
31933192 target_map->instance_type () != JS_OBJECT_TYPE ||
31943193 !source_map->OnlyHasSimpleProperties () ||
3195- !target_map->OnlyHasSimpleProperties ()) {
3194+ !target_map->OnlyHasSimpleProperties () ||
3195+ source_map->elements_kind () != target_map->elements_kind () ||
3196+ !source_map->has_fast_elements ()) {
31963197 return false ;
31973198 }
31983199 // Check that the source inobject properties are big enough to initialize all
31993200 // target slots, but not too big to fit.
3201+ // TODO(olivf): This restriction (and the same restriction on the backing
3202+ // store) could be lifted by properly initializing the target object instead
3203+ // of relying on copying empty slots.
32003204 int source_inobj_properties = source_map->GetInObjectProperties ();
32013205 int target_inobj_properties = target_map->GetInObjectProperties ();
32023206 int source_used_inobj_properties =
0 commit comments