Chromium Code Reviews| Index: src/runtime/runtime-object.cc |
| diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
| index 0c6f81306ee7981c98a5d4150aa0e3d8879105e7..eb8221888d0da84e71f4726405f7acd392ad9bdb 100644 |
| --- a/src/runtime/runtime-object.cc |
| +++ b/src/runtime/runtime-object.cc |
| @@ -996,17 +996,23 @@ RUNTIME_FUNCTION(Runtime_OwnKeys) { |
| // a fresh clone on each invocation. |
| int length = contents->length(); |
| Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); |
| - for (int i = 0; i < length; i++) { |
| - Object* entry = contents->get(i); |
| - if (entry->IsString()) { |
| - copy->set(i, entry); |
| - } else { |
| - DCHECK(entry->IsNumber()); |
| - HandleScope scope(isolate); |
| - Handle<Object> entry_handle(entry, isolate); |
| - Handle<Object> entry_str = |
| - isolate->factory()->NumberToString(entry_handle); |
| - copy->set(i, *entry_str); |
| + int offset = 0; |
| + // Use an outer loop to avoid creating too many handles in the current |
| + // handle scope. |
| + while (offset < length) { |
| + HandleScope scope(isolate); |
| + offset += 100; |
|
Igor Sheludko
2015/09/17 09:55:12
int end = min(offset, length);
|
| + for (int i = offset - 100; i < offset && i < length; i++) { |
|
Igor Sheludko
2015/09/17 09:55:12
...; i < end; ...
Camillo Bruni
2015/09/17 11:01:08
updated
|
| + Object* entry = contents->get(i); |
| + if (entry->IsString()) { |
| + copy->set(i, entry); |
| + } else { |
| + DCHECK(entry->IsNumber()); |
| + Handle<Object> entry_handle(entry, isolate); |
| + Handle<Object> entry_str = |
| + isolate->factory()->NumberToString(entry_handle); |
| + copy->set(i, *entry_str); |
| + } |
| } |
| } |
| return *isolate->factory()->NewJSArrayWithElements(copy); |