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

Side by Side Diff: src/ast/scopes.h

Issue 2253913002: Move asm_module_ and asm_function_ down to DeclarationScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test Created 4 years, 4 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/ast/scopeinfo.cc ('k') | src/ast/scopes.cc » ('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_AST_SCOPES_H_ 5 #ifndef V8_AST_SCOPES_H_
6 #define V8_AST_SCOPES_H_ 6 #define V8_AST_SCOPES_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/base/hashmap.h" 9 #include "src/base/hashmap.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 // Inform the scope that the corresponding code uses "super". 227 // Inform the scope that the corresponding code uses "super".
228 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } 228 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; }
229 229
230 // Set the language mode flag (unless disabled by a global flag). 230 // Set the language mode flag (unless disabled by a global flag).
231 void SetLanguageMode(LanguageMode language_mode) { 231 void SetLanguageMode(LanguageMode language_mode) {
232 DCHECK(!is_module_scope() || is_strict(language_mode)); 232 DCHECK(!is_module_scope() || is_strict(language_mode));
233 set_language_mode(language_mode); 233 set_language_mode(language_mode);
234 } 234 }
235 235
236 // Set the ASM module flag.
237 void SetAsmModule() { asm_module_ = true; }
238
239 // Inform the scope that the scope may execute declarations nonlinearly. 236 // Inform the scope that the scope may execute declarations nonlinearly.
240 // Currently, the only nonlinear scope is a switch statement. The name is 237 // Currently, the only nonlinear scope is a switch statement. The name is
241 // more general in case something else comes up with similar control flow, 238 // more general in case something else comes up with similar control flow,
242 // for example the ability to break out of something which does not have 239 // for example the ability to break out of something which does not have
243 // its own lexical scope. 240 // its own lexical scope.
244 // The bit does not need to be stored on the ScopeInfo because none of 241 // The bit does not need to be stored on the ScopeInfo because none of
245 // the three compilers will perform hole check elimination on a variable 242 // the three compilers will perform hole check elimination on a variable
246 // located in VariableLocation::CONTEXT. So, direct eval and closures 243 // located in VariableLocation::CONTEXT. So, direct eval and closures
247 // will not expose holes. 244 // will not expose holes.
248 void SetNonlinear() { scope_nonlinear_ = true; } 245 void SetNonlinear() { scope_nonlinear_ = true; }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 bool is_declaration_scope() const { return is_declaration_scope_; } 306 bool is_declaration_scope() const { return is_declaration_scope_; }
310 307
311 // Information about which scopes calls eval. 308 // Information about which scopes calls eval.
312 bool calls_eval() const { return scope_calls_eval_; } 309 bool calls_eval() const { return scope_calls_eval_; }
313 bool calls_sloppy_eval() const { 310 bool calls_sloppy_eval() const {
314 return scope_calls_eval_ && is_sloppy(language_mode()); 311 return scope_calls_eval_ && is_sloppy(language_mode());
315 } 312 }
316 bool outer_scope_calls_sloppy_eval() const { 313 bool outer_scope_calls_sloppy_eval() const {
317 return outer_scope_calls_sloppy_eval_; 314 return outer_scope_calls_sloppy_eval_;
318 } 315 }
319 bool asm_module() const { return asm_module_; } 316 bool IsAsmModule() const;
320 bool asm_function() const { return asm_function_; } 317 bool IsAsmFunction() const;
321
322 // Does this scope access "super" property (super.foo). 318 // Does this scope access "super" property (super.foo).
323 bool uses_super_property() const { return scope_uses_super_property_; } 319 bool uses_super_property() const { return scope_uses_super_property_; }
324 // Does this scope have the potential to execute declarations non-linearly? 320 // Does this scope have the potential to execute declarations non-linearly?
325 bool is_nonlinear() const { return scope_nonlinear_; } 321 bool is_nonlinear() const { return scope_nonlinear_; }
326 322
327 // Whether this needs to be represented by a runtime context. 323 // Whether this needs to be represented by a runtime context.
328 bool NeedsContext() const { 324 bool NeedsContext() const {
329 // Catch scopes always have heap slots. 325 // Catch scopes always have heap slots.
330 DCHECK(!is_catch_scope() || num_heap_slots() > 0); 326 DCHECK(!is_catch_scope() || num_heap_slots() > 0);
331 return num_heap_slots() > 0; 327 return num_heap_slots() > 0;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 bool is_strict_ : 1; 503 bool is_strict_ : 1;
508 // This scope is inside a 'with' of some outer scope. 504 // This scope is inside a 'with' of some outer scope.
509 bool scope_inside_with_ : 1; 505 bool scope_inside_with_ : 1;
510 // This scope or a nested catch scope or with scope contain an 'eval' call. At 506 // This scope or a nested catch scope or with scope contain an 'eval' call. At
511 // the 'eval' call site this scope is the declaration scope. 507 // the 'eval' call site this scope is the declaration scope.
512 bool scope_calls_eval_ : 1; 508 bool scope_calls_eval_ : 1;
513 // This scope uses "super" property ('super.foo'). 509 // This scope uses "super" property ('super.foo').
514 bool scope_uses_super_property_ : 1; 510 bool scope_uses_super_property_ : 1;
515 // This scope has a parameter called "arguments". 511 // This scope has a parameter called "arguments".
516 bool has_arguments_parameter_ : 1; 512 bool has_arguments_parameter_ : 1;
517 // This scope contains an "use asm" annotation.
518 bool asm_module_ : 1;
519 // This scope's outer context is an asm module.
520 bool asm_function_ : 1;
521 // This scope's declarations might not be executed in order (e.g., switch). 513 // This scope's declarations might not be executed in order (e.g., switch).
522 bool scope_nonlinear_ : 1; 514 bool scope_nonlinear_ : 1;
523 bool is_hidden_ : 1; 515 bool is_hidden_ : 1;
524 // Temporary workaround that allows masking of 'this' in debug-evalute scopes. 516 // Temporary workaround that allows masking of 'this' in debug-evalute scopes.
525 bool is_debug_evaluate_scope_ : 1; 517 bool is_debug_evaluate_scope_ : 1;
526 518
527 // Computed via PropagateScopeInfo. 519 // Computed via PropagateScopeInfo.
528 bool outer_scope_calls_sloppy_eval_ : 1; 520 bool outer_scope_calls_sloppy_eval_ : 1;
529 bool inner_scope_calls_eval_ : 1; 521 bool inner_scope_calls_eval_ : 1;
530 bool force_eager_compilation_ : 1; 522 bool force_eager_compilation_ : 1;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 669 }
678 670
679 bool NeedsHomeObject() const { 671 bool NeedsHomeObject() const {
680 return scope_uses_super_property_ || 672 return scope_uses_super_property_ ||
681 ((scope_calls_eval_ || inner_scope_calls_eval_) && 673 ((scope_calls_eval_ || inner_scope_calls_eval_) &&
682 (IsConciseMethod(function_kind()) || 674 (IsConciseMethod(function_kind()) ||
683 IsAccessorFunction(function_kind()) || 675 IsAccessorFunction(function_kind()) ||
684 IsClassConstructor(function_kind()))); 676 IsClassConstructor(function_kind())));
685 } 677 }
686 678
679 bool asm_module() const { return asm_module_; }
680 void set_asm_module() { asm_module_ = true; }
681 bool asm_function() const { return asm_function_; }
682 void set_asm_function() { asm_module_ = true; }
683
687 void DeclareThis(AstValueFactory* ast_value_factory); 684 void DeclareThis(AstValueFactory* ast_value_factory);
688 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory); 685 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory);
689 686
690 // This lookup corresponds to a lookup in the "intermediate" scope sitting 687 // This lookup corresponds to a lookup in the "intermediate" scope sitting
691 // between this scope and the outer scope. (ECMA-262, 3rd., requires that 688 // between this scope and the outer scope. (ECMA-262, 3rd., requires that
692 // the name of named function literal is kept in an intermediate scope 689 // the name of named function literal is kept in an intermediate scope
693 // in between this scope and the next outer scope.) 690 // in between this scope and the next outer scope.)
694 Variable* LookupFunctionVar(const AstRawString* name); 691 Variable* LookupFunctionVar(const AstRawString* name);
695 692
696 // Declare the function variable for a function literal. This variable 693 // Declare the function variable for a function literal. This variable
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 850
854 private: 851 private:
855 void AllocateParameter(Variable* var, int index); 852 void AllocateParameter(Variable* var, int index);
856 853
857 void SetDefaults(); 854 void SetDefaults();
858 855
859 // If the scope is a function scope, this is the function kind. 856 // If the scope is a function scope, this is the function kind.
860 const FunctionKind function_kind_; 857 const FunctionKind function_kind_;
861 858
862 bool has_simple_parameters_ : 1; 859 bool has_simple_parameters_ : 1;
860 // This scope contains an "use asm" annotation.
861 bool asm_module_ : 1;
862 // This scope's outer context is an asm module.
863 bool asm_function_ : 1;
863 864
864 // Info about the parameter list of a function. 865 // Info about the parameter list of a function.
865 int arity_; 866 int arity_;
866 int rest_index_; 867 int rest_index_;
867 Variable* rest_parameter_; 868 Variable* rest_parameter_;
868 // Compiler-allocated (user-invisible) temporaries. 869 // Compiler-allocated (user-invisible) temporaries.
869 ZoneList<Variable*> temps_; 870 ZoneList<Variable*> temps_;
870 // Parameter list in source order. 871 // Parameter list in source order.
871 ZoneList<Variable*> params_; 872 ZoneList<Variable*> params_;
872 // Map of function names to lists of functions defined in sloppy blocks 873 // Map of function names to lists of functions defined in sloppy blocks
(...skipping 25 matching lines...) Expand all
898 void AllocateModuleVariables(); 899 void AllocateModuleVariables();
899 900
900 private: 901 private:
901 ModuleDescriptor* module_descriptor_; 902 ModuleDescriptor* module_descriptor_;
902 }; 903 };
903 904
904 } // namespace internal 905 } // namespace internal
905 } // namespace v8 906 } // namespace v8
906 907
907 #endif // V8_AST_SCOPES_H_ 908 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « src/ast/scopeinfo.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698