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

Side by Side Diff: src/parsing/preparser.cc

Issue 2474393003: [parser] Give preparser and parser independent loggers (Closed)
Patch Set: Created 4 years, 1 month 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (track_unresolved_variables_) { 78 if (track_unresolved_variables_) {
79 const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory()); 79 const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory());
80 DCHECK_NOT_NULL(result); 80 DCHECK_NOT_NULL(result);
81 symbol.string_ = result; 81 symbol.string_ = result;
82 } 82 }
83 return symbol; 83 return symbol;
84 } 84 }
85 85
86 PreParser::PreParseResult PreParser::PreParseFunction( 86 PreParser::PreParseResult PreParser::PreParseFunction(
87 FunctionKind kind, DeclarationScope* function_scope, bool parsing_module, 87 FunctionKind kind, DeclarationScope* function_scope, bool parsing_module,
88 SingletonLogger* log, bool is_inner_function, bool may_abort, 88 bool is_inner_function, bool may_abort, int* use_counts) {
89 int* use_counts) {
90 DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type()); 89 DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type());
91 parsing_module_ = parsing_module; 90 parsing_module_ = parsing_module;
92 log_ = log;
93 use_counts_ = use_counts; 91 use_counts_ = use_counts;
94 DCHECK(!track_unresolved_variables_); 92 DCHECK(!track_unresolved_variables_);
95 track_unresolved_variables_ = is_inner_function; 93 track_unresolved_variables_ = is_inner_function;
96 94
97 // The caller passes the function_scope which is not yet inserted into the 95 // The caller passes the function_scope which is not yet inserted into the
98 // scope_state_. All scopes above the function_scope are ignored by the 96 // scope_state_. All scopes above the function_scope are ignored by the
99 // PreParser. 97 // PreParser.
100 DCHECK_NULL(scope_state_); 98 DCHECK_NULL(scope_state_);
101 FunctionState function_state(&function_state_, &scope_state_, function_scope); 99 FunctionState function_state(&function_state_, &scope_state_, function_scope);
102 // This indirection is needed so that we can use the CHECK_OK macros. 100 // This indirection is needed so that we can use the CHECK_OK macros.
(...skipping 26 matching lines...) Expand all
129 LazyParsingResult result = ParseStatementListAndLogFunction( 127 LazyParsingResult result = ParseStatementListAndLogFunction(
130 function_scope->start_position(), &formals, has_duplicate_parameters, 128 function_scope->start_position(), &formals, has_duplicate_parameters,
131 may_abort, ok); 129 may_abort, ok);
132 use_counts_ = nullptr; 130 use_counts_ = nullptr;
133 track_unresolved_variables_ = false; 131 track_unresolved_variables_ = false;
134 if (result == kLazyParsingAborted) { 132 if (result == kLazyParsingAborted) {
135 return kPreParseAbort; 133 return kPreParseAbort;
136 } else if (stack_overflow()) { 134 } else if (stack_overflow()) {
137 return kPreParseStackOverflow; 135 return kPreParseStackOverflow;
138 } else if (!*ok) { 136 } else if (!*ok) {
139 DCHECK(log->has_error()); 137 DCHECK(log_.has_error());
140 } else { 138 } else {
141 DCHECK_EQ(Token::RBRACE, scanner()->peek()); 139 DCHECK_EQ(Token::RBRACE, scanner()->peek());
142 140
143 if (!IsArrowFunction(kind)) { 141 if (!IsArrowFunction(kind)) {
144 // Validate parameter names. We can do this only after parsing the 142 // Validate parameter names. We can do this only after parsing the
145 // function, since the function can declare itself strict. 143 // function, since the function can declare itself strict.
146 const bool allow_duplicate_parameters = 144 const bool allow_duplicate_parameters =
147 is_sloppy(function_scope->language_mode()) && formals.is_simple && 145 is_sloppy(function_scope->language_mode()) && formals.is_simple &&
148 !IsConciseMethod(kind); 146 !IsConciseMethod(kind);
149 ValidateFormalParameters(function_scope->language_mode(), 147 ValidateFormalParameters(function_scope->language_mode(),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 PreParserStatementList body; 238 PreParserStatementList body;
241 LazyParsingResult result = ParseStatementList( 239 LazyParsingResult result = ParseStatementList(
242 body, Token::RBRACE, may_abort, CHECK_OK_VALUE(kLazyParsingComplete)); 240 body, Token::RBRACE, may_abort, CHECK_OK_VALUE(kLazyParsingComplete));
243 if (result == kLazyParsingAborted) return result; 241 if (result == kLazyParsingAborted) return result;
244 242
245 // Position right after terminal '}'. 243 // Position right after terminal '}'.
246 DCHECK_EQ(Token::RBRACE, scanner()->peek()); 244 DCHECK_EQ(Token::RBRACE, scanner()->peek());
247 int body_end = scanner()->peek_location().end_pos; 245 int body_end = scanner()->peek_location().end_pos;
248 DeclarationScope* scope = this->scope()->AsDeclarationScope(); 246 DeclarationScope* scope = this->scope()->AsDeclarationScope();
249 DCHECK(scope->is_function_scope()); 247 DCHECK(scope->is_function_scope());
250 log_->LogFunction(start_position, body_end, formals->num_parameters(), 248 log_.LogFunction(start_position, body_end, formals->num_parameters(),
251 formals->function_length, has_duplicate_parameters, 249 formals->function_length, has_duplicate_parameters,
252 function_state_->materialized_literal_count(), 250 function_state_->materialized_literal_count(),
253 function_state_->expected_property_count(), language_mode(), 251 function_state_->expected_property_count(), language_mode(),
254 scope->uses_super_property(), scope->calls_eval()); 252 scope->uses_super_property(), scope->calls_eval());
255 return kLazyParsingComplete; 253 return kLazyParsingComplete;
256 } 254 }
257 255
258 PreParserExpression PreParser::ExpressionFromIdentifier( 256 PreParserExpression PreParser::ExpressionFromIdentifier(
259 PreParserIdentifier name, int start_position, InferName infer) { 257 PreParserIdentifier name, int start_position, InferName infer) {
260 if (track_unresolved_variables_) { 258 if (track_unresolved_variables_) {
261 AstNodeFactory factory(ast_value_factory()); 259 AstNodeFactory factory(ast_value_factory());
262 // Setting the Zone is necessary because zone_ might be the temp Zone, and 260 // Setting the Zone is necessary because zone_ might be the temp Zone, and
263 // AstValueFactory doesn't know about it. 261 // AstValueFactory doesn't know about it.
264 factory.set_zone(zone()); 262 factory.set_zone(zone());
(...skipping 29 matching lines...) Expand all
294 } 292 }
295 } 293 }
296 } 294 }
297 295
298 #undef CHECK_OK 296 #undef CHECK_OK
299 #undef CHECK_OK_CUSTOM 297 #undef CHECK_OK_CUSTOM
300 298
301 299
302 } // namespace internal 300 } // namespace internal
303 } // namespace v8 301 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698