| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 1557 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
| 1558 SealHandleScope shs(isolate); | 1558 SealHandleScope shs(isolate); |
| 1559 ASSERT(args.length() == 1); | 1559 ASSERT(args.length() == 1); |
| 1560 Object* obj = args[0]; | 1560 Object* obj = args[0]; |
| 1561 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 1561 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
| 1562 return JSObject::cast(obj)->class_name(); | 1562 return JSObject::cast(obj)->class_name(); |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 | 1565 |
| 1566 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 1566 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { |
| 1567 SealHandleScope shs(isolate); | 1567 HandleScope scope(isolate); |
| 1568 ASSERT(args.length() == 1); | 1568 ASSERT(args.length() == 1); |
| 1569 CONVERT_ARG_CHECKED(Object, obj, 0); | 1569 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 1570 // We don't expect access checks to be needed on JSProxy objects. | 1570 // We don't expect access checks to be needed on JSProxy objects. |
| 1571 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 1571 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 1572 do { | 1572 do { |
| 1573 if (obj->IsAccessCheckNeeded() && | 1573 if (obj->IsAccessCheckNeeded() && |
| 1574 !isolate->MayNamedAccess(JSObject::cast(obj), | 1574 !isolate->MayNamedAccessWrapper(Handle<JSObject>::cast(obj), |
| 1575 isolate->heap()->proto_string(), | 1575 isolate->factory()->proto_string(), |
| 1576 v8::ACCESS_GET)) { | 1576 v8::ACCESS_GET)) { |
| 1577 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); | 1577 isolate->ReportFailedAccessCheck(JSObject::cast(*obj), v8::ACCESS_GET); |
| 1578 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1578 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 1579 return isolate->heap()->undefined_value(); | 1579 return isolate->heap()->undefined_value(); |
| 1580 } | 1580 } |
| 1581 obj = obj->GetPrototype(isolate); | 1581 obj = handle(obj->GetPrototype(isolate), isolate); |
| 1582 } while (obj->IsJSObject() && | 1582 } while (obj->IsJSObject() && |
| 1583 JSObject::cast(obj)->map()->is_hidden_prototype()); | 1583 JSObject::cast(*obj)->map()->is_hidden_prototype()); |
| 1584 return obj; | 1584 return *obj; |
| 1585 } | 1585 } |
| 1586 | 1586 |
| 1587 | 1587 |
| 1588 static inline Object* GetPrototypeSkipHiddenPrototypes(Isolate* isolate, | 1588 static inline Object* GetPrototypeSkipHiddenPrototypes(Isolate* isolate, |
| 1589 Object* receiver) { | 1589 Object* receiver) { |
| 1590 Object* current = receiver->GetPrototype(isolate); | 1590 Object* current = receiver->GetPrototype(isolate); |
| 1591 while (current->IsJSObject() && | 1591 while (current->IsJSObject() && |
| 1592 JSObject::cast(current)->map()->is_hidden_prototype()) { | 1592 JSObject::cast(current)->map()->is_hidden_prototype()) { |
| 1593 current = current->GetPrototype(isolate); | 1593 current = current->GetPrototype(isolate); |
| 1594 } | 1594 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 Object* prototype = V->GetPrototype(isolate); | 1633 Object* prototype = V->GetPrototype(isolate); |
| 1634 if (prototype->IsNull()) return isolate->heap()->false_value(); | 1634 if (prototype->IsNull()) return isolate->heap()->false_value(); |
| 1635 if (O == prototype) return isolate->heap()->true_value(); | 1635 if (O == prototype) return isolate->heap()->true_value(); |
| 1636 V = prototype; | 1636 V = prototype; |
| 1637 } | 1637 } |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 | 1640 |
| 1641 static bool CheckAccessException(Object* callback, | 1641 static bool CheckAccessException(Object* callback, |
| 1642 v8::AccessType access_type) { | 1642 v8::AccessType access_type) { |
| 1643 DisallowHeapAllocation no_gc; |
| 1643 if (callback->IsAccessorInfo()) { | 1644 if (callback->IsAccessorInfo()) { |
| 1644 AccessorInfo* info = AccessorInfo::cast(callback); | 1645 AccessorInfo* info = AccessorInfo::cast(callback); |
| 1645 return | 1646 return |
| 1646 (access_type == v8::ACCESS_HAS && | 1647 (access_type == v8::ACCESS_HAS && |
| 1647 (info->all_can_read() || info->all_can_write())) || | 1648 (info->all_can_read() || info->all_can_write())) || |
| 1648 (access_type == v8::ACCESS_GET && info->all_can_read()) || | 1649 (access_type == v8::ACCESS_GET && info->all_can_read()) || |
| 1649 (access_type == v8::ACCESS_SET && info->all_can_write()); | 1650 (access_type == v8::ACCESS_SET && info->all_can_write()); |
| 1650 } | 1651 } |
| 1651 if (callback->IsAccessorPair()) { | 1652 if (callback->IsAccessorPair()) { |
| 1652 AccessorPair* info = AccessorPair::cast(callback); | 1653 AccessorPair* info = AccessorPair::cast(callback); |
| 1653 return | 1654 return |
| 1654 (access_type == v8::ACCESS_HAS && | 1655 (access_type == v8::ACCESS_HAS && |
| 1655 (info->all_can_read() || info->all_can_write())) || | 1656 (info->all_can_read() || info->all_can_write())) || |
| 1656 (access_type == v8::ACCESS_GET && info->all_can_read()) || | 1657 (access_type == v8::ACCESS_GET && info->all_can_read()) || |
| 1657 (access_type == v8::ACCESS_SET && info->all_can_write()); | 1658 (access_type == v8::ACCESS_SET && info->all_can_write()); |
| 1658 } | 1659 } |
| 1659 return false; | 1660 return false; |
| 1660 } | 1661 } |
| 1661 | 1662 |
| 1662 | 1663 |
| 1663 template<class Key> | 1664 template<class Key> |
| 1664 static bool CheckGenericAccess( | 1665 static bool CheckGenericAccess( |
| 1665 JSObject* receiver, | 1666 Handle<JSObject> receiver, |
| 1666 JSObject* holder, | 1667 Handle<JSObject> holder, |
| 1667 Key key, | 1668 Key key, |
| 1668 v8::AccessType access_type, | 1669 v8::AccessType access_type, |
| 1669 bool (Isolate::*mayAccess)(JSObject*, Key, v8::AccessType)) { | 1670 bool (Isolate::*mayAccess)(Handle<JSObject>, Key, v8::AccessType)) { |
| 1670 Isolate* isolate = receiver->GetIsolate(); | 1671 Isolate* isolate = receiver->GetIsolate(); |
| 1671 for (JSObject* current = receiver; | 1672 for (Handle<JSObject> current = receiver; |
| 1672 true; | 1673 true; |
| 1673 current = JSObject::cast(current->GetPrototype())) { | 1674 current = handle(JSObject::cast(current->GetPrototype()), isolate)) { |
| 1674 if (current->IsAccessCheckNeeded() && | 1675 if (current->IsAccessCheckNeeded() && |
| 1675 !(isolate->*mayAccess)(current, key, access_type)) { | 1676 !(isolate->*mayAccess)(current, key, access_type)) { |
| 1676 return false; | 1677 return false; |
| 1677 } | 1678 } |
| 1678 if (current == holder) break; | 1679 if (current.is_identical_to(holder)) break; |
| 1679 } | 1680 } |
| 1680 return true; | 1681 return true; |
| 1681 } | 1682 } |
| 1682 | 1683 |
| 1683 | 1684 |
| 1684 enum AccessCheckResult { | 1685 enum AccessCheckResult { |
| 1685 ACCESS_FORBIDDEN, | 1686 ACCESS_FORBIDDEN, |
| 1686 ACCESS_ALLOWED, | 1687 ACCESS_ALLOWED, |
| 1687 ACCESS_ABSENT | 1688 ACCESS_ABSENT |
| 1688 }; | 1689 }; |
| 1689 | 1690 |
| 1690 | 1691 |
| 1691 static AccessCheckResult CheckPropertyAccess( | 1692 static AccessCheckResult CheckPropertyAccess(Handle<JSObject> obj, |
| 1692 JSObject* obj, | 1693 Handle<Name> name, |
| 1693 Name* name, | 1694 v8::AccessType access_type) { |
| 1694 v8::AccessType access_type) { | |
| 1695 uint32_t index; | 1695 uint32_t index; |
| 1696 if (name->AsArrayIndex(&index)) { | 1696 if (name->AsArrayIndex(&index)) { |
| 1697 // TODO(1095): we should traverse hidden prototype hierachy as well. | 1697 // TODO(1095): we should traverse hidden prototype hierachy as well. |
| 1698 if (CheckGenericAccess( | 1698 if (CheckGenericAccess( |
| 1699 obj, obj, index, access_type, &Isolate::MayIndexedAccess)) { | 1699 obj, obj, index, access_type, &Isolate::MayIndexedAccessWrapper)) { |
| 1700 return ACCESS_ALLOWED; | 1700 return ACCESS_ALLOWED; |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type); | 1703 obj->GetIsolate()->ReportFailedAccessCheck(*obj, access_type); |
| 1704 return ACCESS_FORBIDDEN; | 1704 return ACCESS_FORBIDDEN; |
| 1705 } | 1705 } |
| 1706 | 1706 |
| 1707 LookupResult lookup(obj->GetIsolate()); | 1707 Isolate* isolate = obj->GetIsolate(); |
| 1708 obj->LocalLookup(name, &lookup, true); | 1708 LookupResult lookup(isolate); |
| 1709 obj->LocalLookup(*name, &lookup, true); |
| 1709 | 1710 |
| 1710 if (!lookup.IsProperty()) return ACCESS_ABSENT; | 1711 if (!lookup.IsProperty()) return ACCESS_ABSENT; |
| 1711 if (CheckGenericAccess<Object*>( | 1712 Handle<JSObject> holder(lookup.holder(), isolate); |
| 1712 obj, lookup.holder(), name, access_type, &Isolate::MayNamedAccess)) { | 1713 if (CheckGenericAccess<Handle<Object> >( |
| 1714 obj, holder, name, access_type, &Isolate::MayNamedAccessWrapper)) { |
| 1713 return ACCESS_ALLOWED; | 1715 return ACCESS_ALLOWED; |
| 1714 } | 1716 } |
| 1715 | 1717 |
| 1716 // Access check callback denied the access, but some properties | 1718 // Access check callback denied the access, but some properties |
| 1717 // can have a special permissions which override callbacks descision | 1719 // can have a special permissions which override callbacks descision |
| 1718 // (currently see v8::AccessControl). | 1720 // (currently see v8::AccessControl). |
| 1719 // API callbacks can have per callback access exceptions. | 1721 // API callbacks can have per callback access exceptions. |
| 1720 switch (lookup.type()) { | 1722 switch (lookup.type()) { |
| 1721 case CALLBACKS: | 1723 case CALLBACKS: |
| 1722 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { | 1724 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { |
| 1723 return ACCESS_ALLOWED; | 1725 return ACCESS_ALLOWED; |
| 1724 } | 1726 } |
| 1725 break; | 1727 break; |
| 1726 case INTERCEPTOR: | 1728 case INTERCEPTOR: |
| 1727 // If the object has an interceptor, try real named properties. | 1729 // If the object has an interceptor, try real named properties. |
| 1728 // Overwrite the result to fetch the correct property later. | 1730 // Overwrite the result to fetch the correct property later. |
| 1729 lookup.holder()->LookupRealNamedProperty(name, &lookup); | 1731 holder->LookupRealNamedProperty(*name, &lookup); |
| 1730 if (lookup.IsProperty() && lookup.IsPropertyCallbacks()) { | 1732 if (lookup.IsProperty() && lookup.IsPropertyCallbacks()) { |
| 1731 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { | 1733 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { |
| 1732 return ACCESS_ALLOWED; | 1734 return ACCESS_ALLOWED; |
| 1733 } | 1735 } |
| 1734 } | 1736 } |
| 1735 break; | 1737 break; |
| 1736 default: | 1738 default: |
| 1737 break; | 1739 break; |
| 1738 } | 1740 } |
| 1739 | 1741 |
| 1740 obj->GetIsolate()->ReportFailedAccessCheck(obj, access_type); | 1742 isolate->ReportFailedAccessCheck(*obj, access_type); |
| 1741 return ACCESS_FORBIDDEN; | 1743 return ACCESS_FORBIDDEN; |
| 1742 } | 1744 } |
| 1743 | 1745 |
| 1744 | 1746 |
| 1745 // Enumerator used as indices into the array returned from GetOwnProperty | 1747 // Enumerator used as indices into the array returned from GetOwnProperty |
| 1746 enum PropertyDescriptorIndices { | 1748 enum PropertyDescriptorIndices { |
| 1747 IS_ACCESSOR_INDEX, | 1749 IS_ACCESSOR_INDEX, |
| 1748 VALUE_INDEX, | 1750 VALUE_INDEX, |
| 1749 GETTER_INDEX, | 1751 GETTER_INDEX, |
| 1750 SETTER_INDEX, | 1752 SETTER_INDEX, |
| 1751 WRITABLE_INDEX, | 1753 WRITABLE_INDEX, |
| 1752 ENUMERABLE_INDEX, | 1754 ENUMERABLE_INDEX, |
| 1753 CONFIGURABLE_INDEX, | 1755 CONFIGURABLE_INDEX, |
| 1754 DESCRIPTOR_SIZE | 1756 DESCRIPTOR_SIZE |
| 1755 }; | 1757 }; |
| 1756 | 1758 |
| 1757 | 1759 |
| 1758 static MaybeObject* GetOwnProperty(Isolate* isolate, | 1760 static Handle<Object> GetOwnProperty(Isolate* isolate, |
| 1759 Handle<JSObject> obj, | 1761 Handle<JSObject> obj, |
| 1760 Handle<Name> name) { | 1762 Handle<Name> name) { |
| 1761 Heap* heap = isolate->heap(); | 1763 Heap* heap = isolate->heap(); |
| 1764 Factory* factory = isolate->factory(); |
| 1762 // Due to some WebKit tests, we want to make sure that we do not log | 1765 // Due to some WebKit tests, we want to make sure that we do not log |
| 1763 // more than one access failure here. | 1766 // more than one access failure here. |
| 1764 AccessCheckResult access_check_result = | 1767 AccessCheckResult access_check_result = |
| 1765 CheckPropertyAccess(*obj, *name, v8::ACCESS_HAS); | 1768 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); |
| 1766 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1769 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1767 switch (access_check_result) { | 1770 switch (access_check_result) { |
| 1768 case ACCESS_FORBIDDEN: return heap->false_value(); | 1771 case ACCESS_FORBIDDEN: return factory->false_value(); |
| 1769 case ACCESS_ALLOWED: break; | 1772 case ACCESS_ALLOWED: break; |
| 1770 case ACCESS_ABSENT: return heap->undefined_value(); | 1773 case ACCESS_ABSENT: return factory->undefined_value(); |
| 1771 } | 1774 } |
| 1772 | 1775 |
| 1773 PropertyAttributes attrs = obj->GetLocalPropertyAttribute(*name); | 1776 PropertyAttributes attrs = obj->GetLocalPropertyAttribute(*name); |
| 1774 if (attrs == ABSENT) { | 1777 if (attrs == ABSENT) { |
| 1775 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1778 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1776 return heap->undefined_value(); | 1779 return factory->undefined_value(); |
| 1777 } | 1780 } |
| 1778 ASSERT(!isolate->has_scheduled_exception()); | 1781 ASSERT(!isolate->has_scheduled_exception()); |
| 1779 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name); | 1782 AccessorPair* raw_accessors = obj->GetLocalPropertyAccessorPair(*name); |
| 1780 Handle<AccessorPair> accessors(raw_accessors, isolate); | 1783 Handle<AccessorPair> accessors(raw_accessors, isolate); |
| 1781 | |
| 1782 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); | 1784 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); |
| 1783 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); | 1785 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); |
| 1784 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); | 1786 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); |
| 1785 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); | 1787 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(raw_accessors != NULL)); |
| 1786 | 1788 |
| 1787 if (raw_accessors == NULL) { | 1789 if (raw_accessors == NULL) { |
| 1788 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); | 1790 elms->set(WRITABLE_INDEX, heap->ToBoolean((attrs & READ_ONLY) == 0)); |
| 1789 // GetProperty does access check. | 1791 // GetProperty does access check. |
| 1790 Handle<Object> value = GetProperty(isolate, obj, name); | 1792 Handle<Object> value = GetProperty(isolate, obj, name); |
| 1791 RETURN_IF_EMPTY_HANDLE(isolate, value); | 1793 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle<Object>::null()); |
| 1792 elms->set(VALUE_INDEX, *value); | 1794 elms->set(VALUE_INDEX, *value); |
| 1793 } else { | 1795 } else { |
| 1794 // Access checks are performed for both accessors separately. | 1796 // Access checks are performed for both accessors separately. |
| 1795 // When they fail, the respective field is not set in the descriptor. | 1797 // When they fail, the respective field is not set in the descriptor. |
| 1796 Object* getter = accessors->GetComponent(ACCESSOR_GETTER); | 1798 Handle<Object> getter(accessors->GetComponent(ACCESSOR_GETTER), isolate); |
| 1797 Object* setter = accessors->GetComponent(ACCESSOR_SETTER); | 1799 Handle<Object> setter(accessors->GetComponent(ACCESSOR_SETTER), isolate); |
| 1798 if (!getter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_GET)) { | 1800 |
| 1801 if (!getter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_GET)) { |
| 1799 ASSERT(!isolate->has_scheduled_exception()); | 1802 ASSERT(!isolate->has_scheduled_exception()); |
| 1800 elms->set(GETTER_INDEX, getter); | 1803 elms->set(GETTER_INDEX, *getter); |
| 1801 } else { | 1804 } else { |
| 1802 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1805 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1803 } | 1806 } |
| 1804 if (!setter->IsMap() && CheckPropertyAccess(*obj, *name, v8::ACCESS_SET)) { | 1807 |
| 1808 if (!setter->IsMap() && CheckPropertyAccess(obj, name, v8::ACCESS_SET)) { |
| 1805 ASSERT(!isolate->has_scheduled_exception()); | 1809 ASSERT(!isolate->has_scheduled_exception()); |
| 1806 elms->set(SETTER_INDEX, setter); | 1810 elms->set(SETTER_INDEX, *setter); |
| 1807 } else { | 1811 } else { |
| 1808 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1812 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); |
| 1809 } | 1813 } |
| 1810 } | 1814 } |
| 1811 | 1815 |
| 1812 return *isolate->factory()->NewJSArrayWithElements(elms); | 1816 return isolate->factory()->NewJSArrayWithElements(elms); |
| 1813 } | 1817 } |
| 1814 | 1818 |
| 1815 | 1819 |
| 1816 // Returns an array with the property description: | 1820 // Returns an array with the property description: |
| 1817 // if args[1] is not a property on args[0] | 1821 // if args[1] is not a property on args[0] |
| 1818 // returns undefined | 1822 // returns undefined |
| 1819 // if args[1] is a data property on args[0] | 1823 // if args[1] is a data property on args[0] |
| 1820 // [false, value, Writeable, Enumerable, Configurable] | 1824 // [false, value, Writeable, Enumerable, Configurable] |
| 1821 // if args[1] is an accessor on args[0] | 1825 // if args[1] is an accessor on args[0] |
| 1822 // [true, GetFunction, SetFunction, Enumerable, Configurable] | 1826 // [true, GetFunction, SetFunction, Enumerable, Configurable] |
| 1823 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { | 1827 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { |
| 1824 HandleScope scope(isolate); | 1828 HandleScope scope(isolate); |
| 1825 ASSERT(args.length() == 2); | 1829 ASSERT(args.length() == 2); |
| 1826 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1830 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 1827 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 1831 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 1828 return GetOwnProperty(isolate, obj, name); | 1832 Handle<Object> result = GetOwnProperty(isolate, obj, name); |
| 1833 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 1834 return *result; |
| 1829 } | 1835 } |
| 1830 | 1836 |
| 1831 | 1837 |
| 1832 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { | 1838 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { |
| 1833 HandleScope scope(isolate); | 1839 HandleScope scope(isolate); |
| 1834 ASSERT(args.length() == 1); | 1840 ASSERT(args.length() == 1); |
| 1835 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1841 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 1836 Handle<Object> result = JSObject::PreventExtensions(obj); | 1842 Handle<Object> result = JSObject::PreventExtensions(obj); |
| 1837 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1843 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 1838 return *result; | 1844 return *result; |
| (...skipping 8736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10575 } else { | 10581 } else { |
| 10576 ASSERT(array->HasFastSmiOrObjectElements() || | 10582 ASSERT(array->HasFastSmiOrObjectElements() || |
| 10577 array->HasFastDoubleElements()); | 10583 array->HasFastDoubleElements()); |
| 10578 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 10584 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
| 10579 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 10585 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
| 10580 } | 10586 } |
| 10581 } | 10587 } |
| 10582 | 10588 |
| 10583 | 10589 |
| 10584 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { | 10590 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { |
| 10585 SealHandleScope shs(isolate); | 10591 HandleScope scope(isolate); |
| 10586 ASSERT(args.length() == 3); | 10592 ASSERT(args.length() == 3); |
| 10587 CONVERT_ARG_CHECKED(JSReceiver, receiver, 0); | 10593 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
| 10588 CONVERT_ARG_CHECKED(Name, name, 1); | 10594 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 10589 CONVERT_SMI_ARG_CHECKED(flag, 2); | 10595 CONVERT_SMI_ARG_CHECKED(flag, 2); |
| 10590 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; | 10596 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; |
| 10591 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); | 10597 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); |
| 10592 return JSObject::cast(receiver)->LookupAccessor(name, component); | 10598 Handle<Object> result = |
| 10599 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component); |
| 10600 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 10601 return *result; |
| 10593 } | 10602 } |
| 10594 | 10603 |
| 10595 | 10604 |
| 10596 #ifdef ENABLE_DEBUGGER_SUPPORT | 10605 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 10597 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { | 10606 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { |
| 10598 SealHandleScope shs(isolate); | 10607 SealHandleScope shs(isolate); |
| 10599 ASSERT(args.length() == 0); | 10608 ASSERT(args.length() == 0); |
| 10600 return Execution::DebugBreakHelper(isolate); | 10609 return Execution::DebugBreakHelper(isolate); |
| 10601 } | 10610 } |
| 10602 | 10611 |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11379 JavaScriptFrame* frame) { | 11388 JavaScriptFrame* frame) { |
| 11380 HandleScope scope(isolate); | 11389 HandleScope scope(isolate); |
| 11381 Handle<SharedFunctionInfo> shared(function->shared()); | 11390 Handle<SharedFunctionInfo> shared(function->shared()); |
| 11382 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11391 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 11383 | 11392 |
| 11384 if (!scope_info->HasContext()) return target; | 11393 if (!scope_info->HasContext()) return target; |
| 11385 | 11394 |
| 11386 // Third fill all context locals. | 11395 // Third fill all context locals. |
| 11387 Handle<Context> frame_context(Context::cast(frame->context())); | 11396 Handle<Context> frame_context(Context::cast(frame->context())); |
| 11388 Handle<Context> function_context(frame_context->declaration_context()); | 11397 Handle<Context> function_context(frame_context->declaration_context()); |
| 11389 if (!scope_info->CopyContextLocalsToScopeObject( | 11398 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
| 11390 isolate, function_context, target)) { | 11399 scope_info, function_context, target)) { |
| 11391 return Handle<JSObject>(); | 11400 return Handle<JSObject>(); |
| 11392 } | 11401 } |
| 11393 | 11402 |
| 11394 // Finally copy any properties from the function context extension. | 11403 // Finally copy any properties from the function context extension. |
| 11395 // These will be variables introduced by eval. | 11404 // These will be variables introduced by eval. |
| 11396 if (function_context->closure() == *function) { | 11405 if (function_context->closure() == *function) { |
| 11397 if (function_context->has_extension() && | 11406 if (function_context->has_extension() && |
| 11398 !function_context->IsNativeContext()) { | 11407 !function_context->IsNativeContext()) { |
| 11399 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 11408 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
| 11400 bool threw = false; | 11409 bool threw = false; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11537 | 11546 |
| 11538 Handle<SharedFunctionInfo> shared(context->closure()->shared()); | 11547 Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
| 11539 Handle<ScopeInfo> scope_info(shared->scope_info()); | 11548 Handle<ScopeInfo> scope_info(shared->scope_info()); |
| 11540 | 11549 |
| 11541 // Allocate and initialize a JSObject with all the content of this function | 11550 // Allocate and initialize a JSObject with all the content of this function |
| 11542 // closure. | 11551 // closure. |
| 11543 Handle<JSObject> closure_scope = | 11552 Handle<JSObject> closure_scope = |
| 11544 isolate->factory()->NewJSObject(isolate->object_function()); | 11553 isolate->factory()->NewJSObject(isolate->object_function()); |
| 11545 | 11554 |
| 11546 // Fill all context locals to the context extension. | 11555 // Fill all context locals to the context extension. |
| 11547 if (!scope_info->CopyContextLocalsToScopeObject( | 11556 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
| 11548 isolate, context, closure_scope)) { | 11557 scope_info, context, closure_scope)) { |
| 11549 return Handle<JSObject>(); | 11558 return Handle<JSObject>(); |
| 11550 } | 11559 } |
| 11551 | 11560 |
| 11552 // Finally copy any properties from the function context extension. This will | 11561 // Finally copy any properties from the function context extension. This will |
| 11553 // be variables introduced by eval. | 11562 // be variables introduced by eval. |
| 11554 if (context->has_extension()) { | 11563 if (context->has_extension()) { |
| 11555 Handle<JSObject> ext(JSObject::cast(context->extension())); | 11564 Handle<JSObject> ext(JSObject::cast(context->extension())); |
| 11556 bool threw = false; | 11565 bool threw = false; |
| 11557 Handle<FixedArray> keys = | 11566 Handle<FixedArray> keys = |
| 11558 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 11567 GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11658 Handle<Context> context) { | 11667 Handle<Context> context) { |
| 11659 ASSERT(context->IsBlockContext()); | 11668 ASSERT(context->IsBlockContext()); |
| 11660 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | 11669 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
| 11661 | 11670 |
| 11662 // Allocate and initialize a JSObject with all the arguments, stack locals | 11671 // Allocate and initialize a JSObject with all the arguments, stack locals |
| 11663 // heap locals and extension properties of the debugged function. | 11672 // heap locals and extension properties of the debugged function. |
| 11664 Handle<JSObject> block_scope = | 11673 Handle<JSObject> block_scope = |
| 11665 isolate->factory()->NewJSObject(isolate->object_function()); | 11674 isolate->factory()->NewJSObject(isolate->object_function()); |
| 11666 | 11675 |
| 11667 // Fill all context locals. | 11676 // Fill all context locals. |
| 11668 if (!scope_info->CopyContextLocalsToScopeObject( | 11677 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
| 11669 isolate, context, block_scope)) { | 11678 scope_info, context, block_scope)) { |
| 11670 return Handle<JSObject>(); | 11679 return Handle<JSObject>(); |
| 11671 } | 11680 } |
| 11672 | 11681 |
| 11673 return block_scope; | 11682 return block_scope; |
| 11674 } | 11683 } |
| 11675 | 11684 |
| 11676 | 11685 |
| 11677 // Create a plain JSObject which materializes the module scope for the specified | 11686 // Create a plain JSObject which materializes the module scope for the specified |
| 11678 // module context. | 11687 // module context. |
| 11679 static Handle<JSObject> MaterializeModuleScope( | 11688 static Handle<JSObject> MaterializeModuleScope( |
| 11680 Isolate* isolate, | 11689 Isolate* isolate, |
| 11681 Handle<Context> context) { | 11690 Handle<Context> context) { |
| 11682 ASSERT(context->IsModuleContext()); | 11691 ASSERT(context->IsModuleContext()); |
| 11683 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | 11692 Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |
| 11684 | 11693 |
| 11685 // Allocate and initialize a JSObject with all the members of the debugged | 11694 // Allocate and initialize a JSObject with all the members of the debugged |
| 11686 // module. | 11695 // module. |
| 11687 Handle<JSObject> module_scope = | 11696 Handle<JSObject> module_scope = |
| 11688 isolate->factory()->NewJSObject(isolate->object_function()); | 11697 isolate->factory()->NewJSObject(isolate->object_function()); |
| 11689 | 11698 |
| 11690 // Fill all context locals. | 11699 // Fill all context locals. |
| 11691 if (!scope_info->CopyContextLocalsToScopeObject( | 11700 if (!ScopeInfo::CopyContextLocalsToScopeObject( |
| 11692 isolate, context, module_scope)) { | 11701 scope_info, context, module_scope)) { |
| 11693 return Handle<JSObject>(); | 11702 return Handle<JSObject>(); |
| 11694 } | 11703 } |
| 11695 | 11704 |
| 11696 return module_scope; | 11705 return module_scope; |
| 11697 } | 11706 } |
| 11698 | 11707 |
| 11699 | 11708 |
| 11700 // Iterate over the actual scopes visible from a stack frame or from a closure. | 11709 // Iterate over the actual scopes visible from a stack frame or from a closure. |
| 11701 // The iteration proceeds from the innermost visible nested scope outwards. | 11710 // The iteration proceeds from the innermost visible nested scope outwards. |
| 11702 // All scopes are backed by an actual context except the local scope, | 11711 // All scopes are backed by an actual context except the local scope, |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12594 // Get the step action and check validity. | 12603 // Get the step action and check validity. |
| 12595 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); | 12604 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); |
| 12596 if (step_action != StepIn && | 12605 if (step_action != StepIn && |
| 12597 step_action != StepNext && | 12606 step_action != StepNext && |
| 12598 step_action != StepOut && | 12607 step_action != StepOut && |
| 12599 step_action != StepInMin && | 12608 step_action != StepInMin && |
| 12600 step_action != StepMin) { | 12609 step_action != StepMin) { |
| 12601 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 12610 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
| 12602 } | 12611 } |
| 12603 | 12612 |
| 12604 if (frame_id != StackFrame::NO_ID && step_action != StepNext && | 12613 if (frame_id != StackFrame::NO_ID && |
| 12605 step_action != StepMin && step_action != StepOut) { | 12614 step_action != StepIn && |
| 12615 step_action != StepNext && |
| 12616 step_action != StepOut && |
| 12617 step_action != StepMin) { |
| 12606 return isolate->ThrowIllegalOperation(); | 12618 return isolate->ThrowIllegalOperation(); |
| 12607 } | 12619 } |
| 12608 | 12620 |
| 12609 // Get the number of steps. | 12621 // Get the number of steps. |
| 12610 int step_count = NumberToInt32(args[2]); | 12622 int step_count = NumberToInt32(args[2]); |
| 12611 if (step_count < 1) { | 12623 if (step_count < 1) { |
| 12612 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 12624 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
| 12613 } | 12625 } |
| 12614 | 12626 |
| 12615 // Clear all current stepping setup. | 12627 // Clear all current stepping setup. |
| (...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14797 // Handle last resort GC and make sure to allow future allocations | 14809 // Handle last resort GC and make sure to allow future allocations |
| 14798 // to grow the heap without causing GCs (if possible). | 14810 // to grow the heap without causing GCs (if possible). |
| 14799 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14811 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14800 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14812 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14801 "Runtime::PerformGC"); | 14813 "Runtime::PerformGC"); |
| 14802 } | 14814 } |
| 14803 } | 14815 } |
| 14804 | 14816 |
| 14805 | 14817 |
| 14806 } } // namespace v8::internal | 14818 } } // namespace v8::internal |
| OLD | NEW |