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

Side by Side Diff: src/scopes.h

Issue 1404793004: Add support for calculating a scopes maximum nested context chain. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // Does this scope access "arguments". 334 // Does this scope access "arguments".
335 bool uses_arguments() const { return scope_uses_arguments_; } 335 bool uses_arguments() const { return scope_uses_arguments_; }
336 // Does any inner scope access "arguments". 336 // Does any inner scope access "arguments".
337 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } 337 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; }
338 // Does this scope access "super" property (super.foo). 338 // Does this scope access "super" property (super.foo).
339 bool uses_super_property() const { return scope_uses_super_property_; } 339 bool uses_super_property() const { return scope_uses_super_property_; }
340 // Does this scope have the potential to execute declarations non-linearly? 340 // Does this scope have the potential to execute declarations non-linearly?
341 bool is_nonlinear() const { return scope_nonlinear_; } 341 bool is_nonlinear() const { return scope_nonlinear_; }
342 342
343 // Whether this needs to be represented by a runtime context. 343 // Whether this needs to be represented by a runtime context.
344 bool NeedsContext() const { return num_heap_slots() > 0; } 344 bool NeedsContext() const {
345 // Catch and module scopes always have heap slots.
346 DCHECK(!is_catch_scope() || num_heap_slots() > 0);
347 DCHECK(!is_module_scope() || num_heap_slots() > 0);
348 return is_with_scope() || num_heap_slots() > 0;
adamk 2015/10/15 07:38:45 The other callers of NeedsContext() only call it o
rmcilroy 2015/10/15 09:23:07 I could do this, however personally I think it is
adamk 2015/10/15 09:34:32 What I'm saying is that testing "is_with_scope()"
rmcilroy 2015/10/15 14:06:16 Acknowledged.
349 }
345 350
346 bool NeedsHomeObject() const { 351 bool NeedsHomeObject() const {
347 return scope_uses_super_property_ || 352 return scope_uses_super_property_ ||
348 (scope_calls_eval_ && (IsConciseMethod(function_kind()) || 353 (scope_calls_eval_ && (IsConciseMethod(function_kind()) ||
349 IsAccessorFunction(function_kind()) || 354 IsAccessorFunction(function_kind()) ||
350 IsClassConstructor(function_kind()))); 355 IsClassConstructor(function_kind())));
351 } 356 }
352 357
353 const Scope* NearestOuterEvalScope() const { 358 const Scope* NearestOuterEvalScope() const {
354 if (is_eval_scope()) return this; 359 if (is_eval_scope()) return this;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 517
513 // Determine if we can use lazy compilation for this scope without a context. 518 // Determine if we can use lazy compilation for this scope without a context.
514 bool AllowsLazyCompilationWithoutContext() const; 519 bool AllowsLazyCompilationWithoutContext() const;
515 520
516 // True if the outer context of this scope is always the native context. 521 // True if the outer context of this scope is always the native context.
517 bool HasTrivialOuterContext() const; 522 bool HasTrivialOuterContext() const;
518 523
519 // The number of contexts between this and scope; zero if this == scope. 524 // The number of contexts between this and scope; zero if this == scope.
520 int ContextChainLength(Scope* scope); 525 int ContextChainLength(Scope* scope);
521 526
527 // The maximum number of nested contexts required for this scope and any inner
528 // scopes.
529 int MaxNestedContextChainLength();
530
522 // Find the first function, script, eval or (declaration) block scope. This is 531 // Find the first function, script, eval or (declaration) block scope. This is
523 // the scope where var declarations will be hoisted to in the implementation. 532 // the scope where var declarations will be hoisted to in the implementation.
524 Scope* DeclarationScope(); 533 Scope* DeclarationScope();
525 534
526 // Find the first non-block declaration scope. This should be either a script, 535 // Find the first non-block declaration scope. This should be either a script,
527 // function, or eval scope. Same as DeclarationScope(), but skips 536 // function, or eval scope. Same as DeclarationScope(), but skips
528 // declaration "block" scopes. Used for differentiating associated 537 // declaration "block" scopes. Used for differentiating associated
529 // function objects (i.e., the scope for which a function prologue allocates 538 // function objects (i.e., the scope for which a function prologue allocates
530 // a context) or declaring temporaries. 539 // a context) or declaring temporaries.
531 Scope* ClosureScope(); 540 Scope* ClosureScope();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 824
816 // For tracking which classes are declared consecutively. Needed for strong 825 // For tracking which classes are declared consecutively. Needed for strong
817 // mode. 826 // mode.
818 int class_declaration_group_start_; 827 int class_declaration_group_start_;
819 }; 828 };
820 829
821 } // namespace internal 830 } // namespace internal
822 } // namespace v8 831 } // namespace v8
823 832
824 #endif // V8_SCOPES_H_ 833 #endif // V8_SCOPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698