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/scopes.h

Issue 1312613003: Ensure hole checks take place in switch statement scopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Changes based on review Created 5 years, 3 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 // 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_SCOPES_H_ 5 #ifndef V8_SCOPES_H_
6 #define V8_SCOPES_H_ 6 #define V8_SCOPES_H_
7 7
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/pending-compilation-error-handler.h" 9 #include "src/pending-compilation-error-handler.h"
10 #include "src/zone.h" 10 #include "src/zone.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } 217 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; }
218 218
219 // Set the language mode flag (unless disabled by a global flag). 219 // Set the language mode flag (unless disabled by a global flag).
220 void SetLanguageMode(LanguageMode language_mode) { 220 void SetLanguageMode(LanguageMode language_mode) {
221 language_mode_ = language_mode; 221 language_mode_ = language_mode;
222 } 222 }
223 223
224 // Set the ASM module flag. 224 // Set the ASM module flag.
225 void SetAsmModule() { asm_module_ = true; } 225 void SetAsmModule() { asm_module_ = true; }
226 226
227 // Inform the scope that the scope may execute declarations nonlinearly.
228 // Currently, the only nonlinear scope is a switch statement. The name is
229 // more general in case something else comes up with similar control flow,
230 // for example the ability to break out of something which does not have
231 // its own lexical scope.
232 void SetNonlinear() { scope_nonlinear_ = true; }
233
227 // Position in the source where this scope begins and ends. 234 // Position in the source where this scope begins and ends.
228 // 235 //
229 // * For the scope of a with statement 236 // * For the scope of a with statement
230 // with (obj) stmt 237 // with (obj) stmt
231 // start position: start position of first token of 'stmt' 238 // start position: start position of first token of 'stmt'
232 // end position: end position of last token of 'stmt' 239 // end position: end position of last token of 'stmt'
233 // * For the scope of a block 240 // * For the scope of a block
234 // { stmts } 241 // { stmts }
235 // start position: start position of '{' 242 // start position: start position of '{'
236 // end position: end position of '}' 243 // end position: end position of '}'
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 bool inside_with() const { return scope_inside_with_; } 308 bool inside_with() const { return scope_inside_with_; }
302 // Does this scope contain a with statement. 309 // Does this scope contain a with statement.
303 bool contains_with() const { return scope_contains_with_; } 310 bool contains_with() const { return scope_contains_with_; }
304 311
305 // Does this scope access "arguments". 312 // Does this scope access "arguments".
306 bool uses_arguments() const { return scope_uses_arguments_; } 313 bool uses_arguments() const { return scope_uses_arguments_; }
307 // Does any inner scope access "arguments". 314 // Does any inner scope access "arguments".
308 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } 315 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; }
309 // Does this scope access "super" property (super.foo). 316 // Does this scope access "super" property (super.foo).
310 bool uses_super_property() const { return scope_uses_super_property_; } 317 bool uses_super_property() const { return scope_uses_super_property_; }
318 // Does this scope have the potential to execute declarations non-linearly?
319 bool is_nonlinear() const { return scope_nonlinear_; }
311 320
312 // Whether this needs to be represented by a runtime context. 321 // Whether this needs to be represented by a runtime context.
313 bool NeedsContext() const { return num_heap_slots() > 0; } 322 bool NeedsContext() const { return num_heap_slots() > 0; }
314 323
315 bool NeedsHomeObject() const { 324 bool NeedsHomeObject() const {
316 return scope_uses_super_property_ || 325 return scope_uses_super_property_ ||
317 (scope_calls_eval_ && (IsConciseMethod(function_kind()) || 326 (scope_calls_eval_ && (IsConciseMethod(function_kind()) ||
318 IsAccessorFunction(function_kind()) || 327 IsAccessorFunction(function_kind()) ||
319 IsConstructor(function_kind()))); 328 IsConstructor(function_kind())));
320 } 329 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 // the 'eval' call site this scope is the declaration scope. 603 // the 'eval' call site this scope is the declaration scope.
595 bool scope_calls_eval_; 604 bool scope_calls_eval_;
596 // This scope uses "arguments". 605 // This scope uses "arguments".
597 bool scope_uses_arguments_; 606 bool scope_uses_arguments_;
598 // This scope uses "super" property ('super.foo'). 607 // This scope uses "super" property ('super.foo').
599 bool scope_uses_super_property_; 608 bool scope_uses_super_property_;
600 // This scope contains an "use asm" annotation. 609 // This scope contains an "use asm" annotation.
601 bool asm_module_; 610 bool asm_module_;
602 // This scope's outer context is an asm module. 611 // This scope's outer context is an asm module.
603 bool asm_function_; 612 bool asm_function_;
613 // This scope's declarations might not be executed in order (e.g., switch).
614 bool scope_nonlinear_;
604 // The language mode of this scope. 615 // The language mode of this scope.
605 LanguageMode language_mode_; 616 LanguageMode language_mode_;
606 // Source positions. 617 // Source positions.
607 int start_position_; 618 int start_position_;
608 int end_position_; 619 int end_position_;
609 620
610 // Computed via PropagateScopeInfo. 621 // Computed via PropagateScopeInfo.
611 bool outer_scope_calls_sloppy_eval_; 622 bool outer_scope_calls_sloppy_eval_;
612 bool inner_scope_calls_eval_; 623 bool inner_scope_calls_eval_;
613 bool inner_scope_uses_arguments_; 624 bool inner_scope_uses_arguments_;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 PendingCompilationErrorHandler pending_error_handler_; 780 PendingCompilationErrorHandler pending_error_handler_;
770 781
771 // For tracking which classes are declared consecutively. Needed for strong 782 // For tracking which classes are declared consecutively. Needed for strong
772 // mode. 783 // mode.
773 int class_declaration_group_start_; 784 int class_declaration_group_start_;
774 }; 785 };
775 786
776 } } // namespace v8::internal 787 } } // namespace v8::internal
777 788
778 #endif // V8_SCOPES_H_ 789 #endif // V8_SCOPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698