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

Unified Diff: src/runtime/runtime-promise.cc

Issue 2487053002: [promises] Remove one runtime call to create_resolving_functions (Closed)
Patch Set: add dcheck Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-promise.cc
diff --git a/src/runtime/runtime-promise.cc b/src/runtime/runtime-promise.cc
index a6d3ff93d403c2b6c5a609c9bbbc160bf124e442..226993a50ec7d92c3fe753d21531f566476ae148 100644
--- a/src/runtime/runtime-promise.cc
+++ b/src/runtime/runtime-promise.cc
@@ -6,6 +6,7 @@
#include "src/debug/debug.h"
#include "src/elements.h"
+#include "src/promise-utils.h"
namespace v8 {
namespace internal {
@@ -139,13 +140,19 @@ RUNTIME_FUNCTION(Runtime_EnqueuePromiseReactionJob) {
RUNTIME_FUNCTION(Runtime_EnqueuePromiseResolveThenableJob) {
HandleScope scope(isolate);
- DCHECK(args.length() == 4);
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, resolution, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSReceiver, then, 1);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, resolve, 2);
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, reject, 3);
- Handle<Object> debug_id;
- Handle<Object> debug_name;
+ DCHECK(args.length() == 3);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, promise, 0);
+ CONVERT_ARG_HANDLE_CHECKED(JSReceiver, resolution, 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSReceiver, then, 2);
+
+ // TODO(gsathya): Add fast path for native promises with unmodified
+ // PromiseThen (which don't need these resolving functions, but
+ // instead can just call resolve/reject directly).
+ Handle<JSFunction> resolve, reject;
+ PromiseUtils::CreateResolvingFunctions(
+ isolate, promise, isolate->factory()->false_value(), &resolve, &reject);
+
+ Handle<Object> debug_id, debug_name;
if (isolate->debug()->is_active()) {
debug_id =
handle(Smi::FromInt(isolate->GetNextDebugMicrotaskId()), isolate);
@@ -157,10 +164,13 @@ RUNTIME_FUNCTION(Runtime_EnqueuePromiseResolveThenableJob) {
debug_id = isolate->factory()->undefined_value();
debug_name = isolate->factory()->undefined_value();
}
+
Handle<PromiseResolveThenableJobInfo> info =
isolate->factory()->NewPromiseResolveThenableJobInfo(
- resolution, then, resolve, reject, debug_id, debug_name);
+ resolution, then, resolve, reject, debug_id, debug_name,
+ isolate->native_context());
isolate->EnqueueMicrotask(info);
+
return isolate->heap()->undefined_value();
}
« no previous file with comments | « src/runtime/runtime.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698