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

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

Issue 2268333002: Move scope_uses_super_property_ to DeclarationScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 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 | « src/ast/scopes.cc ('k') | src/parsing/preparser.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 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 4390 matching lines...) Expand 10 before | Expand all | Expand 10 after
4401 language_mode(), CHECK_OK); 4401 language_mode(), CHECK_OK);
4402 } 4402 }
4403 4403
4404 void Parser::SkipLazyFunctionBody(int* materialized_literal_count, 4404 void Parser::SkipLazyFunctionBody(int* materialized_literal_count,
4405 int* expected_property_count, bool* ok, 4405 int* expected_property_count, bool* ok,
4406 Scanner::BookmarkScope* bookmark) { 4406 Scanner::BookmarkScope* bookmark) {
4407 DCHECK_IMPLIES(bookmark, bookmark->HasBeenSet()); 4407 DCHECK_IMPLIES(bookmark, bookmark->HasBeenSet());
4408 if (produce_cached_parse_data()) CHECK(log_); 4408 if (produce_cached_parse_data()) CHECK(log_);
4409 4409
4410 int function_block_pos = position(); 4410 int function_block_pos = position();
4411 DeclarationScope* scope = this->scope()->AsDeclarationScope();
4412 DCHECK(scope->is_function_scope());
4411 if (consume_cached_parse_data() && !cached_parse_data_->rejected()) { 4413 if (consume_cached_parse_data() && !cached_parse_data_->rejected()) {
4412 // If we have cached data, we use it to skip parsing the function body. The 4414 // If we have cached data, we use it to skip parsing the function body. The
4413 // data contains the information we need to construct the lazy function. 4415 // data contains the information we need to construct the lazy function.
4414 FunctionEntry entry = 4416 FunctionEntry entry =
4415 cached_parse_data_->GetFunctionEntry(function_block_pos); 4417 cached_parse_data_->GetFunctionEntry(function_block_pos);
4416 // Check that cached data is valid. If not, mark it as invalid (the embedder 4418 // Check that cached data is valid. If not, mark it as invalid (the embedder
4417 // handles it). Note that end position greater than end of stream is safe, 4419 // handles it). Note that end position greater than end of stream is safe,
4418 // and hard to check. 4420 // and hard to check.
4419 if (entry.is_valid() && entry.end_pos() > function_block_pos) { 4421 if (entry.is_valid() && entry.end_pos() > function_block_pos) {
4420 scanner()->SeekForward(entry.end_pos() - 1); 4422 scanner()->SeekForward(entry.end_pos() - 1);
4421 4423
4422 scope()->set_end_position(entry.end_pos()); 4424 scope->set_end_position(entry.end_pos());
4423 Expect(Token::RBRACE, CHECK_OK_VOID); 4425 Expect(Token::RBRACE, CHECK_OK_VOID);
4424 total_preparse_skipped_ += scope()->end_position() - function_block_pos; 4426 total_preparse_skipped_ += scope->end_position() - function_block_pos;
4425 *materialized_literal_count = entry.literal_count(); 4427 *materialized_literal_count = entry.literal_count();
4426 *expected_property_count = entry.property_count(); 4428 *expected_property_count = entry.property_count();
4427 SetLanguageMode(scope(), entry.language_mode()); 4429 SetLanguageMode(scope, entry.language_mode());
4428 if (entry.uses_super_property()) scope()->RecordSuperPropertyUsage(); 4430 if (entry.uses_super_property()) scope->RecordSuperPropertyUsage();
4429 if (entry.calls_eval()) scope()->RecordEvalCall(); 4431 if (entry.calls_eval()) scope->RecordEvalCall();
4430 return; 4432 return;
4431 } 4433 }
4432 cached_parse_data_->Reject(); 4434 cached_parse_data_->Reject();
4433 } 4435 }
4434 // With no cached data, we partially parse the function, without building an 4436 // With no cached data, we partially parse the function, without building an
4435 // AST. This gathers the data needed to build a lazy function. 4437 // AST. This gathers the data needed to build a lazy function.
4436 SingletonLogger logger; 4438 SingletonLogger logger;
4437 PreParser::PreParseResult result = 4439 PreParser::PreParseResult result =
4438 ParseLazyFunctionBodyWithPreParser(&logger, bookmark); 4440 ParseLazyFunctionBodyWithPreParser(&logger, bookmark);
4439 if (bookmark && bookmark->HasBeenReset()) { 4441 if (bookmark && bookmark->HasBeenReset()) {
4440 return; // Return immediately if pre-parser devided to abort parsing. 4442 return; // Return immediately if pre-parser devided to abort parsing.
4441 } 4443 }
4442 if (result == PreParser::kPreParseStackOverflow) { 4444 if (result == PreParser::kPreParseStackOverflow) {
4443 // Propagate stack overflow. 4445 // Propagate stack overflow.
4444 set_stack_overflow(); 4446 set_stack_overflow();
4445 *ok = false; 4447 *ok = false;
4446 return; 4448 return;
4447 } 4449 }
4448 if (logger.has_error()) { 4450 if (logger.has_error()) {
4449 ReportMessageAt(Scanner::Location(logger.start(), logger.end()), 4451 ReportMessageAt(Scanner::Location(logger.start(), logger.end()),
4450 logger.message(), logger.argument_opt(), 4452 logger.message(), logger.argument_opt(),
4451 logger.error_type()); 4453 logger.error_type());
4452 *ok = false; 4454 *ok = false;
4453 return; 4455 return;
4454 } 4456 }
4455 scope()->set_end_position(logger.end()); 4457 scope->set_end_position(logger.end());
4456 Expect(Token::RBRACE, CHECK_OK_VOID); 4458 Expect(Token::RBRACE, CHECK_OK_VOID);
4457 total_preparse_skipped_ += scope()->end_position() - function_block_pos; 4459 total_preparse_skipped_ += scope->end_position() - function_block_pos;
4458 *materialized_literal_count = logger.literals(); 4460 *materialized_literal_count = logger.literals();
4459 *expected_property_count = logger.properties(); 4461 *expected_property_count = logger.properties();
4460 SetLanguageMode(scope(), logger.language_mode()); 4462 SetLanguageMode(scope, logger.language_mode());
4461 if (logger.uses_super_property()) { 4463 if (logger.uses_super_property()) scope->RecordSuperPropertyUsage();
4462 scope()->RecordSuperPropertyUsage(); 4464 if (logger.calls_eval()) scope->RecordEvalCall();
4463 }
4464 if (logger.calls_eval()) {
4465 scope()->RecordEvalCall();
4466 }
4467 if (produce_cached_parse_data()) { 4465 if (produce_cached_parse_data()) {
4468 DCHECK(log_); 4466 DCHECK(log_);
4469 // Position right after terminal '}'. 4467 // Position right after terminal '}'.
4470 int body_end = scanner()->location().end_pos; 4468 int body_end = scanner()->location().end_pos;
4471 log_->LogFunction(function_block_pos, body_end, *materialized_literal_count, 4469 log_->LogFunction(function_block_pos, body_end, *materialized_literal_count,
4472 *expected_property_count, language_mode(), 4470 *expected_property_count, language_mode(),
4473 scope()->uses_super_property(), scope()->calls_eval()); 4471 scope->uses_super_property(), scope->calls_eval());
4474 } 4472 }
4475 } 4473 }
4476 4474
4477 4475
4478 Statement* Parser::BuildAssertIsCoercible(Variable* var) { 4476 Statement* Parser::BuildAssertIsCoercible(Variable* var) {
4479 // if (var === null || var === undefined) 4477 // if (var === null || var === undefined)
4480 // throw /* type error kNonCoercible) */; 4478 // throw /* type error kNonCoercible) */;
4481 4479
4482 Expression* condition = factory()->NewBinaryOperation( 4480 Expression* condition = factory()->NewBinaryOperation(
4483 Token::OR, 4481 Token::OR,
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after
6918 node->Print(Isolate::Current()); 6916 node->Print(Isolate::Current());
6919 } 6917 }
6920 #endif // DEBUG 6918 #endif // DEBUG
6921 6919
6922 #undef CHECK_OK 6920 #undef CHECK_OK
6923 #undef CHECK_OK_VOID 6921 #undef CHECK_OK_VOID
6924 #undef CHECK_FAILED 6922 #undef CHECK_FAILED
6925 6923
6926 } // namespace internal 6924 } // namespace internal
6927 } // namespace v8 6925 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698