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

Side by Side Diff: src/parsing/parser-base.h

Issue 1693523002: [es6] More efficient way of marking AST call expressions in tail positions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed MarkTail() from Statement Created 4 years, 10 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/parsing/parser.cc ('k') | test/mjsunit/es6/tail-call.js » ('j') | 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 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 const List<DestructuringAssignment>& destructuring_assignments_to_rewrite() 240 const List<DestructuringAssignment>& destructuring_assignments_to_rewrite()
241 const { 241 const {
242 return destructuring_assignments_to_rewrite_; 242 return destructuring_assignments_to_rewrite_;
243 } 243 }
244 244
245 void AddDestructuringAssignment(DestructuringAssignment pair) { 245 void AddDestructuringAssignment(DestructuringAssignment pair) {
246 destructuring_assignments_to_rewrite_.Add(pair); 246 destructuring_assignments_to_rewrite_.Add(pair);
247 } 247 }
248 248
249 List<ExpressionT>& expressions_in_tail_position() {
250 return expressions_in_tail_position_;
251 }
252 void AddExpressionInTailPosition(ExpressionT expression) {
253 if (collect_expressions_in_tail_position_) {
254 expressions_in_tail_position_.Add(expression);
255 }
256 }
257
258 bool collect_expressions_in_tail_position() const {
259 return collect_expressions_in_tail_position_;
260 }
261 void set_collect_expressions_in_tail_position(bool collect) {
262 collect_expressions_in_tail_position_ = collect;
263 }
264
249 private: 265 private:
250 // Used to assign an index to each literal that needs materialization in 266 // Used to assign an index to each literal that needs materialization in
251 // the function. Includes regexp literals, and boilerplate for object and 267 // the function. Includes regexp literals, and boilerplate for object and
252 // array literals. 268 // array literals.
253 int next_materialized_literal_index_; 269 int next_materialized_literal_index_;
254 270
255 // Properties count estimation. 271 // Properties count estimation.
256 int expected_property_count_; 272 int expected_property_count_;
257 273
258 // Location of most recent use of 'this' (invalid if none). 274 // Location of most recent use of 'this' (invalid if none).
(...skipping 10 matching lines...) Expand all
269 // is used by yield expressions and return statements. It is not necessary 285 // is used by yield expressions and return statements. It is not necessary
270 // for generator functions to have this variable set. 286 // for generator functions to have this variable set.
271 Variable* generator_object_variable_; 287 Variable* generator_object_variable_;
272 288
273 FunctionState** function_state_stack_; 289 FunctionState** function_state_stack_;
274 FunctionState* outer_function_state_; 290 FunctionState* outer_function_state_;
275 Scope** scope_stack_; 291 Scope** scope_stack_;
276 Scope* outer_scope_; 292 Scope* outer_scope_;
277 293
278 List<DestructuringAssignment> destructuring_assignments_to_rewrite_; 294 List<DestructuringAssignment> destructuring_assignments_to_rewrite_;
295 List<ExpressionT> expressions_in_tail_position_;
296 bool collect_expressions_in_tail_position_;
279 297
280 void RewriteDestructuringAssignments(); 298 void RewriteDestructuringAssignments();
281 299
282 typename Traits::Type::Factory* factory_; 300 typename Traits::Type::Factory* factory_;
283 301
284 friend class ParserTraits; 302 friend class ParserTraits;
285 friend class Checkpoint; 303 friend class Checkpoint;
286 }; 304 };
287 305
288 // Annoyingly, arrow functions first parse as comma expressions, then when we 306 // Annoyingly, arrow functions first parse as comma expressions, then when we
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 bool allow_harmony_sloppy_let_; 944 bool allow_harmony_sloppy_let_;
927 bool allow_harmony_default_parameters_; 945 bool allow_harmony_default_parameters_;
928 bool allow_harmony_destructuring_bind_; 946 bool allow_harmony_destructuring_bind_;
929 bool allow_harmony_destructuring_assignment_; 947 bool allow_harmony_destructuring_assignment_;
930 bool allow_strong_mode_; 948 bool allow_strong_mode_;
931 bool allow_legacy_const_; 949 bool allow_legacy_const_;
932 bool allow_harmony_do_expressions_; 950 bool allow_harmony_do_expressions_;
933 bool allow_harmony_function_name_; 951 bool allow_harmony_function_name_;
934 }; 952 };
935 953
936
937 template <class Traits> 954 template <class Traits>
938 ParserBase<Traits>::FunctionState::FunctionState( 955 ParserBase<Traits>::FunctionState::FunctionState(
939 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, 956 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope,
940 FunctionKind kind, typename Traits::Type::Factory* factory) 957 FunctionKind kind, typename Traits::Type::Factory* factory)
941 : next_materialized_literal_index_(0), 958 : next_materialized_literal_index_(0),
942 expected_property_count_(0), 959 expected_property_count_(0),
943 this_location_(Scanner::Location::invalid()), 960 this_location_(Scanner::Location::invalid()),
944 return_location_(Scanner::Location::invalid()), 961 return_location_(Scanner::Location::invalid()),
945 super_location_(Scanner::Location::invalid()), 962 super_location_(Scanner::Location::invalid()),
946 kind_(kind), 963 kind_(kind),
947 generator_object_variable_(NULL), 964 generator_object_variable_(NULL),
948 function_state_stack_(function_state_stack), 965 function_state_stack_(function_state_stack),
949 outer_function_state_(*function_state_stack), 966 outer_function_state_(*function_state_stack),
950 scope_stack_(scope_stack), 967 scope_stack_(scope_stack),
951 outer_scope_(*scope_stack), 968 outer_scope_(*scope_stack),
969 collect_expressions_in_tail_position_(true),
952 factory_(factory) { 970 factory_(factory) {
953 *scope_stack_ = scope; 971 *scope_stack_ = scope;
954 *function_state_stack = this; 972 *function_state_stack = this;
955 } 973 }
956 974
957 975
958 template <class Traits> 976 template <class Traits>
959 ParserBase<Traits>::FunctionState::~FunctionState() { 977 ParserBase<Traits>::FunctionState::~FunctionState() {
960 *scope_stack_ = outer_scope_; 978 *scope_stack_ = outer_scope_;
961 *function_state_stack_ = outer_function_state_; 979 *function_state_stack_ = outer_function_state_;
(...skipping 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 return; 3392 return;
3375 } 3393 }
3376 has_seen_constructor_ = true; 3394 has_seen_constructor_ = true;
3377 return; 3395 return;
3378 } 3396 }
3379 } 3397 }
3380 } // namespace internal 3398 } // namespace internal
3381 } // namespace v8 3399 } // namespace v8
3382 3400
3383 #endif // V8_PARSING_PARSER_BASE_H 3401 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | test/mjsunit/es6/tail-call.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698