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

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

Issue 2695593002: [promises] cleanup default promise handlers (Closed)
Patch Set: remove unused var Created 3 years, 10 months 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 | « no previous file | src/contexts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-promise.cc
diff --git a/src/builtins/builtins-promise.cc b/src/builtins/builtins-promise.cc
index 23bd4ed221e73d218671c12a0498fdad5eb17243..2805d611720e206cff4f031875cc2d6331672730 100644
--- a/src/builtins/builtins-promise.cc
+++ b/src/builtins/builtins-promise.cc
@@ -420,7 +420,6 @@ Node* PromiseBuiltinsAssembler::InternalPerformPromiseThen(
Node* context, Node* promise, Node* on_resolve, Node* on_reject,
Node* deferred_promise, Node* deferred_on_resolve,
Node* deferred_on_reject) {
- Node* const native_context = LoadNativeContext(context);
Variable var_on_resolve(this, MachineRepresentation::kTagged),
var_on_reject(this, MachineRepresentation::kTagged);
@@ -432,14 +431,17 @@ Node* PromiseBuiltinsAssembler::InternalPerformPromiseThen(
append_callbacks(this);
GotoIf(TaggedIsSmi(on_resolve), &if_onresolvenotcallable);
+ Isolate* isolate = this->isolate();
Node* const on_resolve_map = LoadMap(on_resolve);
Branch(IsCallableMap(on_resolve_map), &onrejectcheck,
&if_onresolvenotcallable);
Bind(&if_onresolvenotcallable);
{
- var_on_resolve.Bind(LoadContextElement(
- native_context, Context::PROMISE_ID_RESOLVE_HANDLER_INDEX));
+ Isolate* isolate = this->isolate();
+ Node* const default_resolve_handler_symbol = HeapConstant(
+ isolate->factory()->promise_default_resolve_handler_symbol());
+ var_on_resolve.Bind(default_resolve_handler_symbol);
Goto(&onrejectcheck);
}
@@ -454,8 +456,9 @@ Node* PromiseBuiltinsAssembler::InternalPerformPromiseThen(
Bind(&if_onrejectnotcallable);
{
- var_on_reject.Bind(LoadContextElement(
- native_context, Context::PROMISE_ID_REJECT_HANDLER_INDEX));
+ Node* const default_reject_handler_symbol = HeapConstant(
+ isolate->factory()->promise_default_reject_handler_symbol());
+ var_on_reject.Bind(default_reject_handler_symbol);
Goto(&append_callbacks);
}
}
@@ -1265,25 +1268,55 @@ TF_BUILTIN(PromiseHandle, PromiseBuiltinsAssembler) {
Bind(&run_handler);
{
- Callable call_callable = CodeFactory::Call(isolate);
- Node* const result =
- CallJS(call_callable, context, handler, UndefinedConstant(), value);
+ Label if_defaulthandler(this), if_callablehandler(this),
+ if_internalhandler(this), if_customhandler(this, Label::kDeferred);
+ Variable var_result(this, MachineRepresentation::kTagged);
- GotoIfException(result, &if_rejectpromise, &var_reason);
+ Branch(IsSymbol(handler), &if_defaulthandler, &if_callablehandler);
- Label if_internalhandler(this), if_customhandler(this, Label::kDeferred);
- Branch(IsUndefined(deferred_on_resolve), &if_internalhandler,
- &if_customhandler);
+ Bind(&if_defaulthandler);
+ {
+ Label if_resolve(this), if_reject(this);
+ Node* const default_resolve_handler_symbol = HeapConstant(
+ isolate->factory()->promise_default_resolve_handler_symbol());
+ Branch(WordEqual(default_resolve_handler_symbol, handler), &if_resolve,
+ &if_reject);
+
+ Bind(&if_resolve);
+ {
+ var_result.Bind(value);
+ Branch(IsUndefined(deferred_on_resolve), &if_internalhandler,
+ &if_customhandler);
+ }
+
+ Bind(&if_reject);
+ {
+ var_reason.Bind(value);
+ Goto(&if_rejectpromise);
+ }
+ }
+
+ Bind(&if_callablehandler);
+ {
+ Callable call_callable = CodeFactory::Call(isolate);
+ Node* const result =
+ CallJS(call_callable, context, handler, UndefinedConstant(), value);
+ var_result.Bind(result);
+ GotoIfException(result, &if_rejectpromise, &var_reason);
+ Branch(IsUndefined(deferred_on_resolve), &if_internalhandler,
+ &if_customhandler);
+ }
Bind(&if_internalhandler);
- InternalResolvePromise(context, deferred_promise, result);
+ InternalResolvePromise(context, deferred_promise, var_result.value());
Goto(&promisehook_after);
Bind(&if_customhandler);
{
+ Callable call_callable = CodeFactory::Call(isolate);
Node* const maybe_exception =
CallJS(call_callable, context, deferred_on_resolve,
- UndefinedConstant(), result);
+ UndefinedConstant(), var_result.value());
GotoIfException(maybe_exception, &if_rejectpromise, &var_reason);
Goto(&promisehook_after);
}
« no previous file with comments | « no previous file | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698