| OLD | NEW |
| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } | 218 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } |
| 219 | 219 |
| 220 // Set the language mode flag (unless disabled by a global flag). | 220 // Set the language mode flag (unless disabled by a global flag). |
| 221 void SetLanguageMode(LanguageMode language_mode) { | 221 void SetLanguageMode(LanguageMode language_mode) { |
| 222 language_mode_ = language_mode; | 222 language_mode_ = language_mode; |
| 223 } | 223 } |
| 224 | 224 |
| 225 // Set the ASM module flag. | 225 // Set the ASM module flag. |
| 226 void SetAsmModule() { asm_module_ = true; } | 226 void SetAsmModule() { asm_module_ = true; } |
| 227 | 227 |
| 228 // Inform the scope that the scope may execute declarations nonlinearly. |
| 229 // Currently, the only nonlinear scope is a switch statement. The name is |
| 230 // more general in case something else comes up with similar control flow, |
| 231 // for example the ability to break out of something which does not have |
| 232 // its own lexical scope. |
| 233 // The bit does not need to be stored on the ScopeInfo because none of |
| 234 // the three compilers will perform hole check elimination on a variable |
| 235 // located in VariableLocation::CONTEXT. So, direct eval and closures |
| 236 // will not expose holes. |
| 237 void SetNonlinear() { scope_nonlinear_ = true; } |
| 238 |
| 228 // Position in the source where this scope begins and ends. | 239 // Position in the source where this scope begins and ends. |
| 229 // | 240 // |
| 230 // * For the scope of a with statement | 241 // * For the scope of a with statement |
| 231 // with (obj) stmt | 242 // with (obj) stmt |
| 232 // start position: start position of first token of 'stmt' | 243 // start position: start position of first token of 'stmt' |
| 233 // end position: end position of last token of 'stmt' | 244 // end position: end position of last token of 'stmt' |
| 234 // * For the scope of a block | 245 // * For the scope of a block |
| 235 // { stmts } | 246 // { stmts } |
| 236 // start position: start position of '{' | 247 // start position: start position of '{' |
| 237 // end position: end position of '}' | 248 // end position: end position of '}' |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 bool inside_with() const { return scope_inside_with_; } | 313 bool inside_with() const { return scope_inside_with_; } |
| 303 // Does this scope contain a with statement. | 314 // Does this scope contain a with statement. |
| 304 bool contains_with() const { return scope_contains_with_; } | 315 bool contains_with() const { return scope_contains_with_; } |
| 305 | 316 |
| 306 // Does this scope access "arguments". | 317 // Does this scope access "arguments". |
| 307 bool uses_arguments() const { return scope_uses_arguments_; } | 318 bool uses_arguments() const { return scope_uses_arguments_; } |
| 308 // Does any inner scope access "arguments". | 319 // Does any inner scope access "arguments". |
| 309 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } | 320 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
| 310 // Does this scope access "super" property (super.foo). | 321 // Does this scope access "super" property (super.foo). |
| 311 bool uses_super_property() const { return scope_uses_super_property_; } | 322 bool uses_super_property() const { return scope_uses_super_property_; } |
| 323 // Does this scope have the potential to execute declarations non-linearly? |
| 324 bool is_nonlinear() const { return scope_nonlinear_; } |
| 312 | 325 |
| 313 // Whether this needs to be represented by a runtime context. | 326 // Whether this needs to be represented by a runtime context. |
| 314 bool NeedsContext() const { return num_heap_slots() > 0; } | 327 bool NeedsContext() const { return num_heap_slots() > 0; } |
| 315 | 328 |
| 316 bool NeedsHomeObject() const { | 329 bool NeedsHomeObject() const { |
| 317 return scope_uses_super_property_ || | 330 return scope_uses_super_property_ || |
| 318 (scope_calls_eval_ && (IsConciseMethod(function_kind()) || | 331 (scope_calls_eval_ && (IsConciseMethod(function_kind()) || |
| 319 IsAccessorFunction(function_kind()) || | 332 IsAccessorFunction(function_kind()) || |
| 320 IsConstructor(function_kind()))); | 333 IsConstructor(function_kind()))); |
| 321 } | 334 } |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 // the 'eval' call site this scope is the declaration scope. | 615 // the 'eval' call site this scope is the declaration scope. |
| 603 bool scope_calls_eval_; | 616 bool scope_calls_eval_; |
| 604 // This scope uses "arguments". | 617 // This scope uses "arguments". |
| 605 bool scope_uses_arguments_; | 618 bool scope_uses_arguments_; |
| 606 // This scope uses "super" property ('super.foo'). | 619 // This scope uses "super" property ('super.foo'). |
| 607 bool scope_uses_super_property_; | 620 bool scope_uses_super_property_; |
| 608 // This scope contains an "use asm" annotation. | 621 // This scope contains an "use asm" annotation. |
| 609 bool asm_module_; | 622 bool asm_module_; |
| 610 // This scope's outer context is an asm module. | 623 // This scope's outer context is an asm module. |
| 611 bool asm_function_; | 624 bool asm_function_; |
| 625 // This scope's declarations might not be executed in order (e.g., switch). |
| 626 bool scope_nonlinear_; |
| 612 // The language mode of this scope. | 627 // The language mode of this scope. |
| 613 LanguageMode language_mode_; | 628 LanguageMode language_mode_; |
| 614 // Source positions. | 629 // Source positions. |
| 615 int start_position_; | 630 int start_position_; |
| 616 int end_position_; | 631 int end_position_; |
| 617 | 632 |
| 618 // Computed via PropagateScopeInfo. | 633 // Computed via PropagateScopeInfo. |
| 619 bool outer_scope_calls_sloppy_eval_; | 634 bool outer_scope_calls_sloppy_eval_; |
| 620 bool inner_scope_calls_eval_; | 635 bool inner_scope_calls_eval_; |
| 621 bool inner_scope_uses_arguments_; | 636 bool inner_scope_uses_arguments_; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 PendingCompilationErrorHandler pending_error_handler_; | 793 PendingCompilationErrorHandler pending_error_handler_; |
| 779 | 794 |
| 780 // For tracking which classes are declared consecutively. Needed for strong | 795 // For tracking which classes are declared consecutively. Needed for strong |
| 781 // mode. | 796 // mode. |
| 782 int class_declaration_group_start_; | 797 int class_declaration_group_start_; |
| 783 }; | 798 }; |
| 784 | 799 |
| 785 } } // namespace v8::internal | 800 } } // namespace v8::internal |
| 786 | 801 |
| 787 #endif // V8_SCOPES_H_ | 802 #endif // V8_SCOPES_H_ |
| OLD | NEW |