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

Side by Side Diff: src/scopes.h

Issue 13408005: Force context allocation for variables in generator scopes. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 7 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // end position: end position of last token of 'stmt' 262 // end position: end position of last token of 'stmt'
263 int start_position() const { return start_position_; } 263 int start_position() const { return start_position_; }
264 void set_start_position(int statement_pos) { 264 void set_start_position(int statement_pos) {
265 start_position_ = statement_pos; 265 start_position_ = statement_pos;
266 } 266 }
267 int end_position() const { return end_position_; } 267 int end_position() const { return end_position_; }
268 void set_end_position(int statement_pos) { 268 void set_end_position(int statement_pos) {
269 end_position_ = statement_pos; 269 end_position_ = statement_pos;
270 } 270 }
271 271
272 // In some cases we want to force context allocation for a whole scope. For
273 // example in generators, allocating variables in contexts minimizes the work
Michael Starzinger 2013/04/05 11:38:42 Can we move the second sentence of this comment to
wingo 2013/04/05 12:25:06 Done.
274 // to suspend and resume.
275 void ForceContextAllocation() {
276 ASSERT(!already_resolved());
277 force_context_allocation_ = true;
278 }
279 bool has_forced_context_allocation() const {
280 return force_context_allocation_;
281 }
282
272 // --------------------------------------------------------------------------- 283 // ---------------------------------------------------------------------------
273 // Predicates. 284 // Predicates.
274 285
275 // Specific scope types. 286 // Specific scope types.
276 bool is_eval_scope() const { return type_ == EVAL_SCOPE; } 287 bool is_eval_scope() const { return type_ == EVAL_SCOPE; }
277 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } 288 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; }
278 bool is_module_scope() const { return type_ == MODULE_SCOPE; } 289 bool is_module_scope() const { return type_ == MODULE_SCOPE; }
279 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } 290 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; }
280 bool is_catch_scope() const { return type_ == CATCH_SCOPE; } 291 bool is_catch_scope() const { return type_ == CATCH_SCOPE; }
281 bool is_block_scope() const { return type_ == BLOCK_SCOPE; } 292 bool is_block_scope() const { return type_ == BLOCK_SCOPE; }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // The language mode of this scope. 498 // The language mode of this scope.
488 LanguageMode language_mode_; 499 LanguageMode language_mode_;
489 // Source positions. 500 // Source positions.
490 int start_position_; 501 int start_position_;
491 int end_position_; 502 int end_position_;
492 503
493 // Computed via PropagateScopeInfo. 504 // Computed via PropagateScopeInfo.
494 bool outer_scope_calls_non_strict_eval_; 505 bool outer_scope_calls_non_strict_eval_;
495 bool inner_scope_calls_eval_; 506 bool inner_scope_calls_eval_;
496 bool force_eager_compilation_; 507 bool force_eager_compilation_;
508 bool force_context_allocation_;
497 509
498 // True if it doesn't need scope resolution (e.g., if the scope was 510 // True if it doesn't need scope resolution (e.g., if the scope was
499 // constructed based on a serialized scope info or a catch context). 511 // constructed based on a serialized scope info or a catch context).
500 bool already_resolved_; 512 bool already_resolved_;
501 513
502 // Computed as variables are declared. 514 // Computed as variables are declared.
503 int num_var_or_const_; 515 int num_var_or_const_;
504 516
505 // Computed via AllocateVariables; function, block and catch scopes only. 517 // Computed via AllocateVariables; function, block and catch scopes only.
506 int num_stack_slots_; 518 int num_stack_slots_;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 void SetDefaults(ScopeType type, 640 void SetDefaults(ScopeType type,
629 Scope* outer_scope, 641 Scope* outer_scope,
630 Handle<ScopeInfo> scope_info); 642 Handle<ScopeInfo> scope_info);
631 643
632 Zone* zone_; 644 Zone* zone_;
633 }; 645 };
634 646
635 } } // namespace v8::internal 647 } } // namespace v8::internal
636 648
637 #endif // V8_SCOPES_H_ 649 #endif // V8_SCOPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698