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

Side by Side Diff: src/parser.cc

Issue 909463003: PreParser / Parser consistency: Make PreParser aware of Zone and AstValueFactory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 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
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 DCHECK(result != NULL); 664 DCHECK(result != NULL);
665 return result; 665 return result;
666 } 666 }
667 667
668 668
669 const AstRawString* ParserTraits::GetNumberAsSymbol(Scanner* scanner) { 669 const AstRawString* ParserTraits::GetNumberAsSymbol(Scanner* scanner) {
670 double double_value = parser_->scanner()->DoubleValue(); 670 double double_value = parser_->scanner()->DoubleValue();
671 char array[100]; 671 char array[100];
672 const char* string = 672 const char* string =
673 DoubleToCString(double_value, Vector<char>(array, arraysize(array))); 673 DoubleToCString(double_value, Vector<char>(array, arraysize(array)));
674 return ast_value_factory()->GetOneByteString(string); 674 return parser_->ast_value_factory()->GetOneByteString(string);
675 } 675 }
676 676
677 677
678 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) { 678 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) {
679 return parser_->scanner()->NextSymbol(parser_->ast_value_factory()); 679 return parser_->scanner()->NextSymbol(parser_->ast_value_factory());
680 } 680 }
681 681
682 682
683 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory, 683 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory,
684 int pos) { 684 int pos) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 ClassLiteral* ParserTraits::ParseClassLiteral( 787 ClassLiteral* ParserTraits::ParseClassLiteral(
788 const AstRawString* name, Scanner::Location class_name_location, 788 const AstRawString* name, Scanner::Location class_name_location,
789 bool name_is_strict_reserved, int pos, bool* ok) { 789 bool name_is_strict_reserved, int pos, bool* ok) {
790 return parser_->ParseClassLiteral(name, class_name_location, 790 return parser_->ParseClassLiteral(name, class_name_location,
791 name_is_strict_reserved, pos, ok); 791 name_is_strict_reserved, pos, ok);
792 } 792 }
793 793
794 794
795 Parser::Parser(CompilationInfo* info, ParseInfo* parse_info) 795 Parser::Parser(CompilationInfo* info, ParseInfo* parse_info)
796 : ParserBase<ParserTraits>(info->isolate(), info->zone(), &scanner_, 796 : ParserBase<ParserTraits>(info->isolate(), info->zone(), &scanner_,
797 parse_info->stack_limit, info->extension(), NULL, 797 parse_info->stack_limit, info->extension(),
798 this), 798 info->ast_value_factory(), NULL, this),
799 scanner_(parse_info->unicode_cache), 799 scanner_(parse_info->unicode_cache),
800 reusable_preparser_(NULL), 800 reusable_preparser_(NULL),
801 original_scope_(NULL), 801 original_scope_(NULL),
802 target_stack_(NULL), 802 target_stack_(NULL),
803 cached_parse_data_(NULL), 803 cached_parse_data_(NULL),
804 info_(info), 804 info_(info),
805 parsing_lazy_arrow_parameters_(false), 805 parsing_lazy_arrow_parameters_(false),
806 has_pending_error_(false), 806 has_pending_error_(false),
807 pending_error_message_(NULL), 807 pending_error_message_(NULL),
808 pending_error_arg_(NULL), 808 pending_error_arg_(NULL),
(...skipping 16 matching lines...) Expand all
825 FLAG_harmony_computed_property_names); 825 FLAG_harmony_computed_property_names);
826 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); 826 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters);
827 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; 827 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
828 ++feature) { 828 ++feature) {
829 use_counts_[feature] = 0; 829 use_counts_[feature] = 0;
830 } 830 }
831 if (info->ast_value_factory() == NULL) { 831 if (info->ast_value_factory() == NULL) {
832 // info takes ownership of AstValueFactory. 832 // info takes ownership of AstValueFactory.
833 info->SetAstValueFactory( 833 info->SetAstValueFactory(
834 new AstValueFactory(zone(), parse_info->hash_seed)); 834 new AstValueFactory(zone(), parse_info->hash_seed));
835 ast_value_factory_ = info->ast_value_factory();
835 } 836 }
836 } 837 }
837 838
838 839
839 FunctionLiteral* Parser::ParseProgram() { 840 FunctionLiteral* Parser::ParseProgram() {
840 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, 841 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here,
841 // see comment for HistogramTimerScope class. 842 // see comment for HistogramTimerScope class.
842 843
843 // It's OK to use the counters here, since this function is only called in 844 // It's OK to use the counters here, since this function is only called in
844 // the main thread. 845 // the main thread.
(...skipping 3135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( 3981 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
3981 SingletonLogger* logger) { 3982 SingletonLogger* logger) {
3982 // This function may be called on a background thread too; record only the 3983 // This function may be called on a background thread too; record only the
3983 // main thread preparse times. 3984 // main thread preparse times.
3984 if (pre_parse_timer_ != NULL) { 3985 if (pre_parse_timer_ != NULL) {
3985 pre_parse_timer_->Start(); 3986 pre_parse_timer_->Start();
3986 } 3987 }
3987 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 3988 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
3988 3989
3989 if (reusable_preparser_ == NULL) { 3990 if (reusable_preparser_ == NULL) {
3990 reusable_preparser_ = 3991 reusable_preparser_ = new PreParser(
3991 new PreParser(isolate(), &scanner_, NULL, stack_limit_); 3992 isolate(), zone(), &scanner_, ast_value_factory(), NULL, stack_limit_);
3992 reusable_preparser_->set_allow_lazy(true); 3993 reusable_preparser_->set_allow_lazy(true);
3993 reusable_preparser_->set_allow_natives(allow_natives()); 3994 reusable_preparser_->set_allow_natives(allow_natives());
3994 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); 3995 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping());
3995 reusable_preparser_->set_allow_harmony_modules(allow_harmony_modules()); 3996 reusable_preparser_->set_allow_harmony_modules(allow_harmony_modules());
3996 reusable_preparser_->set_allow_harmony_arrow_functions( 3997 reusable_preparser_->set_allow_harmony_arrow_functions(
3997 allow_harmony_arrow_functions()); 3998 allow_harmony_arrow_functions());
3998 reusable_preparser_->set_allow_harmony_numeric_literals( 3999 reusable_preparser_->set_allow_harmony_numeric_literals(
3999 allow_harmony_numeric_literals()); 4000 allow_harmony_numeric_literals());
4000 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); 4001 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes());
4001 reusable_preparser_->set_allow_harmony_object_literals( 4002 reusable_preparser_->set_allow_harmony_object_literals(
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
5412 } else { 5413 } else {
5413 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5414 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5414 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5415 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5415 raw_string->length()); 5416 raw_string->length());
5416 } 5417 }
5417 } 5418 }
5418 5419
5419 return running_hash; 5420 return running_hash;
5420 } 5421 }
5421 } } // namespace v8::internal 5422 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698