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

Side by Side Diff: src/parser.h

Issue 913183005: Inline the ParseInfo structure as parameters to the Parser constructor. (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/background-parsing-task.cc ('k') | 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 return tag != NULL; 628 return tag != NULL;
629 } 629 }
630 630
631 private: 631 private:
632 Parser* parser_; 632 Parser* parser_;
633 }; 633 };
634 634
635 635
636 class Parser : public ParserBase<ParserTraits> { 636 class Parser : public ParserBase<ParserTraits> {
637 public: 637 public:
638 // Note that the hash seed in ParseInfo must be the hash seed from the 638 Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed,
639 // Isolate's heap, otherwise the heap will be in an inconsistent state once 639 UnicodeCache* unicode_cache);
640 // the strings created by the Parser are internalized.
641 struct ParseInfo {
642 uintptr_t stack_limit;
643 uint32_t hash_seed;
644 UnicodeCache* unicode_cache;
645 };
646
647 Parser(CompilationInfo* info, ParseInfo* parse_info);
648 ~Parser() { 640 ~Parser() {
649 delete reusable_preparser_; 641 delete reusable_preparser_;
650 reusable_preparser_ = NULL; 642 reusable_preparser_ = NULL;
651 delete cached_parse_data_; 643 delete cached_parse_data_;
652 cached_parse_data_ = NULL; 644 cached_parse_data_ = NULL;
653 } 645 }
654 646
655 // Parses the source code represented by the compilation info and sets its 647 // Parses the source code represented by the compilation info and sets its
656 // function literal. Returns false (and deallocates any allocated AST 648 // function literal. Returns false (and deallocates any allocated AST
657 // nodes) if parsing failed. 649 // nodes) if parsing failed.
658 static bool Parse(CompilationInfo* info, 650 static bool Parse(CompilationInfo* info, bool allow_lazy = false);
659 bool allow_lazy = false) {
660 ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(),
661 info->isolate()->heap()->HashSeed(),
662 info->isolate()->unicode_cache()};
663 Parser parser(info, &parse_info);
664 parser.set_allow_lazy(allow_lazy);
665 if (parser.Parse()) {
666 info->SetLanguageMode(info->function()->language_mode());
667 return true;
668 }
669 return false;
670 }
671 bool Parse(); 651 bool Parse();
672 void ParseOnBackground(); 652 void ParseOnBackground();
673 653
674 // Handle errors detected during parsing, move statistics to Isolate, 654 // Handle errors detected during parsing, move statistics to Isolate,
675 // internalize strings (move them to the heap). 655 // internalize strings (move them to the heap).
676 void Internalize(); 656 void Internalize();
677 void HandleSourceURLComments(); 657 void HandleSourceURLComments();
678 658
679 private: 659 private:
680 friend class ParserTraits; 660 friend class ParserTraits;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 } 960 }
981 961
982 962
983 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, 963 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state,
984 int start, Expression* tag) { 964 int start, Expression* tag) {
985 return parser_->CloseTemplateLiteral(state, start, tag); 965 return parser_->CloseTemplateLiteral(state, start, tag);
986 } 966 }
987 } } // namespace v8::internal 967 } } // namespace v8::internal
988 968
989 #endif // V8_PARSER_H_ 969 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698