Index: src/runtime/runtime-array.cc |
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc |
index a0b3080a092a4a1fa910338cfb18914038e601e6..e4519cbb535b937081479f6ada2f94b6c33117b9 100644 |
--- a/src/runtime/runtime-array.cc |
+++ b/src/runtime/runtime-array.cc |
@@ -211,12 +211,19 @@ RUNTIME_FUNCTION(Runtime_GetArrayKeys) { |
JSObject::CollectOwnElementKeys(current, &accumulator, ALL_PROPERTIES); |
} |
// Erase any keys >= length. |
- // TODO(adamk): Remove this step when the contract of %GetArrayKeys |
- // is changed to let this happen on the JS side. |
Handle<FixedArray> keys = accumulator.GetKeys(KEEP_NUMBERS); |
+ int j = 0; |
for (int i = 0; i < keys->length(); i++) { |
- if (NumberToUint32(keys->get(i)) >= length) keys->set_undefined(i); |
+ if (NumberToUint32(keys->get(i)) >= length) continue; |
+ if (i != j) keys->set(j, keys->get(i)); |
+ j++; |
} |
+ |
+ if (j != keys->length()) { |
+ isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( |
+ *keys, keys->length() - j); |
+ } |
+ |
return *isolate->factory()->NewJSArrayWithElements(keys); |
} |