Index: src/elements.cc |
diff --git a/src/elements.cc b/src/elements.cc |
index 7a0f558cd91b26acc84b6c7fafeac379b9d29cae..b10e1f7f1b8309213ead099b5c856afcb39d1e5f 100644 |
--- a/src/elements.cc |
+++ b/src/elements.cc |
@@ -1519,7 +1519,7 @@ class DictionaryElementsAccessor |
continue; |
} |
- PropertyDetails details = GetDetailsImpl(receiver->elements(), entry); |
+ PropertyDetails details = GetDetailsImpl(*dictionary, entry); |
switch (details.kind()) { |
case kData: { |
Object* element_k = dictionary->ValueAt(entry); |
@@ -1539,12 +1539,28 @@ class DictionaryElementsAccessor |
if (value->SameValueZero(*element_k)) return Just(true); |
- // Some mutation to the prototype elements may have occurred in |
- // accessor. |
+ // Bailout to slow path if elements on prototype changed |
if (!JSObject::PrototypeHasNoElements(isolate, *receiver)) { |
return IncludesValueSlowPath(isolate, receiver, value, k + 1, |
length); |
} |
+ |
+ // Continue if elements unchanged |
+ if (*dictionary == receiver->elements()) continue; |
+ |
+ // Otherwise, bailout or update elements |
+ if (receiver->GetElementsKind() != DICTIONARY_ELEMENTS) { |
+ if (receiver->map()->GetInitialElements() == receiver->elements()) { |
+ // If switched to initial elements, return true if searching for |
+ // undefined, and false otherwise. |
+ return Just(search_for_hole); |
+ } |
+ // Otherwise, switch to slow path. |
+ return IncludesValueSlowPath(isolate, receiver, value, k + 1, |
+ length); |
+ } |
+ dictionary = handle( |
+ SeededNumberDictionary::cast(receiver->elements()), isolate); |
break; |
} |
} |