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

Side by Side Diff: src/parser.h

Issue 3185026: Reordered function entries in PreParse data to be ordered by start position. (Closed)
Patch Set: Added parentheses. Created 10 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
« 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 int start_pos() { return backing_[kStartPosOffset]; } 61 int start_pos() { return backing_[kStartPosOffset]; }
62 void set_start_pos(int value) { backing_[kStartPosOffset] = value; } 62 void set_start_pos(int value) { backing_[kStartPosOffset] = value; }
63 63
64 int end_pos() { return backing_[kEndPosOffset]; } 64 int end_pos() { return backing_[kEndPosOffset]; }
65 void set_end_pos(int value) { backing_[kEndPosOffset] = value; } 65 void set_end_pos(int value) { backing_[kEndPosOffset] = value; }
66 66
67 int literal_count() { return backing_[kLiteralCountOffset]; } 67 int literal_count() { return backing_[kLiteralCountOffset]; }
68 void set_literal_count(int value) { backing_[kLiteralCountOffset] = value; } 68 void set_literal_count(int value) { backing_[kLiteralCountOffset] = value; }
69 69
70 int property_count() { return backing_[kPropertyCountOffset]; } 70 int property_count() { return backing_[kPropertyCountOffset]; }
71 void set_property_count(int value) { backing_[kPropertyCountOffset] = value; } 71 void set_property_count(int value) {
72 backing_[kPropertyCountOffset] = value;
73 }
74
75 int predata_skip() { return backing_[kPredataSkipOffset]; }
76 void set_predata_skip(int value) {
77 backing_[kPredataSkipOffset] = value;
78 }
72 79
73 bool is_valid() { return backing_.length() > 0; } 80 bool is_valid() { return backing_.length() > 0; }
74 81
75 static const int kSize = 4; 82 static const int kSize = 5;
76 83
77 private: 84 private:
78 Vector<unsigned> backing_; 85 Vector<unsigned> backing_;
79 static const int kStartPosOffset = 0; 86 static const int kStartPosOffset = 0;
80 static const int kEndPosOffset = 1; 87 static const int kEndPosOffset = 1;
81 static const int kLiteralCountOffset = 2; 88 static const int kLiteralCountOffset = 2;
82 static const int kPropertyCountOffset = 3; 89 static const int kPropertyCountOffset = 3;
90 static const int kPredataSkipOffset = 4;
83 }; 91 };
84 92
85 93
86 class ScriptDataImpl : public ScriptData { 94 class ScriptDataImpl : public ScriptData {
87 public: 95 public:
88 explicit ScriptDataImpl(Vector<unsigned> store) 96 explicit ScriptDataImpl(Vector<unsigned> store)
89 : store_(store), 97 : store_(store),
90 last_entry_(0) { } 98 index_(kHeaderSize) { }
91 virtual ~ScriptDataImpl(); 99 virtual ~ScriptDataImpl();
92 virtual int Length(); 100 virtual int Length();
93 virtual const char* Data(); 101 virtual const char* Data();
94 virtual bool HasError(); 102 virtual bool HasError();
95 FunctionEntry GetFunctionEnd(int start); 103 FunctionEntry GetFunctionEntry(int start);
104 void SkipFunctionEntry(int start);
96 bool SanityCheck(); 105 bool SanityCheck();
97 106
98 Scanner::Location MessageLocation(); 107 Scanner::Location MessageLocation();
99 const char* BuildMessage(); 108 const char* BuildMessage();
100 Vector<const char*> BuildArgs(); 109 Vector<const char*> BuildArgs();
101 110
102 bool has_error() { return store_[kHasErrorOffset]; } 111 bool has_error() { return store_[kHasErrorOffset]; }
103 unsigned magic() { return store_[kMagicOffset]; } 112 unsigned magic() { return store_[kMagicOffset]; }
104 unsigned version() { return store_[kVersionOffset]; } 113 unsigned version() { return store_[kVersionOffset]; }
114 // Skip forward in the preparser data by the given number
115 // of unsigned ints.
116 virtual void Skip(int entries) {
117 ASSERT(entries >= 0);
118 ASSERT(entries <= store_.length() - index_);
119 index_ += entries;
120 }
105 121
106 static const unsigned kMagicNumber = 0xBadDead; 122 static const unsigned kMagicNumber = 0xBadDead;
107 static const unsigned kCurrentVersion = 1; 123 static const unsigned kCurrentVersion = 1;
108 124
109 static const unsigned kMagicOffset = 0; 125 static const int kMagicOffset = 0;
110 static const unsigned kVersionOffset = 1; 126 static const int kVersionOffset = 1;
111 static const unsigned kHasErrorOffset = 2; 127 static const int kHasErrorOffset = 2;
112 static const unsigned kSizeOffset = 3; 128 static const int kSizeOffset = 3;
113 static const unsigned kHeaderSize = 4; 129 static const int kHeaderSize = 4;
114 130
115 private: 131 private:
132 Vector<unsigned> store_;
133 int index_;
134
116 unsigned Read(int position); 135 unsigned Read(int position);
117 unsigned* ReadAddress(int position); 136 unsigned* ReadAddress(int position);
118 int EntryCount();
119 FunctionEntry nth(int n);
120 137
121 Vector<unsigned> store_; 138 void FindStart(int position);
122
123 // Read strings written by ParserRecorder::WriteString. 139 // Read strings written by ParserRecorder::WriteString.
124 static const char* ReadString(unsigned* start, int* chars); 140 static const char* ReadString(unsigned* start, int* chars);
125
126 // The last entry returned. This is used to make lookup faster:
127 // the next entry to return is typically the next entry so lookup
128 // will usually be much faster if we start from the last entry.
129 int last_entry_;
130 }; 141 };
131 142
132 143
133 // The parser: Takes a script and and context information, and builds a 144 // The parser: Takes a script and and context information, and builds a
134 // FunctionLiteral AST node. Returns NULL and deallocates any allocated 145 // FunctionLiteral AST node. Returns NULL and deallocates any allocated
135 // AST nodes if parsing failed. 146 // AST nodes if parsing failed.
136 FunctionLiteral* MakeAST(bool compile_in_global_context, 147 FunctionLiteral* MakeAST(bool compile_in_global_context,
137 Handle<Script> script, 148 Handle<Script> script,
138 v8::Extension* extension, 149 v8::Extension* extension,
139 ScriptDataImpl* pre_data, 150 ScriptDataImpl* pre_data,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 static const int kTypeSlot = 0; 204 static const int kTypeSlot = 0;
194 static const int kElementsSlot = 1; 205 static const int kElementsSlot = 1;
195 206
196 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 207 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
197 }; 208 };
198 209
199 210
200 } } // namespace v8::internal 211 } } // namespace v8::internal
201 212
202 #endif // V8_PARSER_H_ 213 #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