Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "src/builtins/builtins-promise.h" | |
| 6 #include "src/builtins/builtins-utils.h" | |
| 7 #include "src/builtins/builtins.h" | |
| 8 #include "src/code-stub-assembler.h" | |
| 9 | |
| 10 namespace v8 { | |
| 11 namespace internal { | |
| 12 | |
| 13 typedef compiler::Node Node; | |
| 14 typedef CodeStubAssembler::ParameterMode ParameterMode; | |
| 15 typedef compiler::CodeAssemblerState CodeAssemblerState; | |
| 16 | |
| 17 class AsyncAwaitBuiltinsAssembler : public PromiseBuiltinsAssembler { | |
| 18 public: | |
| 19 explicit AsyncAwaitBuiltinsAssembler(CodeAssemblerState* state) | |
| 20 : PromiseBuiltinsAssembler(state) {} | |
| 21 }; | |
| 22 | |
| 23 TF_BUILTIN(AsyncFunctionPromiseCreate, AsyncAwaitBuiltinsAssembler) { | |
| 24 CSA_ASSERT_JS_ARGC_EQ(this, 0); | |
| 25 Node* const context = Parameter(3); | |
| 26 | |
| 27 Node* const parent = UndefinedConstant(); | |
| 28 Node* const promise = AllocateAndInitJSPromise(context, parent); | |
|
gsathya
2017/01/18 18:58:42
You don't need the parent here, default is undefin
jgruber
2017/01/19 08:58:11
Done.
| |
| 29 | |
| 30 Label if_is_debug_active(this, Label::kDeferred); | |
| 31 GotoIf(IsDebugActive(), &if_is_debug_active); | |
| 32 | |
| 33 // Early exit if debug is not active. | |
| 34 Return(promise); | |
| 35 | |
| 36 Bind(&if_is_debug_active); | |
| 37 { | |
| 38 // Push the Promise under construction in an async function on | |
| 39 // the catch prediction stack to handle exceptions thrown before | |
| 40 // the first await. | |
| 41 // Assign ID and create a recurring task to save stack for future | |
| 42 // resumptions from await. | |
| 43 CallRuntime(Runtime::kDebugAsyncFunctionPromiseCreated, context, promise); | |
| 44 Return(promise); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 TF_BUILTIN(AsyncFunctionPromiseRelease, AsyncAwaitBuiltinsAssembler) { | |
| 49 CSA_ASSERT_JS_ARGC_EQ(this, 1); | |
| 50 Node* const promise = Parameter(1); | |
| 51 Node* const context = Parameter(4); | |
| 52 | |
| 53 Label if_is_debug_active(this, Label::kDeferred); | |
| 54 GotoIf(IsDebugActive(), &if_is_debug_active); | |
| 55 | |
| 56 // Early exit if debug is not active. | |
| 57 Return(UndefinedConstant()); | |
| 58 | |
| 59 Bind(&if_is_debug_active); | |
| 60 { | |
| 61 // Pop the Promise under construction in an async function on | |
| 62 // from catch prediction stack. | |
| 63 CallRuntime(Runtime::kDebugPopPromise, context); | |
| 64 Return(promise); | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 } // namespace internal | |
| 69 } // namespace v8 | |
| OLD | NEW |