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

Side by Side Diff: src/objects.cc

Issue 2550423002: Propagate exceptions thrown by access check interceptors. (Closed)
Patch Set: propagate Created 4 years 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 | « no previous file | test/cctest/test-access-checks.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 if (it->state() == LookupIterator::ACCESSOR) { 1804 if (it->state() == LookupIterator::ACCESSOR) {
1805 return GetPropertyWithAccessor(it); 1805 return GetPropertyWithAccessor(it);
1806 } 1806 }
1807 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 1807 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
1808 bool done; 1808 bool done;
1809 Handle<Object> result; 1809 Handle<Object> result;
1810 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, 1810 ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
1811 GetPropertyWithInterceptor(it, &done), Object); 1811 GetPropertyWithInterceptor(it, &done), Object);
1812 if (done) return result; 1812 if (done) return result;
1813 } 1813 }
1814
1814 } else { 1815 } else {
1815 MaybeHandle<Object> result; 1816 Handle<Object> result;
1816 bool done; 1817 bool done;
1817 result = GetPropertyWithInterceptorInternal(it, interceptor, &done); 1818 ASSIGN_RETURN_ON_EXCEPTION(
1818 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 1819 isolate, result,
1820 GetPropertyWithInterceptorInternal(it, interceptor, &done), Object);
1819 if (done) return result; 1821 if (done) return result;
1820 } 1822 }
1821 1823
1822 // Cross-Origin [[Get]] of Well-Known Symbols does not throw, and returns 1824 // Cross-Origin [[Get]] of Well-Known Symbols does not throw, and returns
1823 // undefined. 1825 // undefined.
1824 Handle<Name> name = it->GetName(); 1826 Handle<Name> name = it->GetName();
1825 if (name->IsSymbol() && Symbol::cast(*name)->is_well_known_symbol()) { 1827 if (name->IsSymbol() && Symbol::cast(*name)->is_well_known_symbol()) {
1826 return it->factory()->undefined_value(); 1828 return it->factory()->undefined_value();
1827 } 1829 }
1828 1830
1829 isolate->ReportFailedAccessCheck(checked); 1831 isolate->ReportFailedAccessCheck(checked);
1830 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 1832 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
1831 return it->factory()->undefined_value(); 1833 return it->factory()->undefined_value();
1832 } 1834 }
1833 1835
1834 1836
1835 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithFailedAccessCheck( 1837 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithFailedAccessCheck(
1836 LookupIterator* it) { 1838 LookupIterator* it) {
1837 Isolate* isolate = it->isolate(); 1839 Isolate* isolate = it->isolate();
1838 Handle<JSObject> checked = it->GetHolder<JSObject>(); 1840 Handle<JSObject> checked = it->GetHolder<JSObject>();
1839 Handle<InterceptorInfo> interceptor = 1841 Handle<InterceptorInfo> interceptor =
1840 it->GetInterceptorForFailedAccessCheck(); 1842 it->GetInterceptorForFailedAccessCheck();
1841 if (interceptor.is_null()) { 1843 if (interceptor.is_null()) {
1842 while (AllCanRead(it)) { 1844 while (AllCanRead(it)) {
1843 if (it->state() == LookupIterator::ACCESSOR) { 1845 if (it->state() == LookupIterator::ACCESSOR) {
1844 return Just(it->property_attributes()); 1846 return Just(it->property_attributes());
1845 } 1847 }
1846 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state()); 1848 DCHECK_EQ(LookupIterator::INTERCEPTOR, it->state());
1847 auto result = GetPropertyAttributesWithInterceptor(it); 1849 auto result = GetPropertyAttributesWithInterceptor(it);
1848 if (isolate->has_scheduled_exception()) break; 1850 if (isolate->has_scheduled_exception()) break;
dcheng 2016/12/07 06:31:10 Note: I'm not convinced this is correct, but I hav
1849 if (result.IsJust() && result.FromJust() != ABSENT) return result; 1851 if (result.IsJust() && result.FromJust() != ABSENT) return result;
1850 } 1852 }
1851 } else { 1853 } else {
1852 Maybe<PropertyAttributes> result = 1854 Maybe<PropertyAttributes> result =
1853 GetPropertyAttributesWithInterceptorInternal(it, interceptor); 1855 GetPropertyAttributesWithInterceptorInternal(it, interceptor);
1854 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>()); 1856 if (isolate->has_pending_exception()) return Nothing<PropertyAttributes>();
1855 if (result.FromMaybe(ABSENT) != ABSENT) return result; 1857 if (result.FromMaybe(ABSENT) != ABSENT) return result;
1856 } 1858 }
1857 isolate->ReportFailedAccessCheck(checked); 1859 isolate->ReportFailedAccessCheck(checked);
1858 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>()); 1860 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<PropertyAttributes>());
1859 return Just(ABSENT); 1861 return Just(ABSENT);
1860 } 1862 }
1861 1863
1862 1864
1863 // static 1865 // static
1864 bool JSObject::AllCanWrite(LookupIterator* it) { 1866 bool JSObject::AllCanWrite(LookupIterator* it) {
(...skipping 15 matching lines...) Expand all
1880 Handle<JSObject> checked = it->GetHolder<JSObject>(); 1882 Handle<JSObject> checked = it->GetHolder<JSObject>();
1881 Handle<InterceptorInfo> interceptor = 1883 Handle<InterceptorInfo> interceptor =
1882 it->GetInterceptorForFailedAccessCheck(); 1884 it->GetInterceptorForFailedAccessCheck();
1883 if (interceptor.is_null()) { 1885 if (interceptor.is_null()) {
1884 if (AllCanWrite(it)) { 1886 if (AllCanWrite(it)) {
1885 return SetPropertyWithAccessor(it, value, should_throw); 1887 return SetPropertyWithAccessor(it, value, should_throw);
1886 } 1888 }
1887 } else { 1889 } else {
1888 Maybe<bool> result = SetPropertyWithInterceptorInternal( 1890 Maybe<bool> result = SetPropertyWithInterceptorInternal(
1889 it, interceptor, should_throw, value); 1891 it, interceptor, should_throw, value);
1890 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); 1892 if (isolate->has_pending_exception()) return Nothing<bool>();
1891 if (result.IsJust()) return result; 1893 if (result.IsJust()) return result;
1892 } 1894 }
1893
1894 isolate->ReportFailedAccessCheck(checked); 1895 isolate->ReportFailedAccessCheck(checked);
1895 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); 1896 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
1896 return Just(true); 1897 return Just(true);
1897 } 1898 }
1898 1899
1899 1900
1900 void JSObject::SetNormalizedProperty(Handle<JSObject> object, 1901 void JSObject::SetNormalizedProperty(Handle<JSObject> object,
1901 Handle<Name> name, 1902 Handle<Name> name,
1902 Handle<Object> value, 1903 Handle<Object> value,
1903 PropertyDetails details) { 1904 PropertyDetails details) {
(...skipping 18598 matching lines...) Expand 10 before | Expand all | Expand 10 after
20502 // depend on this. 20503 // depend on this.
20503 return DICTIONARY_ELEMENTS; 20504 return DICTIONARY_ELEMENTS;
20504 } 20505 }
20505 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20506 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20506 return kind; 20507 return kind;
20507 } 20508 }
20508 } 20509 }
20509 20510
20510 } // namespace internal 20511 } // namespace internal
20511 } // namespace v8 20512 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-access-checks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698