| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 | 989 |
| 990 Handle<FixedArray> contents; | 990 Handle<FixedArray> contents; |
| 991 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 991 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 992 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY)); | 992 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY)); |
| 993 | 993 |
| 994 // Some fast paths through GetKeysInFixedArrayFor reuse a cached | 994 // Some fast paths through GetKeysInFixedArrayFor reuse a cached |
| 995 // property array and since the result is mutable we have to create | 995 // property array and since the result is mutable we have to create |
| 996 // a fresh clone on each invocation. | 996 // a fresh clone on each invocation. |
| 997 int length = contents->length(); | 997 int length = contents->length(); |
| 998 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); | 998 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length); |
| 999 for (int i = 0; i < length; i++) { | 999 int offset = 0; |
| 1000 Object* entry = contents->get(i); | 1000 // Use an outer loop to avoid creating too many handles in the current |
| 1001 if (entry->IsString()) { | 1001 // handle scope. |
| 1002 copy->set(i, entry); | 1002 while (offset < length) { |
| 1003 } else { | 1003 HandleScope scope(isolate); |
| 1004 DCHECK(entry->IsNumber()); | 1004 offset += 100; |
| 1005 HandleScope scope(isolate); | 1005 for (int i = offset - 100; i < offset && i < length; i++) { |
| 1006 Handle<Object> entry_handle(entry, isolate); | 1006 Object* entry = contents->get(i); |
| 1007 Handle<Object> entry_str = | 1007 if (entry->IsString()) { |
| 1008 isolate->factory()->NumberToString(entry_handle); | 1008 copy->set(i, entry); |
| 1009 copy->set(i, *entry_str); | 1009 } else { |
| 1010 DCHECK(entry->IsNumber()); |
| 1011 Handle<Object> entry_handle(entry, isolate); |
| 1012 Handle<Object> entry_str = |
| 1013 isolate->factory()->NumberToString(entry_handle); |
| 1014 copy->set(i, *entry_str); |
| 1015 } |
| 1010 } | 1016 } |
| 1011 } | 1017 } |
| 1012 return *isolate->factory()->NewJSArrayWithElements(copy); | 1018 return *isolate->factory()->NewJSArrayWithElements(copy); |
| 1013 } | 1019 } |
| 1014 | 1020 |
| 1015 | 1021 |
| 1016 RUNTIME_FUNCTION(Runtime_ToFastProperties) { | 1022 RUNTIME_FUNCTION(Runtime_ToFastProperties) { |
| 1017 HandleScope scope(isolate); | 1023 HandleScope scope(isolate); |
| 1018 DCHECK(args.length() == 1); | 1024 DCHECK(args.length() == 1); |
| 1019 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 1025 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 RUNTIME_FUNCTION(Runtime_CreateIterResultObject) { | 1560 RUNTIME_FUNCTION(Runtime_CreateIterResultObject) { |
| 1555 HandleScope scope(isolate); | 1561 HandleScope scope(isolate); |
| 1556 DCHECK_EQ(2, args.length()); | 1562 DCHECK_EQ(2, args.length()); |
| 1557 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 1563 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
| 1558 CONVERT_ARG_HANDLE_CHECKED(Object, done, 1); | 1564 CONVERT_ARG_HANDLE_CHECKED(Object, done, 1); |
| 1559 return *isolate->factory()->NewJSIteratorResult(value, done); | 1565 return *isolate->factory()->NewJSIteratorResult(value, done); |
| 1560 } | 1566 } |
| 1561 | 1567 |
| 1562 } // namespace internal | 1568 } // namespace internal |
| 1563 } // namespace v8 | 1569 } // namespace v8 |
| OLD | NEW |