Chromium Code Reviews| Index: src/builtins/builtins-promise.cc |
| diff --git a/src/builtins/builtins-promise.cc b/src/builtins/builtins-promise.cc |
| index 935da633a511b888780600707fbbfdc4b77c5da2..e1871eef486a2ff63643be46bae755b575728318 100644 |
| --- a/src/builtins/builtins-promise.cc |
| +++ b/src/builtins/builtins-promise.cc |
| @@ -748,8 +748,7 @@ void PromiseBuiltinsAssembler::InternalResolvePromise(Node* context, |
| Bind(&reject); |
| // Don't cause a debug event as this case is forwarding a rejection |
| - CallRuntime(Runtime::kPromiseReject, context, promise, thenable_value, |
| - FalseConstant()); |
| + InternalPromiseReject(context, promise, thenable_value, false); |
| PromiseSetHasHandler(result); |
| Goto(&out); |
| } |
| @@ -836,8 +835,7 @@ void PromiseBuiltinsAssembler::InternalResolvePromise(Node* context, |
| // 9.a Return RejectPromise(promise, then.[[Value]]). |
| Bind(&if_rejectpromise); |
| { |
| - CallRuntime(Runtime::kPromiseReject, context, promise, var_reason.value(), |
| - TrueConstant()); |
| + InternalPromiseReject(context, promise, var_reason.value(), true); |
| Goto(&out); |
| } |
| @@ -943,6 +941,63 @@ void PromiseBuiltinsAssembler::BranchIfAccessCheckFailed( |
| Bind(&has_access); |
| } |
| +void PromiseBuiltinsAssembler::InternalPromiseReject(Node* context, |
|
Igor Sheludko
2017/01/17 11:54:13
I think you can merge this with the InternalPromis
gsathya
2017/01/17 14:51:34
Done.
|
| + Node* promise, Node* value, |
| + bool debug_event) { |
| + Label out(this); |
| + |
| + if (debug_event) { |
| + GotoUnless(IsDebugActive(), &out); |
| + CallRuntime(Runtime::kDebugPromiseReject, context, promise, value); |
| + Goto(&out); |
| + } else { |
| + Goto(&out); |
| + } |
| + |
| + Bind(&out); |
| + InternalPromiseReject(context, promise, value); |
| +} |
| + |
| +void PromiseBuiltinsAssembler::InternalPromiseReject(Node* context, |
| + Node* promise, Node* value, |
| + Node* debug_event) { |
| + Label out(this); |
| + GotoUnless(IsDebugActive(), &out); |
| + GotoUnless(WordEqual(TrueConstant(), debug_event), &out); |
| + CallRuntime(Runtime::kDebugPromiseReject, context, promise, value); |
| + Goto(&out); |
| + |
| + Bind(&out); |
| + InternalPromiseReject(context, promise, value); |
|
Igor Sheludko
2017/01/17 11:54:14
... and call InternalPromiseReject(context, promis
gsathya
2017/01/17 14:51:34
Done.
|
| +} |
| + |
| +// This duplicates a lot of logic from PromiseRejectEvent in |
| +// runtime-promise.cc |
| +void PromiseBuiltinsAssembler::InternalPromiseReject(Node* context, |
| + Node* promise, |
| + Node* value) { |
| + Label fulfill(this), report_unhandledpromise(this), |
| + run_promise_hook(this, Label::kDeferred); |
| + |
| + Branch(IsPromiseHookEnabled(), &run_promise_hook, &report_unhandledpromise); |
| + |
| + Bind(&run_promise_hook); |
| + { |
| + CallRuntime(Runtime::kPromiseHookResolve, context, promise); |
| + Goto(&report_unhandledpromise); |
| + } |
| + |
| + Bind(&report_unhandledpromise); |
| + { |
| + GotoIf(PromiseHasHandler(promise), &fulfill); |
| + CallRuntime(Runtime::kReportPromiseReject, context, promise, value); |
| + Goto(&fulfill); |
| + } |
| + |
| + Bind(&fulfill); |
| + PromiseFulfill(context, promise, value, v8::Promise::kRejected); |
| +} |
| + |
| // ES#sec-promise-reject-functions |
| // Promise Reject Functions |
| TF_BUILTIN(PromiseRejectClosure, PromiseBuiltinsAssembler) { |
| @@ -970,7 +1025,7 @@ TF_BUILTIN(PromiseRejectClosure, PromiseBuiltinsAssembler) { |
| Node* const debug_event = LoadContextElement( |
| context, IntPtrConstant(PromiseUtils::kDebugEventSlot)); |
| - CallRuntime(Runtime::kPromiseReject, context, promise, value, debug_event); |
| + InternalPromiseReject(context, promise, value, debug_event); |
| Return(UndefinedConstant()); |
| Bind(&out); |
| @@ -1207,8 +1262,7 @@ TF_BUILTIN(PromiseHandleReject, PromiseBuiltinsAssembler) { |
| Bind(&if_internalhandler); |
| { |
| - CallRuntime(Runtime::kPromiseReject, context, promise, exception, |
| - FalseConstant()); |
| + InternalPromiseReject(context, promise, exception, false); |
| Return(UndefinedConstant()); |
| } |
| @@ -1504,5 +1558,15 @@ TF_BUILTIN(PromiseReject, PromiseBuiltinsAssembler) { |
| } |
| } |
| +TF_BUILTIN(InternalPromiseReject, PromiseBuiltinsAssembler) { |
| + Node* const promise = Parameter(1); |
| + Node* const reason = Parameter(2); |
| + Node* const debug_event = Parameter(3); |
| + Node* const context = Parameter(6); |
| + |
| + InternalPromiseReject(context, promise, reason, debug_event); |
| + Return(UndefinedConstant()); |
| +} |
| + |
| } // namespace internal |
| } // namespace v8 |