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

Unified Diff: src/parsing/preparser.cc

Issue 1895603002: [esnext] prototype runtime implementation for async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@AsyncFunction
Patch Set: Try new strategy (Option C) Created 4 years, 8 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
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index 27c6d23bbee171a2a0c13569fe36f726615acbae..9790ac693a6e1a2a706276290450411508d821ec 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -1197,6 +1197,36 @@ PreParserExpression PreParser::ParseDoExpression(bool* ok) {
}
}
+void PreParserTraits::ParseAsyncArrowSingleExpressionBody(
+ PreParserStatementList body, bool accept_IN,
+ Type::ExpressionClassifier* classifier, int pos, bool* ok) {
+ {
+ Scope* generator_scope = pre_parser_->NewScope(
+ pre_parser_->scope_, FUNCTION_SCOPE, kAsyncFunction);
+
+ // For generators, allocating variables in contexts is currently a win
+ // because it minimizes the work needed to suspend and resume an
+ // activation. The machine code produced for generators (by
+ // full-codegen)
+ // relies on this forced context allocation, but not in an essential
+ // way.
+ generator_scope->ForceContextAllocation();
+
+ PreParser::FunctionState generator_state(
+ &pre_parser_->function_state_, &pre_parser_->scope_, generator_scope,
+ kAsyncFunction, pre_parser_->factory());
+ generator_scope->set_start_position(pos);
+
+ PreParserExpression return_value =
+ pre_parser_->ParseAssignmentExpression(accept_IN, classifier, ok);
+ if (!*ok) return;
+
+ generator_scope->set_end_position(
+ pre_parser_->scanner()->location().end_pos);
+ body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
+ }
+}
+
#undef CHECK_OK
« src/isolate.cc ('K') | « src/parsing/preparser.h ('k') | src/runtime/runtime-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698