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

Side by Side Diff: src/parser.h

Issue 527763002: Refactor Parser to make it usable on a background thread. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/parser.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 #ifndef V8_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // For CachedDataMode 10 #include "src/compiler.h" // For CachedDataMode
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope, 590 V8_INLINE void CheckConflictingVarDeclarations(v8::internal::Scope* scope,
591 bool* ok); 591 bool* ok);
592 592
593 private: 593 private:
594 Parser* parser_; 594 Parser* parser_;
595 }; 595 };
596 596
597 597
598 class Parser : public ParserBase<ParserTraits> { 598 class Parser : public ParserBase<ParserTraits> {
599 public: 599 public:
600 explicit Parser(CompilationInfo* info); 600 // Note that the passed hash seed must be the hash seed from the Isolate's
601 // heap, otherwise the heap will be in an inconsistent state once the strings
602 // created by the Parser are internalized.
603 Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
rossberg 2014/09/02 08:47:40 Would it be worth introducing a struct to collect
marja 2014/09/02 09:48:40 Ok. Ultimately, we'd want is separate structs for
604 UnicodeCache* unicode_cache);
601 ~Parser() { 605 ~Parser() {
602 delete reusable_preparser_; 606 delete reusable_preparser_;
603 reusable_preparser_ = NULL; 607 reusable_preparser_ = NULL;
604 delete cached_parse_data_; 608 delete cached_parse_data_;
605 cached_parse_data_ = NULL; 609 cached_parse_data_ = NULL;
606 } 610 }
607 611
608 // Parses the source code represented by the compilation info and sets its 612 // Parses the source code represented by the compilation info and sets its
609 // function literal. Returns false (and deallocates any allocated AST 613 // function literal. Returns false (and deallocates any allocated AST
610 // nodes) if parsing failed. 614 // nodes) if parsing failed.
611 static bool Parse(CompilationInfo* info, 615 static bool Parse(CompilationInfo* info,
612 bool allow_lazy = false) { 616 bool allow_lazy = false) {
613 Parser parser(info); 617 Parser parser(info, info->isolate()->stack_guard()->real_climit(),
618 info->isolate()->heap()->HashSeed(),
619 info->isolate()->unicode_cache());
614 parser.set_allow_lazy(allow_lazy); 620 parser.set_allow_lazy(allow_lazy);
615 return parser.Parse(); 621 return parser.Parse();
616 } 622 }
617 bool Parse(); 623 bool Parse();
618 624
619 private: 625 private:
620 friend class ParserTraits; 626 friend class ParserTraits;
621 627
622 // Limit the allowed number of local variables in a function. The hard limit 628 // Limit the allowed number of local variables in a function. The hard limit
623 // is that offsets computed by FullCodeGenerator::StackOperand and similar 629 // is that offsets computed by FullCodeGenerator::StackOperand and similar
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 796
791 // Consumes the ending }. 797 // Consumes the ending }.
792 ZoneList<Statement*>* ParseEagerFunctionBody( 798 ZoneList<Statement*>* ParseEagerFunctionBody(
793 const AstRawString* function_name, int pos, Variable* fvar, 799 const AstRawString* function_name, int pos, Variable* fvar,
794 Token::Value fvar_init_op, bool is_generator, bool* ok); 800 Token::Value fvar_init_op, bool is_generator, bool* ok);
795 801
796 void HandleSourceURLComments(); 802 void HandleSourceURLComments();
797 803
798 void ThrowPendingError(); 804 void ThrowPendingError();
799 805
800 void InternalizeUseCounts(); 806 // Handle errors detected during parsing, move statistics to Isolate,
807 // internalize strings (move them to the heap).
808 void Internalize();
801 809
802 Isolate* isolate_; 810 Isolate* isolate_;
803 811
804 Handle<Script> script_; 812 Handle<Script> script_;
805 Scanner scanner_; 813 Scanner scanner_;
806 PreParser* reusable_preparser_; 814 PreParser* reusable_preparser_;
807 Scope* original_scope_; // for ES5 function declarations in sloppy eval 815 Scope* original_scope_; // for ES5 function declarations in sloppy eval
808 Target* target_stack_; // for break, continue statements 816 Target* target_stack_; // for break, continue statements
809 ParseData* cached_parse_data_; 817 ParseData* cached_parse_data_;
810 AstValueFactory* ast_value_factory_; 818 AstValueFactory* ast_value_factory_;
811 819
812 CompilationInfo* info_; 820 CompilationInfo* info_;
813 821
814 // Pending errors. 822 // Pending errors.
815 bool has_pending_error_; 823 bool has_pending_error_;
816 Scanner::Location pending_error_location_; 824 Scanner::Location pending_error_location_;
817 const char* pending_error_message_; 825 const char* pending_error_message_;
818 const AstRawString* pending_error_arg_; 826 const AstRawString* pending_error_arg_;
819 const char* pending_error_char_arg_; 827 const char* pending_error_char_arg_;
820 bool pending_error_is_reference_error_; 828 bool pending_error_is_reference_error_;
821 829
830 // Other information which will be stored in Parser and moved to Isolate after
831 // parsing.
822 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; 832 int use_counts_[v8::Isolate::kUseCounterFeatureCount];
833 int total_preparse_skipped_;
834 HistogramTimer* pre_parse_timer_;
835
836 // Hash seed of the heap where strings will eventually get internalized.
837 uint32_t hash_seed_;
823 }; 838 };
824 839
825 840
826 bool ParserTraits::IsFutureStrictReserved( 841 bool ParserTraits::IsFutureStrictReserved(
827 const AstRawString* identifier) const { 842 const AstRawString* identifier) const {
828 return identifier->IsOneByteEqualTo("yield") || 843 return identifier->IsOneByteEqualTo("yield") ||
829 parser_->scanner()->IdentifierIsFutureStrictReserved(identifier); 844 parser_->scanner()->IdentifierIsFutureStrictReserved(identifier);
830 } 845 }
831 846
832 847
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 private: 906 private:
892 static const int kLiteralTypeSlot = 0; 907 static const int kLiteralTypeSlot = 0;
893 static const int kElementsSlot = 1; 908 static const int kElementsSlot = 1;
894 909
895 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 910 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
896 }; 911 };
897 912
898 } } // namespace v8::internal 913 } } // namespace v8::internal
899 914
900 #endif // V8_PARSER_H_ 915 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698