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

Side by Side Diff: src/ast/ast.h

Issue 1895603002: [esnext] prototype runtime implementation for async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@AsyncFunction
Patch Set: Partially fix `throw` completions (resumption works, but no resumption doesn't) 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/bailout-reason.h » ('j') | src/builtins.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 class Yield final : public Expression { 2531 class Yield final : public Expression {
2532 public: 2532 public:
2533 DECLARE_NODE_TYPE(Yield) 2533 DECLARE_NODE_TYPE(Yield)
2534 2534
2535 Expression* generator_object() const { return generator_object_; } 2535 Expression* generator_object() const { return generator_object_; }
2536 Expression* expression() const { return expression_; } 2536 Expression* expression() const { return expression_; }
2537 2537
2538 void set_generator_object(Expression* e) { generator_object_ = e; } 2538 void set_generator_object(Expression* e) { generator_object_ = e; }
2539 void set_expression(Expression* e) { expression_ = e; } 2539 void set_expression(Expression* e) { expression_ = e; }
2540 2540
2541 // AsyncFunction's first yield must suspend execution before starting, to
2542 // prevent 'already executing' error. This avoids complexities of introducing
2543 // an internal generator function.
2544 bool is_async_function_start() const { return is_async_function_start_; }
2545
2541 protected: 2546 protected:
2542 Yield(Zone* zone, Expression* generator_object, Expression* expression, 2547 Yield(Zone* zone, Expression* generator_object, Expression* expression,
2543 int pos) 2548 bool is_async_function_start, int pos)
2544 : Expression(zone, pos), 2549 : Expression(zone, pos),
2545 generator_object_(generator_object), 2550 generator_object_(generator_object),
2546 expression_(expression) {} 2551 expression_(expression),
2552 is_async_function_start_(is_async_function_start) {}
2547 2553
2548 private: 2554 private:
2549 Expression* generator_object_; 2555 Expression* generator_object_;
2550 Expression* expression_; 2556 Expression* expression_;
2557 bool is_async_function_start_;
2551 }; 2558 };
2552 2559
2553
2554 class Throw final : public Expression { 2560 class Throw final : public Expression {
2555 public: 2561 public:
2556 DECLARE_NODE_TYPE(Throw) 2562 DECLARE_NODE_TYPE(Throw)
2557 2563
2558 Expression* exception() const { return exception_; } 2564 Expression* exception() const { return exception_; }
2559 void set_exception(Expression* e) { exception_ = e; } 2565 void set_exception(Expression* e) { exception_ = e; }
2560 2566
2561 protected: 2567 protected:
2562 Throw(Zone* zone, Expression* exception, int pos) 2568 Throw(Zone* zone, Expression* exception, int pos)
2563 : Expression(zone, pos), exception_(exception) {} 2569 : Expression(zone, pos), exception_(exception) {}
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
3395 assign->binary_operation_ = 3401 assign->binary_operation_ =
3396 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); 3402 NewBinaryOperation(assign->binary_op(), target, value, pos + 1);
3397 } 3403 }
3398 return assign; 3404 return assign;
3399 } 3405 }
3400 3406
3401 Yield* NewYield(Expression *generator_object, 3407 Yield* NewYield(Expression *generator_object,
3402 Expression* expression, 3408 Expression* expression,
3403 int pos) { 3409 int pos) {
3404 if (!expression) expression = NewUndefinedLiteral(pos); 3410 if (!expression) expression = NewUndefinedLiteral(pos);
3405 return new (local_zone_) 3411 const bool is_async_function_start = false;
3406 Yield(local_zone_, generator_object, expression, pos); 3412 return new (local_zone_) Yield(local_zone_, generator_object, expression,
3413 is_async_function_start, pos);
3414 }
3415
3416 Yield* NewAsyncFunctionStart(Expression* generator_object,
3417 Expression* expression, int pos) {
3418 DCHECK_NOT_NULL(expression);
3419 // Starting an AsyncFunction emits a yield which suspends before evaluating
3420 // operand.
3421 const bool is_async_function_start = true;
3422 return new (local_zone_) Yield(local_zone_, generator_object, expression,
3423 is_async_function_start, pos);
3407 } 3424 }
3408 3425
3409 Throw* NewThrow(Expression* exception, int pos) { 3426 Throw* NewThrow(Expression* exception, int pos) {
3410 return new (local_zone_) Throw(local_zone_, exception, pos); 3427 return new (local_zone_) Throw(local_zone_, exception, pos);
3411 } 3428 }
3412 3429
3413 FunctionLiteral* NewFunctionLiteral( 3430 FunctionLiteral* NewFunctionLiteral(
3414 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body, 3431 const AstRawString* name, Scope* scope, ZoneList<Statement*>* body,
3415 int materialized_literal_count, int expected_property_count, 3432 int materialized_literal_count, int expected_property_count,
3416 int parameter_count, 3433 int parameter_count,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3554 : NULL; \ 3571 : NULL; \
3555 } 3572 }
3556 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3573 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3557 #undef DECLARE_NODE_FUNCTIONS 3574 #undef DECLARE_NODE_FUNCTIONS
3558 3575
3559 3576
3560 } // namespace internal 3577 } // namespace internal
3561 } // namespace v8 3578 } // namespace v8
3562 3579
3563 #endif // V8_AST_AST_H_ 3580 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/bailout-reason.h » ('j') | src/builtins.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698