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

Side by Side Diff: src/parser.h

Issue 8662037: Don't preparse large files to find boundaries of lazy functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years 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 | « src/liveedit.cc ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 public: 69 public:
70 enum { 70 enum {
71 kStartPositionIndex, 71 kStartPositionIndex,
72 kEndPositionIndex, 72 kEndPositionIndex,
73 kLiteralCountIndex, 73 kLiteralCountIndex,
74 kPropertyCountIndex, 74 kPropertyCountIndex,
75 kStrictModeIndex, 75 kStrictModeIndex,
76 kSize 76 kSize
77 }; 77 };
78 78
79 explicit FunctionEntry(Vector<unsigned> backing) : backing_(backing) { } 79 explicit FunctionEntry(Vector<unsigned> backing)
80 FunctionEntry() { } 80 : backing_(backing) { }
81
82 FunctionEntry() : backing_() { }
81 83
82 int start_pos() { return backing_[kStartPositionIndex]; } 84 int start_pos() { return backing_[kStartPositionIndex]; }
83 int end_pos() { return backing_[kEndPositionIndex]; } 85 int end_pos() { return backing_[kEndPositionIndex]; }
84 int literal_count() { return backing_[kLiteralCountIndex]; } 86 int literal_count() { return backing_[kLiteralCountIndex]; }
85 int property_count() { return backing_[kPropertyCountIndex]; } 87 int property_count() { return backing_[kPropertyCountIndex]; }
86 StrictModeFlag strict_mode_flag() { 88 StrictModeFlag strict_mode_flag() {
87 ASSERT(backing_[kStrictModeIndex] == kStrictMode || 89 ASSERT(backing_[kStrictModeIndex] == kStrictMode ||
88 backing_[kStrictModeIndex] == kNonStrictMode); 90 backing_[kStrictModeIndex] == kNonStrictMode);
89 return static_cast<StrictModeFlag>(backing_[kStrictModeIndex]); 91 return static_cast<StrictModeFlag>(backing_[kStrictModeIndex]);
90 } 92 }
91 93
92 bool is_valid() { return !backing_.is_empty(); } 94 bool is_valid() { return !backing_.is_empty(); }
93 95
94 private: 96 private:
95 Vector<unsigned> backing_; 97 Vector<unsigned> backing_;
98 bool owns_data_;
96 }; 99 };
97 100
98 101
99 class ScriptDataImpl : public ScriptData { 102 class ScriptDataImpl : public ScriptData {
100 public: 103 public:
101 explicit ScriptDataImpl(Vector<unsigned> store) 104 explicit ScriptDataImpl(Vector<unsigned> store)
102 : store_(store), 105 : store_(store),
103 owns_store_(true) { } 106 owns_store_(true) { }
104 107
105 // Create an empty ScriptDataImpl that is guaranteed to not satisfy 108 // Create an empty ScriptDataImpl that is guaranteed to not satisfy
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 161
159 friend class ScriptData; 162 friend class ScriptData;
160 }; 163 };
161 164
162 165
163 class ParserApi { 166 class ParserApi {
164 public: 167 public:
165 // Parses the source code represented by the compilation info and sets its 168 // Parses the source code represented by the compilation info and sets its
166 // function literal. Returns false (and deallocates any allocated AST 169 // function literal. Returns false (and deallocates any allocated AST
167 // nodes) if parsing failed. 170 // nodes) if parsing failed.
168 static bool Parse(CompilationInfo* info); 171 static bool Parse(CompilationInfo* info, int flags);
169 172
170 // Generic preparser generating full preparse data. 173 // Generic preparser generating full preparse data.
171 static ScriptDataImpl* PreParse(UC16CharacterStream* source, 174 static ScriptDataImpl* PreParse(UC16CharacterStream* source,
172 v8::Extension* extension, 175 v8::Extension* extension,
173 int flags); 176 int flags);
174 177
175 // Preparser that only does preprocessing that makes sense if only used 178 // Preparser that only does preprocessing that makes sense if only used
176 // immediately after. 179 // immediately after.
177 static ScriptDataImpl* PartialPreParse(UC16CharacterStream* source, 180 static ScriptDataImpl* PartialPreParse(UC16CharacterStream* source,
178 v8::Extension* extension, 181 v8::Extension* extension,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 bool multiline_; 417 bool multiline_;
415 bool simple_; 418 bool simple_;
416 bool contains_anchor_; 419 bool contains_anchor_;
417 bool is_scanned_for_captures_; 420 bool is_scanned_for_captures_;
418 bool failed_; 421 bool failed_;
419 }; 422 };
420 423
421 // ---------------------------------------------------------------------------- 424 // ----------------------------------------------------------------------------
422 // JAVASCRIPT PARSING 425 // JAVASCRIPT PARSING
423 426
427 // Forward declaration.
428 class SingletonLogger;
429
424 class Parser { 430 class Parser {
425 public: 431 public:
426 Parser(Handle<Script> script, 432 Parser(Handle<Script> script,
427 bool allow_natives_syntax, 433 int parsing_flags, // Combination of ParsingFlags
428 v8::Extension* extension, 434 v8::Extension* extension,
429 ScriptDataImpl* pre_data); 435 ScriptDataImpl* pre_data);
430 virtual ~Parser() { } 436 virtual ~Parser() {
437 if (reusable_preparser_ != NULL) {
438 delete reusable_preparser_;
439 }
440 }
431 441
432 // Returns NULL if parsing failed. 442 // Returns NULL if parsing failed.
433 FunctionLiteral* ParseProgram(CompilationInfo* info); 443 FunctionLiteral* ParseProgram(CompilationInfo* info);
434 FunctionLiteral* ParseLazy(CompilationInfo* info); 444 FunctionLiteral* ParseLazy(CompilationInfo* info);
435 445
436 void ReportMessageAt(Scanner::Location loc, 446 void ReportMessageAt(Scanner::Location loc,
437 const char* message, 447 const char* message,
438 Vector<const char*> args); 448 Vector<const char*> args);
439 void ReportMessageAt(Scanner::Location loc, 449 void ReportMessageAt(Scanner::Location loc,
440 const char* message, 450 const char* message,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 // type. Both arguments must be non-null (in the handle sense). 727 // type. Both arguments must be non-null (in the handle sense).
718 Expression* NewThrowTypeError(Handle<String> type, 728 Expression* NewThrowTypeError(Handle<String> type,
719 Handle<Object> first, 729 Handle<Object> first,
720 Handle<Object> second); 730 Handle<Object> second);
721 731
722 // Generic AST generator for throwing errors from compiled code. 732 // Generic AST generator for throwing errors from compiled code.
723 Expression* NewThrowError(Handle<String> constructor, 733 Expression* NewThrowError(Handle<String> constructor,
724 Handle<String> type, 734 Handle<String> type,
725 Vector< Handle<Object> > arguments); 735 Vector< Handle<Object> > arguments);
726 736
737 preparser::PreParser::PreParseResult LazyParseFunctionLiteral(
738 SingletonLogger* logger);
739
727 Isolate* isolate_; 740 Isolate* isolate_;
728 ZoneList<Handle<String> > symbol_cache_; 741 ZoneList<Handle<String> > symbol_cache_;
729 742
730 Handle<Script> script_; 743 Handle<Script> script_;
731 Scanner scanner_; 744 Scanner scanner_;
732 745 preparser::PreParser* reusable_preparser_;
733 Scope* top_scope_; 746 Scope* top_scope_;
734 FunctionState* current_function_state_; 747 FunctionState* current_function_state_;
735 Target* target_stack_; // for break, continue statements 748 Target* target_stack_; // for break, continue statements
736 v8::Extension* extension_; 749 v8::Extension* extension_;
737 ScriptDataImpl* pre_data_; 750 ScriptDataImpl* pre_data_;
738 FuncNameInferrer* fni_; 751 FuncNameInferrer* fni_;
739 752
740 Mode mode_; 753 Mode mode_;
741 bool allow_natives_syntax_; 754 bool allow_natives_syntax_;
755 bool allow_lazy_;
742 bool stack_overflow_; 756 bool stack_overflow_;
743 // If true, the next (and immediately following) function literal is 757 // If true, the next (and immediately following) function literal is
744 // preceded by a parenthesis. 758 // preceded by a parenthesis.
745 // Heuristically that means that the function will be called immediately, 759 // Heuristically that means that the function will be called immediately,
746 // so never lazily compile it. 760 // so never lazily compile it.
747 bool parenthesized_function_; 761 bool parenthesized_function_;
748 bool harmony_scoping_; 762 bool harmony_scoping_;
749 763
750 friend class BlockState; 764 friend class BlockState;
751 friend class FunctionState; 765 friend class FunctionState;
(...skipping 26 matching lines...) Expand all
778 private: 792 private:
779 static const int kTypeSlot = 0; 793 static const int kTypeSlot = 0;
780 static const int kElementsSlot = 1; 794 static const int kElementsSlot = 1;
781 795
782 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 796 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
783 }; 797 };
784 798
785 } } // namespace v8::internal 799 } } // namespace v8::internal
786 800
787 #endif // V8_PARSER_H_ 801 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/liveedit.cc ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698