Index: src/runtime/runtime-promise.cc |
diff --git a/src/runtime/runtime-promise.cc b/src/runtime/runtime-promise.cc |
index 3335045d98fad839d4c0d794972bdf725612da0d..8e3e285f439aad5aaa3633848be8bf639c2f87e7 100644 |
--- a/src/runtime/runtime-promise.cc |
+++ b/src/runtime/runtime-promise.cc |
@@ -71,83 +71,11 @@ RUNTIME_FUNCTION(Runtime_PromiseRevokeReject) { |
return isolate->heap()->undefined_value(); |
} |
-namespace { |
- |
-// In an async function, reuse the existing stack related to the outer |
-// Promise. Otherwise, e.g. in a direct call to then, save a new stack. |
-// Promises with multiple reactions with one or more of them being async |
-// functions will not get a good stack trace, as async functions require |
-// different stacks from direct Promise use, but we save and restore a |
-// stack once for all reactions. |
-// |
-// If this isn't a case of async function, we return false, otherwise |
-// we set the correct id and return true. |
-// |
-// TODO(littledan): Improve this case. |
-bool GetDebugIdForAsyncFunction(Isolate* isolate, |
- Handle<PromiseReactionJobInfo> info, |
- int* debug_id) { |
- // deferred_promise can be Undefined, FixedArray or userland promise object. |
- if (!info->deferred_promise()->IsJSPromise()) { |
- return false; |
- } |
- |
- Handle<JSPromise> deferred_promise(JSPromise::cast(info->deferred_promise()), |
- isolate); |
- Handle<Symbol> handled_by_symbol = |
- isolate->factory()->promise_handled_by_symbol(); |
- Handle<Object> handled_by_promise = |
- JSObject::GetDataProperty(deferred_promise, handled_by_symbol); |
- |
- if (!handled_by_promise->IsJSPromise()) { |
- return false; |
- } |
- |
- Handle<JSPromise> handled_by_promise_js = |
- Handle<JSPromise>::cast(handled_by_promise); |
- Handle<Symbol> async_stack_id_symbol = |
- isolate->factory()->promise_async_stack_id_symbol(); |
- Handle<Object> id = |
- JSObject::GetDataProperty(handled_by_promise_js, async_stack_id_symbol); |
- |
- // id can be Undefined or Smi. |
- if (!id->IsSmi()) { |
- return false; |
- } |
- |
- *debug_id = Handle<Smi>::cast(id)->value(); |
- return true; |
-} |
- |
-void SetDebugInfo(Isolate* isolate, Handle<JSPromise> promise, |
- Handle<PromiseReactionJobInfo> info, int status) { |
- int id = kDebugPromiseNoID; |
- if (!GetDebugIdForAsyncFunction(isolate, info, &id)) { |
- id = isolate->debug()->NextAsyncTaskId(promise); |
- DCHECK(status != v8::Promise::kPending); |
- } |
- info->set_debug_id(id); |
-} |
- |
-void EnqueuePromiseReactionJob(Isolate* isolate, Handle<JSPromise> promise, |
- Handle<PromiseReactionJobInfo> info, |
- int status) { |
- if (isolate->debug()->is_active()) { |
- SetDebugInfo(isolate, promise, info, status); |
- } |
- |
- isolate->EnqueueMicrotask(info); |
-} |
- |
-} // namespace |
- |
RUNTIME_FUNCTION(Runtime_EnqueuePromiseReactionJob) { |
HandleScope scope(isolate); |
- DCHECK_EQ(3, args.length()); |
- CONVERT_ARG_HANDLE_CHECKED(JSPromise, promise, 0); |
- CONVERT_ARG_HANDLE_CHECKED(PromiseReactionJobInfo, info, 1); |
- CONVERT_SMI_ARG_CHECKED(status, 2); |
- EnqueuePromiseReactionJob(isolate, promise, info, status); |
+ DCHECK_EQ(1, args.length()); |
+ CONVERT_ARG_HANDLE_CHECKED(PromiseReactionJobInfo, info, 0); |
+ isolate->EnqueueMicrotask(info); |
return isolate->heap()->undefined_value(); |
} |