Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 94ea80a18b6df5e3c000c581da9adc6a251f43b8..f87416e4d3709b4932d25c1d809f62daa520d826 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -2170,6 +2170,26 @@ void BytecodeGenerator::BuildVariableLoadForAccumulatorValue( |
} |
void BytecodeGenerator::BuildReturn() { |
+ if (IsAsyncFunction(info()->literal()->kind())) { |
+ RegisterAllocationScope register_scope(this); |
+ RegisterList args = register_allocator()->NewRegisterList(3); |
+ Register receiver = args[0]; |
+ Register promise = args[1]; |
+ Register return_value = args[2]; |
+ builder()->StoreAccumulatorInRegister(return_value); |
+ |
+ Variable* var_promise = scope()->promise_var(); |
+ DCHECK_NOT_NULL(var_promise); |
+ BuildVariableLoad(var_promise, FeedbackVectorSlot::Invalid(), |
+ HoleCheckMode::kElided); |
+ builder() |
+ ->StoreAccumulatorInRegister(promise) |
+ .LoadUndefined() |
+ .StoreAccumulatorInRegister(receiver) |
+ .CallJSRuntime(Context::PROMISE_RESOLVE_INDEX, args) |
+ .LoadAccumulatorWithRegister(promise); |
+ } |
+ |
if (FLAG_trace) { |
RegisterAllocationScope register_scope(this); |
Register result = register_allocator()->NewRegister(); |