Backport: Fix Object.entries/values with changing elements

Bug: 111274046
Test: m -j proxy_resolver_v8_unittest && adb sync && adb shell \
/data/nativetest64/proxy_resolver_v8_unittest/proxy_resolver_v8_unittest
Change-Id: I705fc512cc5837e9364ed187559cc75d079aa5cb
(cherry picked from commit d8be9a10287afed07705ac8af027d6a46d4def99)

 static void TransitionElementsKindImpl(Handle<JSObject> object,
 Handle<Map> to_map) {
 Handle<Map> from_map = handle(object->map());
 ElementsKind from_kind = from_map->elements_kind();
 ElementsKind to_kind = to_map->elements_kind();
 if (IsFastHoleyElementsKind(from_kind)) {
      to_kind = GetHoleyElementsKind(to_kind);
 }
 if (from_kind != to_kind) {
      DCHECK(IsFastElementsKind(from_kind));
      DCHECK(IsFastElementsKind(to_kind));
      DCHECK_NE(TERMINAL_FAST_ELEMENTS_KIND, from_kind);

 Handle<FixedArrayBase> from_elements(object->elements());
 if (object->elements() == object->GetHeap()->empty_fixed_array() ||
 IsFastDoubleElementsKind(from_kind) ==
 IsFastDoubleElementsKind(to_kind)) {
 JSObject::MigrateToMap(object, to_map);
 } else {
        DCHECK((IsFastSmiElementsKind(from_kind) &&
 IsFastDoubleElementsKind(to_kind)) ||
 (IsFastDoubleElementsKind(from_kind) &&
 IsFastObjectElementsKind(to_kind)));
 uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
 Handle<FixedArrayBase> elements = ConvertElementsWithCapacity(
            object, from_elements, from_kind, capacity);
 JSObject::SetMapAndElements(object, to_map, elements);
 }
 if (FLAG_trace_elements_transitions) {
 JSObject::PrintElementsTransition(stdout, object, from_kind,
                                          from_elements, to_kind,
                                          handle(object->elements()));
 }
 }
 }

 static void TransitionElementsKindImpl(Handle<JSObject> object,
 Handle<Map> to_map) {
 Handle<Map> from_map = handle(object->map());
 ElementsKind from_kind = from_map->elements_kind();
 ElementsKind to_kind = to_map->elements_kind();
 if (IsFastHoleyElementsKind(from_kind)) {
      to_kind = GetHoleyElementsKind(to_kind);
 }
 if (from_kind != to_kind) {
      DCHECK(IsFastElementsKind(from_kind));
      DCHECK(IsFastElementsKind(to_kind));
      DCHECK_NE(TERMINAL_FAST_ELEMENTS_KIND, from_kind);

 Handle<FixedArrayBase> from_elements(object->elements());
 if (object->elements() == object->GetHeap()->empty_fixed_array() ||
 IsFastDoubleElementsKind(from_kind) ==
 IsFastDoubleElementsKind(to_kind)) {
 JSObject::MigrateToMap(object, to_map);
 } else {
        DCHECK((IsFastSmiElementsKind(from_kind) &&
 IsFastDoubleElementsKind(to_kind)) ||
 (IsFastDoubleElementsKind(from_kind) &&
 IsFastObjectElementsKind(to_kind)));
 uint32_t capacity = static_cast<uint32_t>(object->elements()->length());
 Handle<FixedArrayBase> elements = ConvertElementsWithCapacity(
            object, from_elements, from_kind, capacity);
 JSObject::SetMapAndElements(object, to_map, elements);
 }
 if (FLAG_trace_elements_transitions) {
 JSObject::PrintElementsTransition(stdout, object, from_kind,
                                          from_elements, to_kind,
                                          handle(object->elements()));
 }
 }
 }
