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

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

Issue 1397063002: [runtime] Fancify KeyAccumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: documentation + cleanup Created 5 years, 2 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
« src/objects.cc ('K') | « 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 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 RUNTIME_FUNCTION(Runtime_OwnKeys) { 976 RUNTIME_FUNCTION(Runtime_OwnKeys) {
977 HandleScope scope(isolate); 977 HandleScope scope(isolate);
978 DCHECK(args.length() == 1); 978 DCHECK(args.length() == 1);
979 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); 979 CONVERT_ARG_CHECKED(JSObject, raw_object, 0);
980 Handle<JSObject> object(raw_object); 980 Handle<JSObject> object(raw_object);
981 981
982 Handle<FixedArray> contents; 982 Handle<FixedArray> contents;
983 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 983 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
984 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY)); 984 isolate, contents, JSReceiver::GetKeys(object, JSReceiver::OWN_ONLY));
985 985
986 // Some fast paths through GetKeysInFixedArrayFor reuse a cached
987 // property array and since the result is mutable we have to create
988 // a fresh clone on each invocation.
989 int length = contents->length(); 986 int length = contents->length();
990 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length);
991 int offset = 0; 987 int offset = 0;
992 // Use an outer loop to avoid creating too many handles in the current 988 // Use an outer loop to avoid creating too many handles in the current
993 // handle scope. 989 // handle scope.
994 while (offset < length) { 990 while (offset < length) {
995 HandleScope scope(isolate); 991 HandleScope scope(isolate);
996 offset += 100; 992 offset += 100;
997 int end = Min(offset, length); 993 int end = Min(offset, length);
998 for (int i = offset - 100; i < end; i++) { 994 for (int i = offset - 100; i < end; i++) {
999 Object* entry = contents->get(i); 995 Object* entry = contents->get(i);
1000 if (entry->IsString()) { 996 if (entry->IsString()) continue;
1001 copy->set(i, entry); 997
1002 } else { 998 DCHECK(entry->IsNumber());
1003 DCHECK(entry->IsNumber()); 999 Handle<Object> entry_handle(entry, isolate);
1004 Handle<Object> entry_handle(entry, isolate); 1000 Handle<Object> entry_str =
1005 Handle<Object> entry_str = 1001 isolate->factory()->NumberToString(entry_handle);
1006 isolate->factory()->NumberToString(entry_handle); 1002 contents->set(i, *entry_str);
1007 copy->set(i, *entry_str);
1008 }
1009 } 1003 }
1010 } 1004 }
1011 return *isolate->factory()->NewJSArrayWithElements(copy); 1005 return *isolate->factory()->NewJSArrayWithElements(contents);
1012 } 1006 }
1013 1007
1014 1008
1015 RUNTIME_FUNCTION(Runtime_ToFastProperties) { 1009 RUNTIME_FUNCTION(Runtime_ToFastProperties) {
1016 HandleScope scope(isolate); 1010 HandleScope scope(isolate);
1017 DCHECK(args.length() == 1); 1011 DCHECK(args.length() == 1);
1018 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 1012 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
1019 if (object->IsJSObject() && !object->IsGlobalObject()) { 1013 if (object->IsJSObject() && !object->IsGlobalObject()) {
1020 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0, 1014 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0,
1021 "RuntimeToFastProperties"); 1015 "RuntimeToFastProperties");
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { 1616 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) {
1623 SealHandleScope shs(isolate); 1617 SealHandleScope shs(isolate);
1624 DCHECK_EQ(1, args.length()); 1618 DCHECK_EQ(1, args.length());
1625 CONVERT_ARG_CHECKED(Object, object, 0); 1619 CONVERT_ARG_CHECKED(Object, object, 0);
1626 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); 1620 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded());
1627 } 1621 }
1628 1622
1629 1623
1630 } // namespace internal 1624 } // namespace internal
1631 } // namespace v8 1625 } // namespace v8
OLDNEW
« src/objects.cc ('K') | « src/runtime/runtime-array.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698