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

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: nits 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
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | test/mjsunit/third_party/object-keys/object-keys.js » ('j') | 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 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 974
975 975
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 SKIP_SYMBOLS, CONVERT_TO_STRING));
986 // Some fast paths through GetKeysInFixedArrayFor reuse a cached 986 return *isolate->factory()->NewJSArrayWithElements(contents);
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();
990 Handle<FixedArray> copy = isolate->factory()->NewFixedArray(length);
991 int offset = 0;
992 // Use an outer loop to avoid creating too many handles in the current
993 // handle scope.
994 while (offset < length) {
995 HandleScope scope(isolate);
996 offset += 100;
997 int end = Min(offset, length);
998 for (int i = offset - 100; i < end; i++) {
999 Object* entry = contents->get(i);
1000 if (entry->IsString()) {
1001 copy->set(i, entry);
1002 } else {
1003 DCHECK(entry->IsNumber());
1004 Handle<Object> entry_handle(entry, isolate);
1005 Handle<Object> entry_str =
1006 isolate->factory()->NumberToString(entry_handle);
1007 copy->set(i, *entry_str);
1008 }
1009 }
1010 }
1011 return *isolate->factory()->NewJSArrayWithElements(copy);
1012 } 987 }
1013 988
1014 989
1015 RUNTIME_FUNCTION(Runtime_ToFastProperties) { 990 RUNTIME_FUNCTION(Runtime_ToFastProperties) {
1016 HandleScope scope(isolate); 991 HandleScope scope(isolate);
1017 DCHECK(args.length() == 1); 992 DCHECK(args.length() == 1);
1018 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 993 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
1019 if (object->IsJSObject() && !object->IsGlobalObject()) { 994 if (object->IsJSObject() && !object->IsGlobalObject()) {
1020 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0, 995 JSObject::MigrateSlowToFast(Handle<JSObject>::cast(object), 0,
1021 "RuntimeToFastProperties"); 996 "RuntimeToFastProperties");
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 1614
1640 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { 1615 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
1641 HandleScope scope(isolate); 1616 HandleScope scope(isolate);
1642 DCHECK(args.length() == 2); 1617 DCHECK(args.length() == 2);
1643 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1618 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1644 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1619 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1645 return JSReceiver::DefineProperties(isolate, o, properties); 1620 return JSReceiver::DefineProperties(isolate, o, properties);
1646 } 1621 }
1647 } // namespace internal 1622 } // namespace internal
1648 } // namespace v8 1623 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-array.cc ('k') | test/mjsunit/third_party/object-keys/object-keys.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698