| 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 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 HandleScope scope(isolate); | 1614 HandleScope scope(isolate); |
| 1615 ASSERT(args.length() == 1); | 1615 ASSERT(args.length() == 1); |
| 1616 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 1616 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
| 1617 // We don't expect access checks to be needed on JSProxy objects. | 1617 // We don't expect access checks to be needed on JSProxy objects. |
| 1618 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 1618 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
| 1619 do { | 1619 do { |
| 1620 if (obj->IsAccessCheckNeeded() && | 1620 if (obj->IsAccessCheckNeeded() && |
| 1621 !isolate->MayNamedAccessWrapper(Handle<JSObject>::cast(obj), | 1621 !isolate->MayNamedAccessWrapper(Handle<JSObject>::cast(obj), |
| 1622 isolate->factory()->proto_string(), | 1622 isolate->factory()->proto_string(), |
| 1623 v8::ACCESS_GET)) { | 1623 v8::ACCESS_GET)) { |
| 1624 isolate->ReportFailedAccessCheck(JSObject::cast(*obj), v8::ACCESS_GET); | 1624 isolate->ReportFailedAccessCheckWrapper(Handle<JSObject>::cast(obj), |
| 1625 v8::ACCESS_GET); |
| 1625 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1626 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 1626 return isolate->heap()->undefined_value(); | 1627 return isolate->heap()->undefined_value(); |
| 1627 } | 1628 } |
| 1628 obj = handle(obj->GetPrototype(isolate), isolate); | 1629 obj = handle(obj->GetPrototype(isolate), isolate); |
| 1629 } while (obj->IsJSObject() && | 1630 } while (obj->IsJSObject() && |
| 1630 JSObject::cast(*obj)->map()->is_hidden_prototype()); | 1631 JSObject::cast(*obj)->map()->is_hidden_prototype()); |
| 1631 return *obj; | 1632 return *obj; |
| 1632 } | 1633 } |
| 1633 | 1634 |
| 1634 | 1635 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 Handle<Name> name, | 1741 Handle<Name> name, |
| 1741 v8::AccessType access_type) { | 1742 v8::AccessType access_type) { |
| 1742 uint32_t index; | 1743 uint32_t index; |
| 1743 if (name->AsArrayIndex(&index)) { | 1744 if (name->AsArrayIndex(&index)) { |
| 1744 // TODO(1095): we should traverse hidden prototype hierachy as well. | 1745 // TODO(1095): we should traverse hidden prototype hierachy as well. |
| 1745 if (CheckGenericAccess( | 1746 if (CheckGenericAccess( |
| 1746 obj, obj, index, access_type, &Isolate::MayIndexedAccessWrapper)) { | 1747 obj, obj, index, access_type, &Isolate::MayIndexedAccessWrapper)) { |
| 1747 return ACCESS_ALLOWED; | 1748 return ACCESS_ALLOWED; |
| 1748 } | 1749 } |
| 1749 | 1750 |
| 1750 obj->GetIsolate()->ReportFailedAccessCheck(*obj, access_type); | 1751 obj->GetIsolate()->ReportFailedAccessCheckWrapper(obj, access_type); |
| 1751 return ACCESS_FORBIDDEN; | 1752 return ACCESS_FORBIDDEN; |
| 1752 } | 1753 } |
| 1753 | 1754 |
| 1754 Isolate* isolate = obj->GetIsolate(); | 1755 Isolate* isolate = obj->GetIsolate(); |
| 1755 LookupResult lookup(isolate); | 1756 LookupResult lookup(isolate); |
| 1756 obj->LocalLookup(*name, &lookup, true); | 1757 obj->LocalLookup(*name, &lookup, true); |
| 1757 | 1758 |
| 1758 if (!lookup.IsProperty()) return ACCESS_ABSENT; | 1759 if (!lookup.IsProperty()) return ACCESS_ABSENT; |
| 1759 Handle<JSObject> holder(lookup.holder(), isolate); | 1760 Handle<JSObject> holder(lookup.holder(), isolate); |
| 1760 if (CheckGenericAccess<Handle<Object> >( | 1761 if (CheckGenericAccess<Handle<Object> >( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1779 if (lookup.IsProperty() && lookup.IsPropertyCallbacks()) { | 1780 if (lookup.IsProperty() && lookup.IsPropertyCallbacks()) { |
| 1780 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { | 1781 if (CheckAccessException(lookup.GetCallbackObject(), access_type)) { |
| 1781 return ACCESS_ALLOWED; | 1782 return ACCESS_ALLOWED; |
| 1782 } | 1783 } |
| 1783 } | 1784 } |
| 1784 break; | 1785 break; |
| 1785 default: | 1786 default: |
| 1786 break; | 1787 break; |
| 1787 } | 1788 } |
| 1788 | 1789 |
| 1789 isolate->ReportFailedAccessCheck(*obj, access_type); | 1790 isolate->ReportFailedAccessCheckWrapper(obj, access_type); |
| 1790 return ACCESS_FORBIDDEN; | 1791 return ACCESS_FORBIDDEN; |
| 1791 } | 1792 } |
| 1792 | 1793 |
| 1793 | 1794 |
| 1794 // Enumerator used as indices into the array returned from GetOwnProperty | 1795 // Enumerator used as indices into the array returned from GetOwnProperty |
| 1795 enum PropertyDescriptorIndices { | 1796 enum PropertyDescriptorIndices { |
| 1796 IS_ACCESSOR_INDEX, | 1797 IS_ACCESSOR_INDEX, |
| 1797 VALUE_INDEX, | 1798 VALUE_INDEX, |
| 1798 GETTER_INDEX, | 1799 GETTER_INDEX, |
| 1799 SETTER_INDEX, | 1800 SETTER_INDEX, |
| (...skipping 3930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5730 } | 5731 } |
| 5731 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5732 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
| 5732 CONVERT_SMI_ARG_CHECKED(filter_value, 1); | 5733 CONVERT_SMI_ARG_CHECKED(filter_value, 1); |
| 5733 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); | 5734 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); |
| 5734 | 5735 |
| 5735 // Skip the global proxy as it has no properties and always delegates to the | 5736 // Skip the global proxy as it has no properties and always delegates to the |
| 5736 // real global object. | 5737 // real global object. |
| 5737 if (obj->IsJSGlobalProxy()) { | 5738 if (obj->IsJSGlobalProxy()) { |
| 5738 // Only collect names if access is permitted. | 5739 // Only collect names if access is permitted. |
| 5739 if (obj->IsAccessCheckNeeded() && | 5740 if (obj->IsAccessCheckNeeded() && |
| 5740 !isolate->MayNamedAccess(*obj, | 5741 !isolate->MayNamedAccessWrapper(obj, |
| 5741 isolate->heap()->undefined_value(), | 5742 isolate->factory()->undefined_value(), |
| 5742 v8::ACCESS_KEYS)) { | 5743 v8::ACCESS_KEYS)) { |
| 5743 isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS); | 5744 isolate->ReportFailedAccessCheckWrapper(obj, v8::ACCESS_KEYS); |
| 5744 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 5745 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 5745 return *isolate->factory()->NewJSArray(0); | 5746 return *isolate->factory()->NewJSArray(0); |
| 5746 } | 5747 } |
| 5747 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); | 5748 obj = Handle<JSObject>(JSObject::cast(obj->GetPrototype())); |
| 5748 } | 5749 } |
| 5749 | 5750 |
| 5750 // Find the number of objects making up this. | 5751 // Find the number of objects making up this. |
| 5751 int length = LocalPrototypeChainLength(*obj); | 5752 int length = LocalPrototypeChainLength(*obj); |
| 5752 | 5753 |
| 5753 // Find the number of local properties for each of the objects. | 5754 // Find the number of local properties for each of the objects. |
| 5754 ScopedVector<int> local_property_count(length); | 5755 ScopedVector<int> local_property_count(length); |
| 5755 int total_property_count = 0; | 5756 int total_property_count = 0; |
| 5756 Handle<JSObject> jsproto = obj; | 5757 Handle<JSObject> jsproto = obj; |
| 5757 for (int i = 0; i < length; i++) { | 5758 for (int i = 0; i < length; i++) { |
| 5758 // Only collect names if access is permitted. | 5759 // Only collect names if access is permitted. |
| 5759 if (jsproto->IsAccessCheckNeeded() && | 5760 if (jsproto->IsAccessCheckNeeded() && |
| 5760 !isolate->MayNamedAccess(*jsproto, | 5761 !isolate->MayNamedAccessWrapper(jsproto, |
| 5761 isolate->heap()->undefined_value(), | 5762 isolate->factory()->undefined_value(), |
| 5762 v8::ACCESS_KEYS)) { | 5763 v8::ACCESS_KEYS)) { |
| 5763 isolate->ReportFailedAccessCheck(*jsproto, v8::ACCESS_KEYS); | 5764 isolate->ReportFailedAccessCheckWrapper(jsproto, v8::ACCESS_KEYS); |
| 5764 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 5765 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 5765 return *isolate->factory()->NewJSArray(0); | 5766 return *isolate->factory()->NewJSArray(0); |
| 5766 } | 5767 } |
| 5767 int n; | 5768 int n; |
| 5768 n = jsproto->NumberOfLocalProperties(filter); | 5769 n = jsproto->NumberOfLocalProperties(filter); |
| 5769 local_property_count[i] = n; | 5770 local_property_count[i] = n; |
| 5770 total_property_count += n; | 5771 total_property_count += n; |
| 5771 if (i < length - 1) { | 5772 if (i < length - 1) { |
| 5772 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 5773 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
| 5773 } | 5774 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5901 | 5902 |
| 5902 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { | 5903 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { |
| 5903 HandleScope scope(isolate); | 5904 HandleScope scope(isolate); |
| 5904 ASSERT_EQ(args.length(), 1); | 5905 ASSERT_EQ(args.length(), 1); |
| 5905 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); | 5906 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); |
| 5906 Handle<JSObject> object(raw_object); | 5907 Handle<JSObject> object(raw_object); |
| 5907 | 5908 |
| 5908 if (object->IsJSGlobalProxy()) { | 5909 if (object->IsJSGlobalProxy()) { |
| 5909 // Do access checks before going to the global object. | 5910 // Do access checks before going to the global object. |
| 5910 if (object->IsAccessCheckNeeded() && | 5911 if (object->IsAccessCheckNeeded() && |
| 5911 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), | 5912 !isolate->MayNamedAccessWrapper(object, |
| 5912 v8::ACCESS_KEYS)) { | 5913 isolate->factory()->undefined_value(), |
| 5913 isolate->ReportFailedAccessCheck(*object, v8::ACCESS_KEYS); | 5914 v8::ACCESS_KEYS)) { |
| 5915 isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_KEYS); |
| 5914 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 5916 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 5915 return *isolate->factory()->NewJSArray(0); | 5917 return *isolate->factory()->NewJSArray(0); |
| 5916 } | 5918 } |
| 5917 | 5919 |
| 5918 Handle<Object> proto(object->GetPrototype(), isolate); | 5920 Handle<Object> proto(object->GetPrototype(), isolate); |
| 5919 // If proxy is detached we simply return an empty array. | 5921 // If proxy is detached we simply return an empty array. |
| 5920 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); | 5922 if (proto->IsNull()) return *isolate->factory()->NewJSArray(0); |
| 5921 object = Handle<JSObject>::cast(proto); | 5923 object = Handle<JSObject>::cast(proto); |
| 5922 } | 5924 } |
| 5923 | 5925 |
| (...skipping 8808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14732 | 14734 |
| 14733 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessAllowedForObserver) { | 14735 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessAllowedForObserver) { |
| 14734 HandleScope scope(isolate); | 14736 HandleScope scope(isolate); |
| 14735 ASSERT(args.length() == 3); | 14737 ASSERT(args.length() == 3); |
| 14736 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); | 14738 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); |
| 14737 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); | 14739 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); |
| 14738 ASSERT(object->map()->is_access_check_needed()); | 14740 ASSERT(object->map()->is_access_check_needed()); |
| 14739 Handle<Object> key = args.at<Object>(2); | 14741 Handle<Object> key = args.at<Object>(2); |
| 14740 SaveContext save(isolate); | 14742 SaveContext save(isolate); |
| 14741 isolate->set_context(observer->context()); | 14743 isolate->set_context(observer->context()); |
| 14742 if (!isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), | 14744 if (!isolate->MayNamedAccessWrapper(object, |
| 14743 v8::ACCESS_KEYS)) { | 14745 isolate->factory()->undefined_value(), |
| 14746 v8::ACCESS_KEYS)) { |
| 14744 return isolate->heap()->false_value(); | 14747 return isolate->heap()->false_value(); |
| 14745 } | 14748 } |
| 14746 bool access_allowed = false; | 14749 bool access_allowed = false; |
| 14747 uint32_t index = 0; | 14750 uint32_t index = 0; |
| 14748 if (key->ToArrayIndex(&index) || | 14751 if (key->ToArrayIndex(&index) || |
| 14749 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { | 14752 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { |
| 14750 access_allowed = | 14753 access_allowed = |
| 14751 isolate->MayIndexedAccess(*object, index, v8::ACCESS_GET) && | 14754 isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_GET) && |
| 14752 isolate->MayIndexedAccess(*object, index, v8::ACCESS_HAS); | 14755 isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_HAS); |
| 14753 } else { | 14756 } else { |
| 14754 access_allowed = isolate->MayNamedAccess(*object, *key, v8::ACCESS_GET) && | 14757 access_allowed = |
| 14755 isolate->MayNamedAccess(*object, *key, v8::ACCESS_HAS); | 14758 isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_GET) && |
| 14759 isolate->MayNamedAccessWrapper(object, key, v8::ACCESS_HAS); |
| 14756 } | 14760 } |
| 14757 return isolate->heap()->ToBoolean(access_allowed); | 14761 return isolate->heap()->ToBoolean(access_allowed); |
| 14758 } | 14762 } |
| 14759 | 14763 |
| 14760 | 14764 |
| 14761 static MaybeObject* ArrayConstructorCommon(Isolate* isolate, | 14765 static MaybeObject* ArrayConstructorCommon(Isolate* isolate, |
| 14762 Handle<JSFunction> constructor, | 14766 Handle<JSFunction> constructor, |
| 14763 Handle<AllocationSite> site, | 14767 Handle<AllocationSite> site, |
| 14764 Arguments* caller_args) { | 14768 Arguments* caller_args) { |
| 14765 bool holey = false; | 14769 bool holey = false; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14965 // Handle last resort GC and make sure to allow future allocations | 14969 // Handle last resort GC and make sure to allow future allocations |
| 14966 // to grow the heap without causing GCs (if possible). | 14970 // to grow the heap without causing GCs (if possible). |
| 14967 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14971 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14968 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14972 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14969 "Runtime::PerformGC"); | 14973 "Runtime::PerformGC"); |
| 14970 } | 14974 } |
| 14971 } | 14975 } |
| 14972 | 14976 |
| 14973 | 14977 |
| 14974 } } // namespace v8::internal | 14978 } } // namespace v8::internal |
| OLD | NEW |