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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 1316213008: Speedup JSReceiver::GetKeys (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Compilation Fix Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 int end = Min(offset, length);
1006 Handle<Object> entry_handle(entry, isolate); 1006 for (int i = offset - 100; i < end; i++) {
1007 Handle<Object> entry_str = 1007 Object* entry = contents->get(i);
1008 isolate->factory()->NumberToString(entry_handle); 1008 if (entry->IsString()) {
1009 copy->set(i, *entry_str); 1009 copy->set(i, entry);
1010 } else {
1011 DCHECK(entry->IsNumber());
1012 Handle<Object> entry_handle(entry, isolate);
1013 Handle<Object> entry_str =
1014 isolate->factory()->NumberToString(entry_handle);
1015 copy->set(i, *entry_str);
1016 }
1010 } 1017 }
1011 } 1018 }
1012 return *isolate->factory()->NewJSArrayWithElements(copy); 1019 return *isolate->factory()->NewJSArrayWithElements(copy);
1013 } 1020 }
1014 1021
1015 1022
1016 RUNTIME_FUNCTION(Runtime_ToFastProperties) { 1023 RUNTIME_FUNCTION(Runtime_ToFastProperties) {
1017 HandleScope scope(isolate); 1024 HandleScope scope(isolate);
1018 DCHECK(args.length() == 1); 1025 DCHECK(args.length() == 1);
1019 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 1026 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 RUNTIME_FUNCTION(Runtime_CreateIterResultObject) { 1565 RUNTIME_FUNCTION(Runtime_CreateIterResultObject) {
1559 HandleScope scope(isolate); 1566 HandleScope scope(isolate);
1560 DCHECK_EQ(2, args.length()); 1567 DCHECK_EQ(2, args.length());
1561 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); 1568 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0);
1562 CONVERT_ARG_HANDLE_CHECKED(Object, done, 1); 1569 CONVERT_ARG_HANDLE_CHECKED(Object, done, 1);
1563 return *isolate->factory()->NewJSIteratorResult(value, done); 1570 return *isolate->factory()->NewJSIteratorResult(value, done);
1564 } 1571 }
1565 1572
1566 } // namespace internal 1573 } // namespace internal
1567 } // namespace v8 1574 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698