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

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

Issue 2263123002: Find the last outer eval scope to check in fullcodegen rather than scope analysis (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add ports 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 | « no previous file | 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } 303 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; }
304 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } 304 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; }
305 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } 305 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; }
306 bool is_declaration_scope() const { return is_declaration_scope_; } 306 bool is_declaration_scope() const { return is_declaration_scope_; }
307 307
308 // Information about which scopes calls eval. 308 // Information about which scopes calls eval.
309 bool calls_eval() const { return scope_calls_eval_; } 309 bool calls_eval() const { return scope_calls_eval_; }
310 bool calls_sloppy_eval() const { 310 bool calls_sloppy_eval() const {
311 return scope_calls_eval_ && is_sloppy(language_mode()); 311 return scope_calls_eval_ && is_sloppy(language_mode());
312 } 312 }
313 bool outer_scope_calls_sloppy_eval() const {
314 return outer_scope_calls_sloppy_eval_;
315 }
316 bool IsAsmModule() const; 313 bool IsAsmModule() const;
317 bool IsAsmFunction() const; 314 bool IsAsmFunction() const;
318 // Does this scope access "super" property (super.foo). 315 // Does this scope access "super" property (super.foo).
319 bool uses_super_property() const { return scope_uses_super_property_; } 316 bool uses_super_property() const { return scope_uses_super_property_; }
320 // Does this scope have the potential to execute declarations non-linearly? 317 // Does this scope have the potential to execute declarations non-linearly?
321 bool is_nonlinear() const { return scope_nonlinear_; } 318 bool is_nonlinear() const { return scope_nonlinear_; }
322 319
323 // Whether this needs to be represented by a runtime context. 320 // Whether this needs to be represented by a runtime context.
324 bool NeedsContext() const { 321 bool NeedsContext() const {
325 // Catch scopes always have heap slots. 322 // Catch scopes always have heap slots.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 // Determine if we can parse a function literal in this scope lazily. 373 // Determine if we can parse a function literal in this scope lazily.
377 bool AllowsLazyParsing() const; 374 bool AllowsLazyParsing() const;
378 375
379 // Determine if we can use lazy compilation for this scope. 376 // Determine if we can use lazy compilation for this scope.
380 bool AllowsLazyCompilation() const; 377 bool AllowsLazyCompilation() const;
381 378
382 // Determine if we can use lazy compilation for this scope without a context. 379 // Determine if we can use lazy compilation for this scope without a context.
383 bool AllowsLazyCompilationWithoutContext() const; 380 bool AllowsLazyCompilationWithoutContext() const;
384 381
385 // The number of contexts between this and scope; zero if this == scope. 382 // The number of contexts between this and scope; zero if this == scope.
386 int ContextChainLength(Scope* scope); 383 int ContextChainLength(Scope* scope) const;
384
385 // The number of contexts between this and the outermost context that has a
386 // sloppy eval call. One if this->calls_sloppy_eval().
387 int ContextChainLengthUntilOutermostSloppyEval() const;
387 388
388 // The maximum number of nested contexts required for this scope and any inner 389 // The maximum number of nested contexts required for this scope and any inner
389 // scopes. 390 // scopes.
390 int MaxNestedContextChainLength(); 391 int MaxNestedContextChainLength();
391 392
392 // Find the first function, script, eval or (declaration) block scope. This is 393 // Find the first function, script, eval or (declaration) block scope. This is
393 // the scope where var declarations will be hoisted to in the implementation. 394 // the scope where var declarations will be hoisted to in the implementation.
394 DeclarationScope* GetDeclarationScope(); 395 DeclarationScope* GetDeclarationScope();
395 396
396 // Find the first non-block declaration scope. This should be either a script, 397 // Find the first non-block declaration scope. This should be either a script,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 bool scope_uses_super_property_ : 1; 506 bool scope_uses_super_property_ : 1;
506 // This scope has a parameter called "arguments". 507 // This scope has a parameter called "arguments".
507 bool has_arguments_parameter_ : 1; 508 bool has_arguments_parameter_ : 1;
508 // This scope's declarations might not be executed in order (e.g., switch). 509 // This scope's declarations might not be executed in order (e.g., switch).
509 bool scope_nonlinear_ : 1; 510 bool scope_nonlinear_ : 1;
510 bool is_hidden_ : 1; 511 bool is_hidden_ : 1;
511 // Temporary workaround that allows masking of 'this' in debug-evalute scopes. 512 // Temporary workaround that allows masking of 'this' in debug-evalute scopes.
512 bool is_debug_evaluate_scope_ : 1; 513 bool is_debug_evaluate_scope_ : 1;
513 514
514 // Computed via PropagateScopeInfo. 515 // Computed via PropagateScopeInfo.
515 bool outer_scope_calls_sloppy_eval_ : 1;
516 bool inner_scope_calls_eval_ : 1; 516 bool inner_scope_calls_eval_ : 1;
517 bool force_eager_compilation_ : 1; 517 bool force_eager_compilation_ : 1;
518 bool force_context_allocation_ : 1; 518 bool force_context_allocation_ : 1;
519 519
520 // True if it holds 'var' declarations. 520 // True if it holds 'var' declarations.
521 bool is_declaration_scope_ : 1; 521 bool is_declaration_scope_ : 1;
522 522
523 // Create a non-local variable with a given name. 523 // Create a non-local variable with a given name.
524 // These variables are looked up dynamically at runtime. 524 // These variables are looked up dynamically at runtime.
525 Variable* NonLocal(const AstRawString* name, VariableMode mode); 525 Variable* NonLocal(const AstRawString* name, VariableMode mode);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); 584 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory);
585 585
586 // Finds free variables of this scope. This mutates the unresolved variables 586 // Finds free variables of this scope. This mutates the unresolved variables
587 // list along the way, so full resolution cannot be done afterwards. 587 // list along the way, so full resolution cannot be done afterwards.
588 // If a ParseInfo* is passed, non-free variables will be resolved. 588 // If a ParseInfo* is passed, non-free variables will be resolved.
589 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, 589 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope,
590 ParseInfo* info = nullptr, 590 ParseInfo* info = nullptr,
591 VariableProxy* stack = nullptr); 591 VariableProxy* stack = nullptr);
592 592
593 // Scope analysis. 593 // Scope analysis.
594 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); 594 void PropagateScopeInfo();
595 595
596 // Predicates. 596 // Predicates.
597 bool MustAllocate(Variable* var); 597 bool MustAllocate(Variable* var);
598 bool MustAllocateInContext(Variable* var); 598 bool MustAllocateInContext(Variable* var);
599 599
600 // Variable allocation. 600 // Variable allocation.
601 void AllocateStackSlot(Variable* var); 601 void AllocateStackSlot(Variable* var);
602 void AllocateHeapSlot(Variable* var); 602 void AllocateHeapSlot(Variable* var);
603 void AllocateNonParameterLocal(Variable* var); 603 void AllocateNonParameterLocal(Variable* var);
604 void AllocateDeclaredGlobal(Variable* var); 604 void AllocateDeclaredGlobal(Variable* var);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 void AllocateModuleVariables(); 893 void AllocateModuleVariables();
894 894
895 private: 895 private:
896 ModuleDescriptor* module_descriptor_; 896 ModuleDescriptor* module_descriptor_;
897 }; 897 };
898 898
899 } // namespace internal 899 } // namespace internal
900 } // namespace v8 900 } // namespace v8
901 901
902 #endif // V8_AST_SCOPES_H_ 902 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698