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

Side by Side Diff: src/parsing/parser.h

Issue 2656753003: [ast/parsing] Pessimistically assume all top-level variables will be assigned. (Closed)
Patch Set: Created 3 years, 10 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_PARSING_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 816
817 // Determine if the expression is a variable proxy and mark it as being used 817 // Determine if the expression is a variable proxy and mark it as being used
818 // in an assignment or with a increment/decrement operator. 818 // in an assignment or with a increment/decrement operator.
819 V8_INLINE static void MarkExpressionAsAssigned(Expression* expression) { 819 V8_INLINE static void MarkExpressionAsAssigned(Expression* expression) {
820 DCHECK_NOT_NULL(expression); 820 DCHECK_NOT_NULL(expression);
821 if (expression->IsVariableProxy()) { 821 if (expression->IsVariableProxy()) {
822 expression->AsVariableProxy()->set_is_assigned(); 822 expression->AsVariableProxy()->set_is_assigned();
823 } 823 }
824 } 824 }
825 825
826 // We have to pessimistically assume that top-level variables will be
827 // assigned. This is because they might be accessed by a lazily parsed
marja 2017/01/25 12:44:10 You could fix this comment in this CL :) (There's
828 // top-level function, which, for efficiency, we preparse without
829 // variable tracking. In the case of a script (not a module), they
830 // might also get accessed by another script.
831 V8_INLINE static void MarkTopLevelVariableAsAssigned(Scope* scope,
832 VariableProxy* proxy) {
833 if (scope->is_script_scope() || scope->is_module_scope()) {
adamk 2017/01/27 16:07:36 I thought we currently disable preparsing of funct
834 proxy->set_is_assigned();
835 }
836 }
837
826 // Returns true if we have a binary expression between two numeric 838 // Returns true if we have a binary expression between two numeric
827 // literals. In that case, *x will be changed to an expression which is the 839 // literals. In that case, *x will be changed to an expression which is the
828 // computed value. 840 // computed value.
829 bool ShortcutNumericLiteralBinaryExpression(Expression** x, Expression* y, 841 bool ShortcutNumericLiteralBinaryExpression(Expression** x, Expression* y,
830 Token::Value op, int pos); 842 Token::Value op, int pos);
831 843
832 // Rewrites the following types of unary expressions: 844 // Rewrites the following types of unary expressions:
833 // not <literal> -> true / false 845 // not <literal> -> true / false
834 // + <numeric literal> -> <numeric literal> 846 // + <numeric literal> -> <numeric literal>
835 // - <numeric literal> -> <numeric literal with value negated> 847 // - <numeric literal> -> <numeric literal with value negated>
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1188
1177 private: 1189 private:
1178 ParserTarget** variable_; 1190 ParserTarget** variable_;
1179 ParserTarget* previous_; 1191 ParserTarget* previous_;
1180 }; 1192 };
1181 1193
1182 } // namespace internal 1194 } // namespace internal
1183 } // namespace v8 1195 } // namespace v8
1184 1196
1185 #endif // V8_PARSING_PARSER_H_ 1197 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/parsing/parser.cc » ('j') | src/parsing/pattern-rewriter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698