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

Side by Side Diff: src/parsing/parser.cc

Issue 1806293002: [generators] Add some explanation on forcing context allocation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/full-codegen/x87/full-codegen-x87.cc ('k') | no next file » | no next file with comments »
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 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 4085 matching lines...) Expand 10 before | Expand all | Expand 10 after
4096 { 4096 {
4097 AstNodeFactory function_factory(ast_value_factory()); 4097 AstNodeFactory function_factory(ast_value_factory());
4098 FunctionState function_state(&function_state_, &scope_, scope, kind, 4098 FunctionState function_state(&function_state_, &scope_, scope, kind,
4099 &function_factory); 4099 &function_factory);
4100 scope_->SetScopeName(function_name); 4100 scope_->SetScopeName(function_name);
4101 ExpressionClassifier formals_classifier(this, &duplicate_finder); 4101 ExpressionClassifier formals_classifier(this, &duplicate_finder);
4102 4102
4103 if (is_generator) { 4103 if (is_generator) {
4104 // For generators, allocating variables in contexts is currently a win 4104 // For generators, allocating variables in contexts is currently a win
4105 // because it minimizes the work needed to suspend and resume an 4105 // because it minimizes the work needed to suspend and resume an
4106 // activation. 4106 // activation. The machine code produced for generators (by full-codegen)
4107 // relies on this forced context allocation, but not in an essential way.
Michael Starzinger 2016/03/17 12:48:00 nit: The "[...], but not in an essential way" part
4107 scope_->ForceContextAllocation(); 4108 scope_->ForceContextAllocation();
4108 4109
4109 // Calling a generator returns a generator object. That object is stored 4110 // Calling a generator returns a generator object. That object is stored
4110 // in a temporary variable, a definition that is used by "yield" 4111 // in a temporary variable, a definition that is used by "yield"
4111 // expressions. This also marks the FunctionState as a generator. 4112 // expressions. This also marks the FunctionState as a generator.
4112 Variable* temp = scope_->NewTemporary( 4113 Variable* temp = scope_->NewTemporary(
4113 ast_value_factory()->dot_generator_object_string()); 4114 ast_value_factory()->dot_generator_object_string());
4114 function_state.set_generator_object_variable(temp); 4115 function_state.set_generator_object_variable(temp);
4115 } 4116 }
4116 4117
(...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after
6782 try_block, target); 6783 try_block, target);
6783 final_loop = target; 6784 final_loop = target;
6784 } 6785 }
6785 6786
6786 return final_loop; 6787 return final_loop;
6787 } 6788 }
6788 6789
6789 6790
6790 } // namespace internal 6791 } // namespace internal
6791 } // namespace v8 6792 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698