| OLD | NEW |
| 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.h" | 7 #include "src/api.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 Handle<Object> next_source = args.at<Object>(i); | 1581 Handle<Object> next_source = args.at<Object>(i); |
| 1582 // 4a. If nextSource is undefined or null, let keys be an empty List. | 1582 // 4a. If nextSource is undefined or null, let keys be an empty List. |
| 1583 if (next_source->IsUndefined() || next_source->IsNull()) continue; | 1583 if (next_source->IsUndefined() || next_source->IsNull()) continue; |
| 1584 // 4b. Else, | 1584 // 4b. Else, |
| 1585 // 4b i. Let from be ToObject(nextSource). | 1585 // 4b i. Let from be ToObject(nextSource). |
| 1586 Handle<JSReceiver> from = | 1586 Handle<JSReceiver> from = |
| 1587 Object::ToObject(isolate, next_source).ToHandleChecked(); | 1587 Object::ToObject(isolate, next_source).ToHandleChecked(); |
| 1588 // 4b ii. Let keys be ? from.[[OwnPropertyKeys]](). | 1588 // 4b ii. Let keys be ? from.[[OwnPropertyKeys]](). |
| 1589 Handle<FixedArray> keys; | 1589 Handle<FixedArray> keys; |
| 1590 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1590 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1591 isolate, keys, JSReceiver::GetKeys(from, JSReceiver::OWN_ONLY, | 1591 isolate, keys, |
| 1592 ALL_PROPERTIES, KEEP_NUMBERS)); | 1592 JSReceiver::GetKeys(from, OWN_ONLY, ALL_PROPERTIES, KEEP_NUMBERS)); |
| 1593 // 4c. Repeat for each element nextKey of keys in List order, | 1593 // 4c. Repeat for each element nextKey of keys in List order, |
| 1594 for (int j = 0; j < keys->length(); ++j) { | 1594 for (int j = 0; j < keys->length(); ++j) { |
| 1595 Handle<Object> next_key(keys->get(j), isolate); | 1595 Handle<Object> next_key(keys->get(j), isolate); |
| 1596 // 4c i. Let desc be ? from.[[GetOwnProperty]](nextKey). | 1596 // 4c i. Let desc be ? from.[[GetOwnProperty]](nextKey). |
| 1597 PropertyDescriptor desc; | 1597 PropertyDescriptor desc; |
| 1598 Maybe<bool> found = | 1598 Maybe<bool> found = |
| 1599 JSReceiver::GetOwnPropertyDescriptor(isolate, from, next_key, &desc); | 1599 JSReceiver::GetOwnPropertyDescriptor(isolate, from, next_key, &desc); |
| 1600 if (found.IsNothing()) return isolate->heap()->exception(); | 1600 if (found.IsNothing()) return isolate->heap()->exception(); |
| 1601 // 4c ii. If desc is not undefined and desc.[[Enumerable]] is true, then | 1601 // 4c ii. If desc is not undefined and desc.[[Enumerable]] is true, then |
| 1602 if (found.FromJust() && desc.enumerable()) { | 1602 if (found.FromJust() && desc.enumerable()) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 Object* GetOwnPropertyKeys(Isolate* isolate, | 1669 Object* GetOwnPropertyKeys(Isolate* isolate, |
| 1670 BuiltinArguments<BuiltinExtraArguments::kNone> args, | 1670 BuiltinArguments<BuiltinExtraArguments::kNone> args, |
| 1671 PropertyFilter filter) { | 1671 PropertyFilter filter) { |
| 1672 HandleScope scope(isolate); | 1672 HandleScope scope(isolate); |
| 1673 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1673 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1674 Handle<JSReceiver> receiver; | 1674 Handle<JSReceiver> receiver; |
| 1675 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 1675 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1676 Object::ToObject(isolate, object)); | 1676 Object::ToObject(isolate, object)); |
| 1677 Handle<FixedArray> keys; | 1677 Handle<FixedArray> keys; |
| 1678 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1678 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1679 isolate, keys, JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, filter, | 1679 isolate, keys, |
| 1680 CONVERT_TO_STRING)); | 1680 JSReceiver::GetKeys(receiver, OWN_ONLY, filter, CONVERT_TO_STRING)); |
| 1681 return *isolate->factory()->NewJSArrayWithElements(keys); | 1681 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 } // namespace | 1684 } // namespace |
| 1685 | 1685 |
| 1686 | 1686 |
| 1687 // ES6 section 19.1.2.7 Object.getOwnPropertyNames ( O ) | 1687 // ES6 section 19.1.2.7 Object.getOwnPropertyNames ( O ) |
| 1688 BUILTIN(ObjectGetOwnPropertyNames) { | 1688 BUILTIN(ObjectGetOwnPropertyNames) { |
| 1689 return GetOwnPropertyKeys(isolate, args, SKIP_SYMBOLS); | 1689 return GetOwnPropertyKeys(isolate, args, SKIP_SYMBOLS); |
| 1690 } | 1690 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 | 1737 |
| 1738 // ES6 section 19.1.2.14 Object.keys ( O ) | 1738 // ES6 section 19.1.2.14 Object.keys ( O ) |
| 1739 BUILTIN(ObjectKeys) { | 1739 BUILTIN(ObjectKeys) { |
| 1740 HandleScope scope(isolate); | 1740 HandleScope scope(isolate); |
| 1741 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1741 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1742 Handle<JSReceiver> receiver; | 1742 Handle<JSReceiver> receiver; |
| 1743 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 1743 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1744 Object::ToObject(isolate, object)); | 1744 Object::ToObject(isolate, object)); |
| 1745 Handle<FixedArray> keys; | 1745 Handle<FixedArray> keys; |
| 1746 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1746 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1747 isolate, keys, | 1747 isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS, |
| 1748 JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, | 1748 CONVERT_TO_STRING)); |
| 1749 CONVERT_TO_STRING)); | |
| 1750 return *isolate->factory()->NewJSArrayWithElements(keys); | 1749 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 1751 } | 1750 } |
| 1752 | 1751 |
| 1753 | 1752 |
| 1754 BUILTIN(ObjectValues) { | 1753 BUILTIN(ObjectValues) { |
| 1755 HandleScope scope(isolate); | 1754 HandleScope scope(isolate); |
| 1756 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1755 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1757 Handle<JSReceiver> receiver; | 1756 Handle<JSReceiver> receiver; |
| 1758 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 1757 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1759 Object::ToObject(isolate, object)); | 1758 Object::ToObject(isolate, object)); |
| 1760 Handle<FixedArray> keys; | 1759 Handle<FixedArray> keys; |
| 1761 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1760 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1762 isolate, keys, | 1761 isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS, |
| 1763 JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, | 1762 CONVERT_TO_STRING)); |
| 1764 CONVERT_TO_STRING)); | |
| 1765 | 1763 |
| 1766 for (int i = 0; i < keys->length(); ++i) { | 1764 for (int i = 0; i < keys->length(); ++i) { |
| 1767 auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); | 1765 auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); |
| 1768 Handle<Object> value; | 1766 Handle<Object> value; |
| 1769 | 1767 |
| 1770 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1768 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1771 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); | 1769 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); |
| 1772 | 1770 |
| 1773 keys->set(i, *value); | 1771 keys->set(i, *value); |
| 1774 } | 1772 } |
| 1775 | 1773 |
| 1776 return *isolate->factory()->NewJSArrayWithElements(keys); | 1774 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 1777 } | 1775 } |
| 1778 | 1776 |
| 1779 | 1777 |
| 1780 BUILTIN(ObjectEntries) { | 1778 BUILTIN(ObjectEntries) { |
| 1781 HandleScope scope(isolate); | 1779 HandleScope scope(isolate); |
| 1782 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1780 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1783 Handle<JSReceiver> receiver; | 1781 Handle<JSReceiver> receiver; |
| 1784 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 1782 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1785 Object::ToObject(isolate, object)); | 1783 Object::ToObject(isolate, object)); |
| 1786 Handle<FixedArray> keys; | 1784 Handle<FixedArray> keys; |
| 1787 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1785 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1788 isolate, keys, | 1786 isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS, |
| 1789 JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, | 1787 CONVERT_TO_STRING)); |
| 1790 CONVERT_TO_STRING)); | |
| 1791 | 1788 |
| 1792 for (int i = 0; i < keys->length(); ++i) { | 1789 for (int i = 0; i < keys->length(); ++i) { |
| 1793 auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); | 1790 auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); |
| 1794 Handle<Object> value; | 1791 Handle<Object> value; |
| 1795 | 1792 |
| 1796 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1793 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1797 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); | 1794 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); |
| 1798 | 1795 |
| 1799 auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2); | 1796 auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2); |
| 1800 entry_storage->set(0, *key); | 1797 entry_storage->set(0, *key); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 | 2080 |
| 2084 if (!target->IsJSReceiver()) { | 2081 if (!target->IsJSReceiver()) { |
| 2085 THROW_NEW_ERROR_RETURN_FAILURE( | 2082 THROW_NEW_ERROR_RETURN_FAILURE( |
| 2086 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 2083 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 2087 isolate->factory()->NewStringFromAsciiChecked( | 2084 isolate->factory()->NewStringFromAsciiChecked( |
| 2088 "Reflect.ownKeys"))); | 2085 "Reflect.ownKeys"))); |
| 2089 } | 2086 } |
| 2090 | 2087 |
| 2091 Handle<FixedArray> keys; | 2088 Handle<FixedArray> keys; |
| 2092 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2089 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 2093 isolate, keys, JSReceiver::GetKeys(Handle<JSReceiver>::cast(target), | 2090 isolate, keys, |
| 2094 JSReceiver::OWN_ONLY, ALL_PROPERTIES, | 2091 JSReceiver::GetKeys(Handle<JSReceiver>::cast(target), OWN_ONLY, |
| 2095 CONVERT_TO_STRING)); | 2092 ALL_PROPERTIES, CONVERT_TO_STRING)); |
| 2096 return *isolate->factory()->NewJSArrayWithElements(keys); | 2093 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 2097 } | 2094 } |
| 2098 | 2095 |
| 2099 | 2096 |
| 2100 // ES6 section 26.1.12 Reflect.preventExtensions | 2097 // ES6 section 26.1.12 Reflect.preventExtensions |
| 2101 BUILTIN(ReflectPreventExtensions) { | 2098 BUILTIN(ReflectPreventExtensions) { |
| 2102 HandleScope scope(isolate); | 2099 HandleScope scope(isolate); |
| 2103 DCHECK_EQ(2, args.length()); | 2100 DCHECK_EQ(2, args.length()); |
| 2104 Handle<Object> target = args.at<Object>(1); | 2101 Handle<Object> target = args.at<Object>(1); |
| 2105 | 2102 |
| (...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4191 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4188 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 4192 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4189 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4193 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4190 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4194 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4191 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4195 #undef DEFINE_BUILTIN_ACCESSOR_C | 4192 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4196 #undef DEFINE_BUILTIN_ACCESSOR_A | 4193 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4197 | 4194 |
| 4198 | 4195 |
| 4199 } // namespace internal | 4196 } // namespace internal |
| 4200 } // namespace v8 | 4197 } // namespace v8 |
| OLD | NEW |