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/isolate.h" | 5 #include "src/isolate.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <fstream> // NOLINT(readability/streams) | 9 #include <fstream> // NOLINT(readability/streams) |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 Handle<JSPromise> promise); | 1813 Handle<JSPromise> promise); |
1814 | 1814 |
1815 bool PromiseHandlerCheck(Isolate* isolate, Handle<JSReceiver> handler, | 1815 bool PromiseHandlerCheck(Isolate* isolate, Handle<JSReceiver> handler, |
1816 Handle<JSObject> deferred) { | 1816 Handle<JSObject> deferred) { |
1817 // Recurse to the forwarding Promise, if any. This may be due to | 1817 // Recurse to the forwarding Promise, if any. This may be due to |
1818 // - await reaction forwarding to the throwaway Promise, which has | 1818 // - await reaction forwarding to the throwaway Promise, which has |
1819 // a dependency edge to the outer Promise. | 1819 // a dependency edge to the outer Promise. |
1820 // - PromiseIdResolveHandler forwarding to the output of .then | 1820 // - PromiseIdResolveHandler forwarding to the output of .then |
1821 // - Promise.all/Promise.race forwarding to a throwaway Promise, which | 1821 // - Promise.all/Promise.race forwarding to a throwaway Promise, which |
1822 // has a dependency edge to the generated outer Promise. | 1822 // has a dependency edge to the generated outer Promise. |
| 1823 // Otherwise, this is a real reject handler for the Promise. |
1823 Handle<Symbol> key = isolate->factory()->promise_forwarding_handler_symbol(); | 1824 Handle<Symbol> key = isolate->factory()->promise_forwarding_handler_symbol(); |
1824 Handle<Object> forwarding_handler = JSReceiver::GetDataProperty(handler, key); | 1825 Handle<Object> forwarding_handler = JSReceiver::GetDataProperty(handler, key); |
1825 if (forwarding_handler->IsUndefined(isolate)) { | 1826 if (forwarding_handler->IsUndefined(isolate)) { |
1826 return true; | 1827 return true; |
1827 } | 1828 } |
1828 | 1829 |
1829 // TODO(gsathya): Remove this once we get rid of deferred objects. | 1830 // TODO(gsathya): Remove this once we get rid of deferred objects. |
1830 Handle<String> promise_str = isolate->factory()->promise_string(); | 1831 Handle<String> promise_str = isolate->factory()->promise_string(); |
1831 Handle<Object> deferred_promise_obj = | 1832 Handle<Object> deferred_promise_obj = |
1832 JSObject::GetDataProperty(deferred, promise_str); | 1833 JSObject::GetDataProperty(deferred, promise_str); |
1833 if (!deferred_promise_obj->IsJSPromise()) { | 1834 if (!deferred_promise_obj->IsJSPromise()) { |
1834 return true; | 1835 return true; |
1835 } | 1836 } |
1836 | 1837 |
1837 return InternalPromiseHasUserDefinedRejectHandler( | 1838 return InternalPromiseHasUserDefinedRejectHandler( |
1838 isolate, Handle<JSPromise>::cast(deferred_promise_obj)); | 1839 isolate, Handle<JSPromise>::cast(deferred_promise_obj)); |
1839 | |
1840 // Otherwise, this is a real reject handler for the Promise | |
1841 return true; | |
1842 } | 1840 } |
1843 | 1841 |
1844 bool InternalPromiseHasUserDefinedRejectHandler(Isolate* isolate, | 1842 bool InternalPromiseHasUserDefinedRejectHandler(Isolate* isolate, |
1845 Handle<JSPromise> promise) { | 1843 Handle<JSPromise> promise) { |
1846 // If this promise was marked as being handled by a catch block | 1844 // If this promise was marked as being handled by a catch block |
1847 // in an async function, then it has a user-defined reject handler. | 1845 // in an async function, then it has a user-defined reject handler. |
1848 if (promise->handled_hint()) return true; | 1846 if (promise->handled_hint()) return true; |
1849 | 1847 |
1850 // If this Promise is subsumed by another Promise (a Promise resolved | 1848 // If this Promise is subsumed by another Promise (a Promise resolved |
1851 // with another Promise, or an intermediate, hidden, throwaway Promise | 1849 // with another Promise, or an intermediate, hidden, throwaway Promise |
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 // Then check whether this scope intercepts. | 3648 // Then check whether this scope intercepts. |
3651 if ((flag & intercept_mask_)) { | 3649 if ((flag & intercept_mask_)) { |
3652 intercepted_flags_ |= flag; | 3650 intercepted_flags_ |= flag; |
3653 return true; | 3651 return true; |
3654 } | 3652 } |
3655 return false; | 3653 return false; |
3656 } | 3654 } |
3657 | 3655 |
3658 } // namespace internal | 3656 } // namespace internal |
3659 } // namespace v8 | 3657 } // namespace v8 |
OLD | NEW |