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/debug/debug.h" | 5 #include "src/debug/debug.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 info.SetSecondPassCallback(&SendAsyncTaskEventCancel); | 1920 info.SetSecondPassCallback(&SendAsyncTaskEventCancel); |
1921 } | 1921 } |
1922 | 1922 |
1923 // In an async function, reuse the existing stack related to the outer | 1923 // In an async function, reuse the existing stack related to the outer |
1924 // Promise. Otherwise, e.g. in a direct call to then, save a new stack. | 1924 // Promise. Otherwise, e.g. in a direct call to then, save a new stack. |
1925 // Promises with multiple reactions with one or more of them being async | 1925 // Promises with multiple reactions with one or more of them being async |
1926 // functions will not get a good stack trace, as async functions require | 1926 // functions will not get a good stack trace, as async functions require |
1927 // different stacks from direct Promise use, but we save and restore a | 1927 // different stacks from direct Promise use, but we save and restore a |
1928 // stack once for all reactions. | 1928 // stack once for all reactions. |
1929 // | 1929 // |
1930 // If this isn't a case of async function, we return false, otherwise | |
1931 // we set the correct id and return true. | |
1932 // | |
1933 // TODO(littledan): Improve this case. | 1930 // TODO(littledan): Improve this case. |
1934 int GetReferenceAsyncTaskId(Isolate* isolate, Handle<JSPromise> promise) { | 1931 int GetReferenceAsyncTaskId(Isolate* isolate, Handle<JSPromise> promise) { |
1935 Handle<Symbol> handled_by_symbol = | 1932 Handle<Symbol> handled_by_symbol = |
1936 isolate->factory()->promise_handled_by_symbol(); | 1933 isolate->factory()->promise_handled_by_symbol(); |
1937 Handle<Object> handled_by_promise = | 1934 Handle<Object> handled_by_promise = |
1938 JSObject::GetDataProperty(promise, handled_by_symbol); | 1935 JSObject::GetDataProperty(promise, handled_by_symbol); |
1939 if (!handled_by_promise->IsJSPromise()) { | 1936 if (!handled_by_promise->IsJSPromise()) { |
1940 return isolate->debug()->NextAsyncTaskId(promise); | 1937 return isolate->debug()->NextAsyncTaskId(promise); |
1941 } | 1938 } |
1942 Handle<JSPromise> handled_by_promise_js = | 1939 Handle<JSPromise> handled_by_promise_js = |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 return v8::Utils::ToLocal(callback_data_); | 2424 return v8::Utils::ToLocal(callback_data_); |
2428 } | 2425 } |
2429 | 2426 |
2430 | 2427 |
2431 v8::Isolate* EventDetailsImpl::GetIsolate() const { | 2428 v8::Isolate* EventDetailsImpl::GetIsolate() const { |
2432 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); | 2429 return reinterpret_cast<v8::Isolate*>(exec_state_->GetIsolate()); |
2433 } | 2430 } |
2434 | 2431 |
2435 } // namespace internal | 2432 } // namespace internal |
2436 } // namespace v8 | 2433 } // namespace v8 |
OLD | NEW |