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

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

Issue 2306413002: Fully deserialize the scope chain after parsing, not before (Closed)
Patch Set: updates 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
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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 556 }
557 557
558 return factory()->NewCallRuntime(context_index, args, pos); 558 return factory()->NewCallRuntime(context_index, args, pos);
559 } 559 }
560 560
561 Parser::Parser(ParseInfo* info) 561 Parser::Parser(ParseInfo* info)
562 : ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(), 562 : ParserBase<Parser>(info->zone(), &scanner_, info->stack_limit(),
563 info->extension(), info->ast_value_factory(), NULL), 563 info->extension(), info->ast_value_factory(), NULL),
564 scanner_(info->unicode_cache()), 564 scanner_(info->unicode_cache()),
565 reusable_preparser_(NULL), 565 reusable_preparser_(NULL),
566 original_scope_(NULL),
567 target_stack_(NULL), 566 target_stack_(NULL),
568 compile_options_(info->compile_options()), 567 compile_options_(info->compile_options()),
569 cached_parse_data_(NULL), 568 cached_parse_data_(NULL),
570 total_preparse_skipped_(0), 569 total_preparse_skipped_(0),
571 pre_parse_timer_(NULL), 570 pre_parse_timer_(NULL),
572 parsing_on_main_thread_(true) { 571 parsing_on_main_thread_(true) {
573 // Even though we were passed ParseInfo, we should not store it in 572 // Even though we were passed ParseInfo, we should not store it in
574 // Parser - this makes sure that Isolate is not accidentally accessed via 573 // Parser - this makes sure that Isolate is not accidentally accessed via
575 // ParseInfo during background parsing. 574 // ParseInfo during background parsing.
576 DCHECK(!info->script().is_null() || info->source_stream() != nullptr || 575 DCHECK(!info->script().is_null() || info->source_stream() != nullptr ||
(...skipping 16 matching lines...) Expand all
593 } 592 }
594 if (info->ast_value_factory() == NULL) { 593 if (info->ast_value_factory() == NULL) {
595 // info takes ownership of AstValueFactory. 594 // info takes ownership of AstValueFactory.
596 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed())); 595 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed()));
597 info->set_ast_value_factory_owned(); 596 info->set_ast_value_factory_owned();
598 ast_value_factory_ = info->ast_value_factory(); 597 ast_value_factory_ = info->ast_value_factory();
599 ast_node_factory_.set_ast_value_factory(ast_value_factory_); 598 ast_node_factory_.set_ast_value_factory(ast_value_factory_);
600 } 599 }
601 } 600 }
602 601
603 void Parser::DeserializeScopeChain( 602 void Parser::InspectScopeChain(ParseInfo* info,
604 ParseInfo* info, Handle<Context> context, 603 MaybeHandle<ScopeInfo> maybe_outer_scope) {
605 Scope::DeserializationMode deserialization_mode) {
606 DCHECK(ThreadId::Current().Equals(info->isolate()->thread_id())); 604 DCHECK(ThreadId::Current().Equals(info->isolate()->thread_id()));
607 // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native 605 // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native
608 // context, which will have the "this" binding for script scopes. 606 // context, which will have the "this" binding for script scopes.
609 DeclarationScope* script_scope = NewScriptScope(); 607 DeclarationScope* script_scope = NewScriptScope();
610 info->set_script_scope(script_scope); 608 info->set_script_scope(script_scope);
611 Scope* scope = script_scope; 609 Handle<ScopeInfo> outer_scope;
612 if (!context.is_null() && !context->IsNativeContext()) { 610 if (maybe_outer_scope.ToHandle(&outer_scope)) {
613 scope = Scope::DeserializeScopeChain(info->isolate(), zone(), *context, 611 if (outer_scope->scope_type() != SCRIPT_SCOPE) {
614 script_scope, ast_value_factory(), 612 info->set_allow_lazy_parsing(false);
615 deserialization_mode); 613 }
616 DCHECK(!info->is_module() || scope->is_module_scope()); 614 Handle<ScopeInfo> receiver_scope = outer_scope;
617 if (info->context().is_null()) { 615 while (receiver_scope->scope_type() != SCRIPT_SCOPE &&
618 DCHECK(deserialization_mode == 616 (receiver_scope->scope_type() != FUNCTION_SCOPE ||
619 Scope::DeserializationMode::kDeserializeOffHeap); 617 IsArrowFunction(receiver_scope->function_kind()))) {
620 } else { 618 if (!receiver_scope->HasOuterScopeInfo()) {
621 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this 619 receiver_scope = Handle<ScopeInfo>::null();
622 // means the Parser cannot operate independent of the V8 heap. Tell the 620 break;
623 // string table to internalize strings and values right after they're 621 }
624 // created. This kind of parsing can only be done in the main thread. 622 receiver_scope = Handle<ScopeInfo>(receiver_scope->OuterScopeInfo());
625 DCHECK(parsing_on_main_thread_); 623 }
626 ast_value_factory()->Internalize(info->isolate()); 624 if (!receiver_scope.is_null()) {
625 outermost_receiver_function_kind_ = receiver_scope->function_kind();
626 outermost_receiver_scope_type_ = receiver_scope->scope_type();
627 } 627 }
628 } 628 }
629 original_scope_ = scope;
630 } 629 }
631 630
632 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { 631 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
633 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, 632 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here,
634 // see comment for HistogramTimerScope class. 633 // see comment for HistogramTimerScope class.
635 634
636 // It's OK to use the Isolate & counters here, since this function is only 635 // It's OK to use the Isolate & counters here, since this function is only
637 // called in the main thread. 636 // called in the main thread.
638 DCHECK(parsing_on_main_thread_); 637 DCHECK(parsing_on_main_thread_);
639 638
(...skipping 10 matching lines...) Expand all
650 649
651 // Initialize parser state. 650 // Initialize parser state.
652 CompleteParserRecorder recorder; 651 CompleteParserRecorder recorder;
653 652
654 if (produce_cached_parse_data()) { 653 if (produce_cached_parse_data()) {
655 log_ = &recorder; 654 log_ = &recorder;
656 } else if (consume_cached_parse_data()) { 655 } else if (consume_cached_parse_data()) {
657 cached_parse_data_->Initialize(); 656 cached_parse_data_->Initialize();
658 } 657 }
659 658
660 DeserializeScopeChain(info, info->context(), 659 InspectScopeChain(
661 Scope::DeserializationMode::kKeepScopeInfo); 660 info,
661 info->context().is_null() || info->context()->IsNativeContext()
662 ? MaybeHandle<ScopeInfo>()
663 : MaybeHandle<ScopeInfo>(info->context()->scope_info(), isolate));
662 664
663 source = String::Flatten(source); 665 source = String::Flatten(source);
664 FunctionLiteral* result; 666 FunctionLiteral* result;
665 667
666 { 668 {
667 std::unique_ptr<Utf16CharacterStream> stream; 669 std::unique_ptr<Utf16CharacterStream> stream;
668 if (source->IsExternalTwoByteString()) { 670 if (source->IsExternalTwoByteString()) {
669 stream.reset(new ExternalTwoByteStringUtf16CharacterStream( 671 stream.reset(new ExternalTwoByteStringUtf16CharacterStream(
670 Handle<ExternalTwoByteString>::cast(source), 0, source->length())); 672 Handle<ExternalTwoByteString>::cast(source), 0, source->length()));
671 } else if (source->IsExternalOneByteString()) { 673 } else if (source->IsExternalOneByteString()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 // background thread. We should not access anything Isolate / heap dependent 711 // background thread. We should not access anything Isolate / heap dependent
710 // via ParseInfo, and also not pass it forward. 712 // via ParseInfo, and also not pass it forward.
711 DCHECK_NULL(scope_state_); 713 DCHECK_NULL(scope_state_);
712 DCHECK_NULL(target_stack_); 714 DCHECK_NULL(target_stack_);
713 715
714 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; 716 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY;
715 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; 717 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY;
716 718
717 FunctionLiteral* result = NULL; 719 FunctionLiteral* result = NULL;
718 { 720 {
719 Scope* outer = original_scope_; 721 Scope* outer = info->script_scope();
720 DCHECK_NOT_NULL(outer); 722 DCHECK_NOT_NULL(outer);
721 if (info->is_eval()) { 723 if (info->is_eval()) {
722 if (!outer->is_script_scope() || is_strict(info->language_mode())) { 724 if (is_strict(info->language_mode())) {
723 parsing_mode = PARSE_EAGERLY; 725 parsing_mode = PARSE_EAGERLY;
724 } 726 }
725 outer = NewEvalScope(outer); 727 outer = NewEvalScope(outer);
726 } else if (info->is_module()) { 728 } else if (info->is_module()) {
727 DCHECK_EQ(outer, info->script_scope()); 729 DCHECK_EQ(outer, info->script_scope());
728 outer = NewModuleScope(info->script_scope()); 730 outer = NewModuleScope(info->script_scope());
729 } 731 }
730 732
731 DeclarationScope* scope = outer->AsDeclarationScope(); 733 DeclarationScope* scope = outer->AsDeclarationScope();
732 734
(...skipping 27 matching lines...) Expand all
760 if (ok && is_strict(language_mode())) { 762 if (ok && is_strict(language_mode())) {
761 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 763 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
762 CheckDecimalLiteralWithLeadingZero(beg_pos, 764 CheckDecimalLiteralWithLeadingZero(beg_pos,
763 scanner()->location().end_pos); 765 scanner()->location().end_pos);
764 } 766 }
765 if (ok && is_sloppy(language_mode())) { 767 if (ok && is_sloppy(language_mode())) {
766 // TODO(littledan): Function bindings on the global object that modify 768 // TODO(littledan): Function bindings on the global object that modify
767 // pre-existing bindings should be made writable, enumerable and 769 // pre-existing bindings should be made writable, enumerable and
768 // nonconfigurable if possible, whereas this code will leave attributes 770 // nonconfigurable if possible, whereas this code will leave attributes
769 // unchanged if the property already exists. 771 // unchanged if the property already exists.
770 InsertSloppyBlockFunctionVarBindings(scope, &ok); 772 scope->HoistSloppyBlockFunctions(factory(), &ok);
771 } 773 }
772 if (ok) { 774 if (ok) {
773 CheckConflictingVarDeclarations(scope, &ok); 775 CheckConflictingVarDeclarations(scope, &ok);
774 } 776 }
775 777
776 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { 778 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
777 if (body->length() != 1 || 779 if (body->length() != 1 ||
778 !body->at(0)->IsExpressionStatement() || 780 !body->at(0)->IsExpressionStatement() ||
779 !body->at(0)->AsExpressionStatement()-> 781 !body->at(0)->AsExpressionStatement()->
780 expression()->IsFunctionLiteral()) { 782 expression()->IsFunctionLiteral()) {
(...skipping 24 matching lines...) Expand all
805 RuntimeCallTimerScope runtime_timer(isolate, &RuntimeCallStats::ParseLazy); 807 RuntimeCallTimerScope runtime_timer(isolate, &RuntimeCallStats::ParseLazy);
806 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy()); 808 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy());
807 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseLazy"); 809 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.ParseLazy");
808 Handle<String> source(String::cast(info->script()->source())); 810 Handle<String> source(String::cast(info->script()->source()));
809 isolate->counters()->total_parse_size()->Increment(source->length()); 811 isolate->counters()->total_parse_size()->Increment(source->length());
810 base::ElapsedTimer timer; 812 base::ElapsedTimer timer;
811 if (FLAG_trace_parse) { 813 if (FLAG_trace_parse) {
812 timer.Start(); 814 timer.Start();
813 } 815 }
814 Handle<SharedFunctionInfo> shared_info = info->shared_info(); 816 Handle<SharedFunctionInfo> shared_info = info->shared_info();
815 DeserializeScopeChain(info, info->context(), 817 InspectScopeChain(
816 Scope::DeserializationMode::kKeepScopeInfo); 818 info,
819 info->context().is_null() || info->context()->IsNativeContext()
820 ? MaybeHandle<ScopeInfo>()
821 : MaybeHandle<ScopeInfo>(info->context()->scope_info(), isolate));
817 822
818 // Initialize parser state. 823 // Initialize parser state.
819 source = String::Flatten(source); 824 source = String::Flatten(source);
820 FunctionLiteral* result; 825 FunctionLiteral* result;
821 { 826 {
822 std::unique_ptr<Utf16CharacterStream> stream; 827 std::unique_ptr<Utf16CharacterStream> stream;
823 if (source->IsExternalTwoByteString()) { 828 if (source->IsExternalTwoByteString()) {
824 stream.reset(new ExternalTwoByteStringUtf16CharacterStream( 829 stream.reset(new ExternalTwoByteStringUtf16CharacterStream(
825 Handle<ExternalTwoByteString>::cast(source), 830 Handle<ExternalTwoByteString>::cast(source),
826 shared_info->start_position(), shared_info->end_position())); 831 shared_info->start_position(), shared_info->end_position()));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); 877 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
873 fni_->PushEnclosingName(raw_name); 878 fni_->PushEnclosingName(raw_name);
874 879
875 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); 880 ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
876 881
877 // Place holder for the result. 882 // Place holder for the result.
878 FunctionLiteral* result = nullptr; 883 FunctionLiteral* result = nullptr;
879 884
880 { 885 {
881 // Parse the function literal. 886 // Parse the function literal.
882 Scope* outer = original_scope_; 887 Scope* outer = info->script_scope();
883 DCHECK(outer); 888 DCHECK(outer);
884 FunctionState function_state(&function_state_, &scope_state_, outer, 889 FunctionState function_state(&function_state_, &scope_state_, outer,
885 info->function_kind()); 890 info->function_kind());
886 DCHECK(is_sloppy(outer->language_mode()) ||
887 is_strict(info->language_mode()));
888 FunctionLiteral::FunctionType function_type = ComputeFunctionType(info); 891 FunctionLiteral::FunctionType function_type = ComputeFunctionType(info);
889 bool ok = true; 892 bool ok = true;
890 893
891 if (info->is_arrow()) { 894 if (info->is_arrow()) {
892 bool is_async = allow_harmony_async_await() && info->is_async(); 895 bool is_async = allow_harmony_async_await() && info->is_async();
893 if (is_async) { 896 if (is_async) {
894 DCHECK(!scanner()->HasAnyLineTerminatorAfterNext()); 897 DCHECK(!scanner()->HasAnyLineTerminatorAfterNext());
895 if (!Check(Token::ASYNC)) { 898 if (!Check(Token::ASYNC)) {
896 CHECK(stack_overflow()); 899 CHECK(stack_overflow());
897 return nullptr; 900 return nullptr;
(...skipping 3113 matching lines...) Expand 10 before | Expand all | Expand 10 after
4011 4014
4012 if (!parameters.is_simple) { 4015 if (!parameters.is_simple) {
4013 DCHECK_NOT_NULL(inner_scope); 4016 DCHECK_NOT_NULL(inner_scope);
4014 DCHECK_EQ(function_scope, scope()); 4017 DCHECK_EQ(function_scope, scope());
4015 DCHECK_EQ(function_scope, inner_scope->outer_scope()); 4018 DCHECK_EQ(function_scope, inner_scope->outer_scope());
4016 DCHECK_EQ(body, inner_block->statements()); 4019 DCHECK_EQ(body, inner_block->statements());
4017 SetLanguageMode(function_scope, inner_scope->language_mode()); 4020 SetLanguageMode(function_scope, inner_scope->language_mode());
4018 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); 4021 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK);
4019 4022
4020 if (is_sloppy(inner_scope->language_mode())) { 4023 if (is_sloppy(inner_scope->language_mode())) {
4021 InsertSloppyBlockFunctionVarBindings(inner_scope, CHECK_OK); 4024 inner_scope->HoistSloppyBlockFunctions(factory(), CHECK_OK);
4022 } 4025 }
4023 4026
4024 // TODO(littledan): Merge the two rejection blocks into one 4027 // TODO(littledan): Merge the two rejection blocks into one
4025 if (IsAsyncFunction(kind)) { 4028 if (IsAsyncFunction(kind)) {
4026 init_block = BuildRejectPromiseOnException(init_block, CHECK_OK); 4029 init_block = BuildRejectPromiseOnException(init_block, CHECK_OK);
4027 } 4030 }
4028 4031
4029 DCHECK_NOT_NULL(init_block); 4032 DCHECK_NOT_NULL(init_block);
4030 4033
4031 inner_scope->set_end_position(scanner()->location().end_pos); 4034 inner_scope->set_end_position(scanner()->location().end_pos);
4032 if (inner_scope->FinalizeBlockScope() != nullptr) { 4035 if (inner_scope->FinalizeBlockScope() != nullptr) {
4033 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); 4036 CheckConflictingVarDeclarations(inner_scope, CHECK_OK);
4034 InsertShadowingVarBindingInitializers(inner_block); 4037 InsertShadowingVarBindingInitializers(inner_block);
4035 } 4038 }
4036 inner_scope = nullptr; 4039 inner_scope = nullptr;
4037 4040
4038 result->Add(init_block, zone()); 4041 result->Add(init_block, zone());
4039 result->Add(inner_block, zone()); 4042 result->Add(inner_block, zone());
4040 } else { 4043 } else {
4041 DCHECK_EQ(inner_scope, function_scope); 4044 DCHECK_EQ(inner_scope, function_scope);
4042 if (is_sloppy(function_scope->language_mode())) { 4045 if (is_sloppy(function_scope->language_mode())) {
4043 InsertSloppyBlockFunctionVarBindings(function_scope, CHECK_OK); 4046 function_scope->HoistSloppyBlockFunctions(factory(), CHECK_OK);
4044 } 4047 }
4045 } 4048 }
4046 4049
4047 if (function_type == FunctionLiteral::kNamedExpression) { 4050 if (function_type == FunctionLiteral::kNamedExpression) {
4048 // Now that we know the language mode, we can create the const assignment 4051 // Now that we know the language mode, we can create the const assignment
4049 // in the previously reserved spot. 4052 // in the previously reserved spot.
4050 DCHECK_EQ(function_scope, scope()); 4053 DCHECK_EQ(function_scope, scope());
4051 Variable* fvar = function_scope->DeclareFunctionVar(function_name); 4054 Variable* fvar = function_scope->DeclareFunctionVar(function_name);
4052 VariableProxy* fproxy = factory()->NewVariableProxy(fvar); 4055 VariableProxy* fproxy = factory()->NewVariableProxy(fvar);
4053 result->Set(kFunctionNameAssignmentIndex, 4056 result->Set(kFunctionNameAssignmentIndex,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4251 VariableProxy* to = NewUnresolved(name); 4254 VariableProxy* to = NewUnresolved(name);
4252 VariableProxy* from = factory()->NewVariableProxy(parameter); 4255 VariableProxy* from = factory()->NewVariableProxy(parameter);
4253 Expression* assignment = 4256 Expression* assignment =
4254 factory()->NewAssignment(Token::ASSIGN, to, from, kNoSourcePosition); 4257 factory()->NewAssignment(Token::ASSIGN, to, from, kNoSourcePosition);
4255 Statement* statement = 4258 Statement* statement =
4256 factory()->NewExpressionStatement(assignment, kNoSourcePosition); 4259 factory()->NewExpressionStatement(assignment, kNoSourcePosition);
4257 inner_block->statements()->InsertAt(0, statement, zone()); 4260 inner_block->statements()->InsertAt(0, statement, zone());
4258 } 4261 }
4259 } 4262 }
4260 4263
4261 void Parser::InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope,
4262 bool* ok) {
4263 scope->HoistSloppyBlockFunctions(factory(), CHECK_OK_VOID);
4264
4265 SloppyBlockFunctionMap* map = scope->sloppy_block_function_map();
4266 for (ZoneHashMap::Entry* p = map->Start(); p != nullptr; p = map->Next(p)) {
4267 // Write in assignments to var for each block-scoped function declaration
4268 auto delegates = static_cast<SloppyBlockFunctionStatement*>(p->value);
4269 for (SloppyBlockFunctionStatement* delegate = delegates;
4270 delegate != nullptr; delegate = delegate->next()) {
4271 if (delegate->to() == nullptr) {
4272 continue;
4273 }
4274 Expression* assignment = factory()->NewAssignment(
4275 Token::ASSIGN, delegate->to(), delegate->from(), kNoSourcePosition);
4276 Statement* statement =
4277 factory()->NewExpressionStatement(assignment, kNoSourcePosition);
4278 delegate->set_statement(statement);
4279 }
4280 }
4281 }
4282
4283
4284 // ---------------------------------------------------------------------------- 4264 // ----------------------------------------------------------------------------
4285 // Parser support 4265 // Parser support
4286 4266
4287 bool Parser::TargetStackContainsLabel(const AstRawString* label) { 4267 bool Parser::TargetStackContainsLabel(const AstRawString* label) {
4288 for (ParserTarget* t = target_stack_; t != NULL; t = t->previous()) { 4268 for (ParserTarget* t = target_stack_; t != NULL; t = t->previous()) {
4289 if (ContainsLabel(t->statement()->labels(), label)) return true; 4269 if (ContainsLabel(t->statement()->labels(), label)) return true;
4290 } 4270 }
4291 return false; 4271 return false;
4292 } 4272 }
4293 4273
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
4428 DCHECK(info->source_stream() == nullptr); 4408 DCHECK(info->source_stream() == nullptr);
4429 stream_ptr = info->character_stream(); 4409 stream_ptr = info->character_stream();
4430 } else { 4410 } else {
4431 DCHECK(info->character_stream() == nullptr); 4411 DCHECK(info->character_stream() == nullptr);
4432 stream.reset(new ExternalStreamingStream(info->source_stream(), 4412 stream.reset(new ExternalStreamingStream(info->source_stream(),
4433 info->source_stream_encoding())); 4413 info->source_stream_encoding()));
4434 stream_ptr = stream.get(); 4414 stream_ptr = stream.get();
4435 } 4415 }
4436 DCHECK(info->context().is_null() || info->context()->IsNativeContext()); 4416 DCHECK(info->context().is_null() || info->context()->IsNativeContext());
4437 4417
4438 DCHECK(original_scope_);
4439
4440 // When streaming, we don't know the length of the source until we have parsed 4418 // When streaming, we don't know the length of the source until we have parsed
4441 // it. The raw data can be UTF-8, so we wouldn't know the source length until 4419 // it. The raw data can be UTF-8, so we wouldn't know the source length until
4442 // we have decoded it anyway even if we knew the raw data length (which we 4420 // we have decoded it anyway even if we knew the raw data length (which we
4443 // don't). We work around this by storing all the scopes which need their end 4421 // don't). We work around this by storing all the scopes which need their end
4444 // position set at the end of the script (the top scope and possible eval 4422 // position set at the end of the script (the top scope and possible eval
4445 // scopes) and set their end position after we know the script length. 4423 // scopes) and set their end position after we know the script length.
4446 if (info->is_lazy()) { 4424 if (info->is_lazy()) {
4447 result = DoParseLazy(info, info->function_name(), stream_ptr); 4425 result = DoParseLazy(info, info->function_name(), stream_ptr);
4448 } else { 4426 } else {
4449 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); 4427 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 node->Print(Isolate::Current()); 5952 node->Print(Isolate::Current());
5975 } 5953 }
5976 #endif // DEBUG 5954 #endif // DEBUG
5977 5955
5978 #undef CHECK_OK 5956 #undef CHECK_OK
5979 #undef CHECK_OK_VOID 5957 #undef CHECK_OK_VOID
5980 #undef CHECK_FAILED 5958 #undef CHECK_FAILED
5981 5959
5982 } // namespace internal 5960 } // namespace internal
5983 } // namespace v8 5961 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698