Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 bool is_inner_function, bool may_abort, int* use_counts) { | 88 bool is_inner_function, bool may_abort, int* use_counts) { |
| 89 DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type()); | 89 DCHECK_EQ(FUNCTION_SCOPE, function_scope->scope_type()); |
| 90 parsing_module_ = parsing_module; | 90 parsing_module_ = parsing_module; |
| 91 use_counts_ = use_counts; | 91 use_counts_ = use_counts; |
| 92 DCHECK(!track_unresolved_variables_); | 92 DCHECK(!track_unresolved_variables_); |
| 93 track_unresolved_variables_ = is_inner_function; | 93 track_unresolved_variables_ = is_inner_function; |
| 94 | 94 |
| 95 ResetFunctionLiteralId(); | |
|
marja
2016/11/25 13:14:56
Had to think a bit about this... so this is becaus
jochen (gone - plz use gerrit)
2016/11/28 08:12:07
done
| |
| 96 | |
| 95 // The caller passes the function_scope which is not yet inserted into the | 97 // The caller passes the function_scope which is not yet inserted into the |
| 96 // scope_state_. All scopes above the function_scope are ignored by the | 98 // scope_state_. All scopes above the function_scope are ignored by the |
| 97 // PreParser. | 99 // PreParser. |
| 98 DCHECK_NULL(scope_state_); | 100 DCHECK_NULL(scope_state_); |
| 99 FunctionState function_state(&function_state_, &scope_state_, function_scope); | 101 FunctionState function_state(&function_state_, &scope_state_, function_scope); |
| 100 // This indirection is needed so that we can use the CHECK_OK macros. | 102 // This indirection is needed so that we can use the CHECK_OK macros. |
| 101 bool ok_holder = true; | 103 bool ok_holder = true; |
| 102 bool* ok = &ok_holder; | 104 bool* ok = &ok_holder; |
| 103 | 105 |
| 104 PreParserFormalParameters formals(function_scope); | 106 PreParserFormalParameters formals(function_scope); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 runtime_call_stats_, | 190 runtime_call_stats_, |
| 189 counters[track_unresolved_variables_][parsing_on_main_thread_]); | 191 counters[track_unresolved_variables_][parsing_on_main_thread_]); |
| 190 | 192 |
| 191 // Parse function body. | 193 // Parse function body. |
| 192 PreParserStatementList body; | 194 PreParserStatementList body; |
| 193 DeclarationScope* function_scope = NewFunctionScope(kind); | 195 DeclarationScope* function_scope = NewFunctionScope(kind); |
| 194 function_scope->SetLanguageMode(language_mode); | 196 function_scope->SetLanguageMode(language_mode); |
| 195 FunctionState function_state(&function_state_, &scope_state_, function_scope); | 197 FunctionState function_state(&function_state_, &scope_state_, function_scope); |
| 196 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 198 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
| 197 ExpressionClassifier formals_classifier(this, &duplicate_finder); | 199 ExpressionClassifier formals_classifier(this, &duplicate_finder); |
| 200 GetNextFunctionLiteralId(); | |
| 198 | 201 |
| 199 Expect(Token::LPAREN, CHECK_OK); | 202 Expect(Token::LPAREN, CHECK_OK); |
| 200 int start_position = scanner()->location().beg_pos; | 203 int start_position = scanner()->location().beg_pos; |
| 201 function_scope->set_start_position(start_position); | 204 function_scope->set_start_position(start_position); |
| 202 PreParserFormalParameters formals(function_scope); | 205 PreParserFormalParameters formals(function_scope); |
| 203 ParseFormalParameterList(&formals, CHECK_OK); | 206 ParseFormalParameterList(&formals, CHECK_OK); |
| 204 Expect(Token::RPAREN, CHECK_OK); | 207 Expect(Token::RPAREN, CHECK_OK); |
| 205 int formals_end_position = scanner()->location().end_pos; | 208 int formals_end_position = scanner()->location().end_pos; |
| 206 | 209 |
| 207 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position, | 210 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 bool may_abort, bool* ok) { | 247 bool may_abort, bool* ok) { |
| 245 PreParserStatementList body; | 248 PreParserStatementList body; |
| 246 LazyParsingResult result = ParseStatementList( | 249 LazyParsingResult result = ParseStatementList( |
| 247 body, Token::RBRACE, may_abort, CHECK_OK_VALUE(kLazyParsingComplete)); | 250 body, Token::RBRACE, may_abort, CHECK_OK_VALUE(kLazyParsingComplete)); |
| 248 if (result == kLazyParsingAborted) return result; | 251 if (result == kLazyParsingAborted) return result; |
| 249 | 252 |
| 250 // Position right after terminal '}'. | 253 // Position right after terminal '}'. |
| 251 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 254 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
| 252 int body_end = scanner()->peek_location().end_pos; | 255 int body_end = scanner()->peek_location().end_pos; |
| 253 DCHECK(this->scope()->is_function_scope()); | 256 DCHECK(this->scope()->is_function_scope()); |
| 254 log_.LogFunction(body_end, formals->num_parameters(), | 257 log_.LogFunction( |
| 255 formals->function_length, has_duplicate_parameters, | 258 body_end, formals->num_parameters(), formals->function_length, |
| 256 function_state_->materialized_literal_count(), | 259 has_duplicate_parameters, function_state_->materialized_literal_count(), |
| 257 function_state_->expected_property_count()); | 260 function_state_->expected_property_count(), GetLastFunctionLiteralId()); |
| 258 return kLazyParsingComplete; | 261 return kLazyParsingComplete; |
| 259 } | 262 } |
| 260 | 263 |
| 261 PreParserExpression PreParser::ExpressionFromIdentifier( | 264 PreParserExpression PreParser::ExpressionFromIdentifier( |
| 262 PreParserIdentifier name, int start_position, InferName infer) { | 265 PreParserIdentifier name, int start_position, InferName infer) { |
| 263 if (track_unresolved_variables_) { | 266 if (track_unresolved_variables_) { |
| 264 AstNodeFactory factory(ast_value_factory()); | 267 AstNodeFactory factory(ast_value_factory()); |
| 265 // Setting the Zone is necessary because zone_ might be the temp Zone, and | 268 // Setting the Zone is necessary because zone_ might be the temp Zone, and |
| 266 // AstValueFactory doesn't know about it. | 269 // AstValueFactory doesn't know about it. |
| 267 factory.set_zone(zone()); | 270 factory.set_zone(zone()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 297 } | 300 } |
| 298 } | 301 } |
| 299 } | 302 } |
| 300 | 303 |
| 301 #undef CHECK_OK | 304 #undef CHECK_OK |
| 302 #undef CHECK_OK_CUSTOM | 305 #undef CHECK_OK_CUSTOM |
| 303 | 306 |
| 304 | 307 |
| 305 } // namespace internal | 308 } // namespace internal |
| 306 } // namespace v8 | 309 } // namespace v8 |
| OLD | NEW |