Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Unified Diff: src/objects.cc

Issue 1148863002: Fix for-in for large indexes and indexes on proxies (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index ea67e2cbe672eda297ee79a5c859bdf90d73cddf..ecb5bf1b5164265ae48d7f4be04d01181a7c8c65 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8203,8 +8203,7 @@ MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike(
Handle<FixedArray> result;
ASSIGN_RETURN_ON_EXCEPTION(
array->GetIsolate(), result,
- accessor->AddElementsToFixedArray(array, array, content, filter),
- FixedArray);
+ accessor->AddElementsToFixedArray(array, content, filter), FixedArray);
#ifdef ENABLE_SLOW_DCHECKS
if (FLAG_enable_slow_asserts) {
@@ -8221,25 +8220,27 @@ MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike(
MaybeHandle<FixedArray> FixedArray::UnionOfKeys(Handle<FixedArray> first,
Handle<FixedArray> second) {
- ElementsAccessor* accessor = ElementsAccessor::ForArray(second);
- Handle<FixedArray> result;
- ASSIGN_RETURN_ON_EXCEPTION(
- first->GetIsolate(), result,
- accessor->AddElementsToFixedArray(
- Handle<Object>::null(), // receiver
- Handle<JSObject>::null(), // holder
- first, Handle<FixedArrayBase>::cast(second), ALL_KEYS),
- FixedArray);
-
-#ifdef ENABLE_SLOW_DCHECKS
- if (FLAG_enable_slow_asserts) {
- DisallowHeapAllocation no_allocation;
- for (int i = 0; i < result->length(); i++) {
- Object* current = result->get(i);
- DCHECK(current->IsNumber() || current->IsName());
+ if (second->length() == 0) return first;
+ if (first->length() == 0) return second;
+ Isolate* isolate = first->GetIsolate();
+ Handle<FixedArray> result =
+ isolate->factory()->NewFixedArray(first->length() + second->length());
+ for (int i = 0; i < first->length(); i++) {
+ result->set(i, first->get(i));
+ }
+ int pos = first->length();
+ for (int j = 0; j < second->length(); j++) {
+ Object* current = second->get(j);
+ int i;
+ for (i = 0; i < first->length(); i++) {
+ if (current->KeyEquals(first->get(i))) break;
+ }
+ if (i == first->length()) {
+ result->set(pos++, current);
}
}
-#endif
+
+ result->Shrink(pos);
return result;
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698