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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 { 1190 {
1191 BlockState block_state(&scope_, block_scope); 1191 BlockState block_state(&scope_, block_scope);
1192 while (peek() != Token::RBRACE) { 1192 while (peek() != Token::RBRACE) {
1193 ParseStatementListItem(CHECK_OK); 1193 ParseStatementListItem(CHECK_OK);
1194 } 1194 }
1195 Expect(Token::RBRACE, CHECK_OK); 1195 Expect(Token::RBRACE, CHECK_OK);
1196 return PreParserExpression::Default(); 1196 return PreParserExpression::Default();
1197 } 1197 }
1198 } 1198 }
1199 1199
1200 void PreParserTraits::ParseAsyncArrowSingleExpressionBody(
1201 PreParserStatementList body, bool accept_IN,
1202 Type::ExpressionClassifier* classifier, int pos, bool* ok) {
1203 {
1204 Scope* generator_scope = pre_parser_->NewScope(
1205 pre_parser_->scope_, FUNCTION_SCOPE, kAsyncFunction);
1206
1207 // For generators, allocating variables in contexts is currently a win
1208 // because it minimizes the work needed to suspend and resume an
1209 // activation. The machine code produced for generators (by
1210 // full-codegen)
1211 // relies on this forced context allocation, but not in an essential
1212 // way.
1213 generator_scope->ForceContextAllocation();
1214
1215 PreParser::FunctionState generator_state(
1216 &pre_parser_->function_state_, &pre_parser_->scope_, generator_scope,
1217 kAsyncFunction, pre_parser_->factory());
1218 generator_scope->set_start_position(pos);
1219
1220 PreParserExpression return_value =
1221 pre_parser_->ParseAssignmentExpression(accept_IN, classifier, ok);
1222 if (!*ok) return;
1223
1224 generator_scope->set_end_position(
1225 pre_parser_->scanner()->location().end_pos);
1226 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1227 }
1228 }
1229
1200 #undef CHECK_OK 1230 #undef CHECK_OK
1201 1231
1202 1232
1203 } // namespace internal 1233 } // namespace internal
1204 } // namespace v8 1234 } // namespace v8
OLDNEW
« 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