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

Side by Side Diff: src/builtins.cc

Issue 2010593002: Revert of [keys] Simplify KeyAccumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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/api.cc ('k') | src/debug/debug-scopes.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api-arguments.h" 7 #include "src/api-arguments.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 // 4a. If nextSource is undefined or null, let keys be an empty List. 1621 // 4a. If nextSource is undefined or null, let keys be an empty List.
1622 // 4b. Else, 1622 // 4b. Else,
1623 // 4b i. Let from be ToObject(nextSource). 1623 // 4b i. Let from be ToObject(nextSource).
1624 // Only non-empty strings and JSReceivers have enumerable properties. 1624 // Only non-empty strings and JSReceivers have enumerable properties.
1625 Handle<JSReceiver> from = 1625 Handle<JSReceiver> from =
1626 Object::ToObject(isolate, next_source).ToHandleChecked(); 1626 Object::ToObject(isolate, next_source).ToHandleChecked();
1627 // 4b ii. Let keys be ? from.[[OwnPropertyKeys]](). 1627 // 4b ii. Let keys be ? from.[[OwnPropertyKeys]]().
1628 Handle<FixedArray> keys; 1628 Handle<FixedArray> keys;
1629 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1629 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1630 isolate, keys, 1630 isolate, keys,
1631 KeyAccumulator::GetKeys(from, OWN_ONLY, ALL_PROPERTIES, KEEP_NUMBERS)); 1631 JSReceiver::GetKeys(from, OWN_ONLY, ALL_PROPERTIES, KEEP_NUMBERS));
1632 // 4c. Repeat for each element nextKey of keys in List order, 1632 // 4c. Repeat for each element nextKey of keys in List order,
1633 for (int j = 0; j < keys->length(); ++j) { 1633 for (int j = 0; j < keys->length(); ++j) {
1634 Handle<Object> next_key(keys->get(j), isolate); 1634 Handle<Object> next_key(keys->get(j), isolate);
1635 // 4c i. Let desc be ? from.[[GetOwnProperty]](nextKey). 1635 // 4c i. Let desc be ? from.[[GetOwnProperty]](nextKey).
1636 PropertyDescriptor desc; 1636 PropertyDescriptor desc;
1637 Maybe<bool> found = 1637 Maybe<bool> found =
1638 JSReceiver::GetOwnPropertyDescriptor(isolate, from, next_key, &desc); 1638 JSReceiver::GetOwnPropertyDescriptor(isolate, from, next_key, &desc);
1639 if (found.IsNothing()) return isolate->heap()->exception(); 1639 if (found.IsNothing()) return isolate->heap()->exception();
1640 // 4c ii. If desc is not undefined and desc.[[Enumerable]] is true, then 1640 // 4c ii. If desc is not undefined and desc.[[Enumerable]] is true, then
1641 if (found.FromJust() && desc.enumerable()) { 1641 if (found.FromJust() && desc.enumerable()) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 BuiltinArguments<BuiltinExtraArguments::kNone> args, 1894 BuiltinArguments<BuiltinExtraArguments::kNone> args,
1895 PropertyFilter filter) { 1895 PropertyFilter filter) {
1896 HandleScope scope(isolate); 1896 HandleScope scope(isolate);
1897 Handle<Object> object = args.atOrUndefined(isolate, 1); 1897 Handle<Object> object = args.atOrUndefined(isolate, 1);
1898 Handle<JSReceiver> receiver; 1898 Handle<JSReceiver> receiver;
1899 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, 1899 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
1900 Object::ToObject(isolate, object)); 1900 Object::ToObject(isolate, object));
1901 Handle<FixedArray> keys; 1901 Handle<FixedArray> keys;
1902 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1902 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1903 isolate, keys, 1903 isolate, keys,
1904 KeyAccumulator::GetKeys(receiver, OWN_ONLY, filter, CONVERT_TO_STRING)); 1904 JSReceiver::GetKeys(receiver, OWN_ONLY, filter, CONVERT_TO_STRING));
1905 return *isolate->factory()->NewJSArrayWithElements(keys); 1905 return *isolate->factory()->NewJSArrayWithElements(keys);
1906 } 1906 }
1907 1907
1908 } // namespace 1908 } // namespace
1909 1909
1910 1910
1911 // ES6 section 19.1.2.7 Object.getOwnPropertyNames ( O ) 1911 // ES6 section 19.1.2.7 Object.getOwnPropertyNames ( O )
1912 BUILTIN(ObjectGetOwnPropertyNames) { 1912 BUILTIN(ObjectGetOwnPropertyNames) {
1913 return GetOwnPropertyKeys(isolate, args, SKIP_SYMBOLS); 1913 return GetOwnPropertyKeys(isolate, args, SKIP_SYMBOLS);
1914 } 1914 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 if (enum_length == 0) { 1990 if (enum_length == 0) {
1991 keys = isolate->factory()->empty_fixed_array(); 1991 keys = isolate->factory()->empty_fixed_array();
1992 } else { 1992 } else {
1993 Handle<FixedArray> cache( 1993 Handle<FixedArray> cache(
1994 receiver->map()->instance_descriptors()->GetEnumCache()); 1994 receiver->map()->instance_descriptors()->GetEnumCache());
1995 keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length); 1995 keys = isolate->factory()->CopyFixedArrayUpTo(cache, enum_length);
1996 } 1996 }
1997 } else { 1997 } else {
1998 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1998 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1999 isolate, keys, 1999 isolate, keys,
2000 KeyAccumulator::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS, 2000 JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS,
2001 CONVERT_TO_STRING)); 2001 CONVERT_TO_STRING));
2002 } 2002 }
2003 return *isolate->factory()->NewJSArrayWithElements(keys, FAST_ELEMENTS); 2003 return *isolate->factory()->NewJSArrayWithElements(keys, FAST_ELEMENTS);
2004 } 2004 }
2005 2005
2006 BUILTIN(ObjectValues) { 2006 BUILTIN(ObjectValues) {
2007 HandleScope scope(isolate); 2007 HandleScope scope(isolate);
2008 Handle<Object> object = args.atOrUndefined(isolate, 1); 2008 Handle<Object> object = args.atOrUndefined(isolate, 1);
2009 Handle<JSReceiver> receiver; 2009 Handle<JSReceiver> receiver;
2010 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, 2010 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
2011 Object::ToObject(isolate, object)); 2011 Object::ToObject(isolate, object));
(...skipping 21 matching lines...) Expand all
2033 HandleScope scope(isolate); 2033 HandleScope scope(isolate);
2034 Handle<Object> object = args.atOrUndefined(isolate, 1); 2034 Handle<Object> object = args.atOrUndefined(isolate, 1);
2035 Handle<Object> undefined = isolate->factory()->undefined_value(); 2035 Handle<Object> undefined = isolate->factory()->undefined_value();
2036 2036
2037 Handle<JSReceiver> receiver; 2037 Handle<JSReceiver> receiver;
2038 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, 2038 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
2039 Object::ToObject(isolate, object)); 2039 Object::ToObject(isolate, object));
2040 2040
2041 Handle<FixedArray> keys; 2041 Handle<FixedArray> keys;
2042 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 2042 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2043 isolate, keys, KeyAccumulator::GetKeys(receiver, OWN_ONLY, ALL_PROPERTIES, 2043 isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ALL_PROPERTIES,
2044 CONVERT_TO_STRING)); 2044 CONVERT_TO_STRING));
2045 2045
2046 Handle<JSObject> descriptors = 2046 Handle<JSObject> descriptors =
2047 isolate->factory()->NewJSObject(isolate->object_function()); 2047 isolate->factory()->NewJSObject(isolate->object_function());
2048 2048
2049 for (int i = 0; i < keys->length(); ++i) { 2049 for (int i = 0; i < keys->length(); ++i) {
2050 Handle<Name> key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); 2050 Handle<Name> key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate));
2051 PropertyDescriptor descriptor; 2051 PropertyDescriptor descriptor;
2052 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( 2052 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor(
2053 isolate, receiver, key, &descriptor); 2053 isolate, receiver, key, &descriptor);
2054 MAYBE_RETURN(did_get_descriptor, isolate->heap()->exception()); 2054 MAYBE_RETURN(did_get_descriptor, isolate->heap()->exception());
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
2701 if (!target->IsJSReceiver()) { 2701 if (!target->IsJSReceiver()) {
2702 THROW_NEW_ERROR_RETURN_FAILURE( 2702 THROW_NEW_ERROR_RETURN_FAILURE(
2703 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, 2703 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject,
2704 isolate->factory()->NewStringFromAsciiChecked( 2704 isolate->factory()->NewStringFromAsciiChecked(
2705 "Reflect.ownKeys"))); 2705 "Reflect.ownKeys")));
2706 } 2706 }
2707 2707
2708 Handle<FixedArray> keys; 2708 Handle<FixedArray> keys;
2709 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 2709 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2710 isolate, keys, 2710 isolate, keys,
2711 KeyAccumulator::GetKeys(Handle<JSReceiver>::cast(target), OWN_ONLY, 2711 JSReceiver::GetKeys(Handle<JSReceiver>::cast(target), OWN_ONLY,
2712 ALL_PROPERTIES, CONVERT_TO_STRING)); 2712 ALL_PROPERTIES, CONVERT_TO_STRING));
2713 return *isolate->factory()->NewJSArrayWithElements(keys); 2713 return *isolate->factory()->NewJSArrayWithElements(keys);
2714 } 2714 }
2715 2715
2716 2716
2717 // ES6 section 26.1.12 Reflect.preventExtensions 2717 // ES6 section 26.1.12 Reflect.preventExtensions
2718 BUILTIN(ReflectPreventExtensions) { 2718 BUILTIN(ReflectPreventExtensions) {
2719 HandleScope scope(isolate); 2719 HandleScope scope(isolate);
2720 DCHECK_EQ(2, args.length()); 2720 DCHECK_EQ(2, args.length());
2721 Handle<Object> target = args.at<Object>(1); 2721 Handle<Object> target = args.at<Object>(1);
2722 2722
(...skipping 2809 matching lines...) Expand 10 before | Expand all | Expand 10 after
5532 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) 5532 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
5533 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 5533 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
5534 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 5534 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
5535 #undef DEFINE_BUILTIN_ACCESSOR_C 5535 #undef DEFINE_BUILTIN_ACCESSOR_C
5536 #undef DEFINE_BUILTIN_ACCESSOR_A 5536 #undef DEFINE_BUILTIN_ACCESSOR_A
5537 #undef DEFINE_BUILTIN_ACCESSOR_T 5537 #undef DEFINE_BUILTIN_ACCESSOR_T
5538 #undef DEFINE_BUILTIN_ACCESSOR_H 5538 #undef DEFINE_BUILTIN_ACCESSOR_H
5539 5539
5540 } // namespace internal 5540 } // namespace internal
5541 } // namespace v8 5541 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/debug/debug-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698