Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 1a3dc4e73ad46fd21d7a55d46d55319359a87b7a..883d7896c57e91dc31a1990845fd96557532eb63 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -3601,9 +3601,17 @@ Object* FixedArray::AddKeysFromJSArray(JSArray* array) { |
Object* FixedArray::UnionOfKeys(FixedArray* other) { |
int len0 = length(); |
+#ifdef DEBUG |
+ if (FLAG_enable_slow_asserts) { |
+ for (int i = 0; i < len0; i++) { |
+ ASSERT(get(i)->IsString() || get(i)->IsNumber()); |
+ } |
+ } |
+#endif |
int len1 = other->length(); |
- // Optimize if either is empty. |
- if (len0 == 0) return other; |
+ // Optimize if 'other' is empty. |
+ // We cannot optimize if 'this' is empty, as other may have holes |
+ // or non keys. |
if (len1 == 0) return this; |
// Compute how many elements are not in this. |
@@ -3623,14 +3631,18 @@ Object* FixedArray::UnionOfKeys(FixedArray* other) { |
FixedArray* result = FixedArray::cast(obj); |
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
for (int i = 0; i < len0; i++) { |
- result->set(i, get(i), mode); |
+ Object* e = get(i); |
+ ASSERT(e->IsString() || e->IsNumber()); |
+ result->set(i, e, mode); |
} |
// Fill in the extra keys. |
int index = 0; |
for (int y = 0; y < len1; y++) { |
Object* value = other->get(y); |
if (!value->IsTheHole() && !HasKey(this, value)) { |
- result->set(len0 + index, other->get(y), mode); |
+ Object* e = other->get(y); |
+ ASSERT(e->IsString() || e->IsNumber()); |
+ result->set(len0 + index, e, mode); |
index++; |
} |
} |