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

Side by Side Diff: src/lexer/lexer-shell.cc

Issue 83633002: Experimental parser: continue unifying the API with Scanner. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month 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/lexer/experimental-scanner.h ('k') | tools/lexer_generator/code_generator.jinja » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 scanner_->Initialize(stream_); 149 scanner_->Initialize(stream_);
150 } 150 }
151 151
152 ~BaselineScanner() { 152 ~BaselineScanner() {
153 delete scanner_; 153 delete scanner_;
154 delete stream_; 154 delete stream_;
155 delete unicode_cache_; 155 delete unicode_cache_;
156 delete[] source_; 156 delete[] source_;
157 } 157 }
158 158
159 Token::Value Next(int* beg_pos, int* end_pos) { 159 Scanner* scanner_;
160 Token::Value res = scanner_->Next();
161 *beg_pos = scanner_->location().beg_pos;
162 *end_pos = scanner_->location().end_pos;
163 return res;
164 }
165 160
166 private: 161 private:
167 UnicodeCache* unicode_cache_; 162 UnicodeCache* unicode_cache_;
168 Scanner* scanner_;
169 const byte* source_; 163 const byte* source_;
170 BufferedUtf16CharacterStream* stream_; 164 BufferedUtf16CharacterStream* stream_;
171 }; 165 };
172 166
173 167
174 struct TokenWithLocation { 168 struct TokenWithLocation {
175 Token::Value value; 169 Token::Value value;
176 size_t beg; 170 size_t beg;
177 size_t end; 171 size_t end;
178 TokenWithLocation() : value(Token::ILLEGAL), beg(0), end(0) { } 172 TokenWithLocation() : value(Token::ILLEGAL), beg(0), end(0) { }
(...skipping 19 matching lines...) Expand all
198 bool dump_tokens, 192 bool dump_tokens,
199 std::vector<TokenWithLocation>* tokens, 193 std::vector<TokenWithLocation>* tokens,
200 int repeat, 194 int repeat,
201 HarmonySettings harmony_settings) { 195 HarmonySettings harmony_settings) {
202 ElapsedTimer timer; 196 ElapsedTimer timer;
203 BaselineScanner scanner( 197 BaselineScanner scanner(
204 fname, isolate, encoding, &timer, repeat, harmony_settings); 198 fname, isolate, encoding, &timer, repeat, harmony_settings);
205 Token::Value token; 199 Token::Value token;
206 int beg, end; 200 int beg, end;
207 do { 201 do {
208 token = scanner.Next(&beg, &end); 202 token = scanner.scanner_->Next();
203 beg = scanner.scanner_->location().beg_pos;
204 end = scanner.scanner_->location().end_pos;
209 if (dump_tokens) { 205 if (dump_tokens) {
210 tokens->push_back(TokenWithLocation(token, beg, end)); 206 tokens->push_back(TokenWithLocation(token, beg, end));
211 } 207 }
212 } while (token != Token::EOS); 208 } while (token != Token::EOS);
213 return timer.Elapsed(); 209 return timer.Elapsed();
214 } 210 }
215 211
216 212
217 template<typename YYCTYPE> 213 template<typename YYCTYPE>
218 TimeDelta RunExperimentalScanner(const char* fname, 214 TimeDelta RunExperimentalScanner(const char* fname,
219 Isolate* isolate, 215 Isolate* isolate,
220 Encoding encoding, 216 Encoding encoding,
221 bool dump_tokens, 217 bool dump_tokens,
222 std::vector<TokenWithLocation>* tokens, 218 std::vector<TokenWithLocation>* tokens,
223 int repeat, 219 int repeat,
224 HarmonySettings harmony_settings) { 220 HarmonySettings harmony_settings) {
225 ElapsedTimer timer; 221 ElapsedTimer timer;
226 byte* buffer_end = 0; 222 byte* buffer_end = 0;
227 YYCTYPE* buffer = reinterpret_cast<YYCTYPE*>( 223 YYCTYPE* buffer = reinterpret_cast<YYCTYPE*>(
228 ReadFile(fname, &buffer_end, repeat, encoding == UTF8TO16)); 224 ReadFile(fname, &buffer_end, repeat, encoding == UTF8TO16));
229 225
226 timer.Start();
230 ExperimentalScanner<YYCTYPE> scanner( 227 ExperimentalScanner<YYCTYPE> scanner(
231 buffer, reinterpret_cast<YYCTYPE*>(buffer_end), isolate); 228 buffer, reinterpret_cast<YYCTYPE*>(buffer_end), isolate);
232 scanner.SetHarmonyNumericLiterals(harmony_settings.numeric_literals); 229 scanner.SetHarmonyNumericLiterals(harmony_settings.numeric_literals);
233 scanner.SetHarmonyModules(harmony_settings.modules); 230 scanner.SetHarmonyModules(harmony_settings.modules);
234 scanner.SetHarmonyScoping(harmony_settings.scoping); 231 scanner.SetHarmonyScoping(harmony_settings.scoping);
235 232
236 timer.Start();
237 Token::Value token; 233 Token::Value token;
238 int beg, end; 234 int beg, end;
239 do { 235 do {
240 token = scanner.Next(&beg, &end); 236 token = scanner.Next();
237 beg = scanner.location().beg_pos;
238 end = scanner.location().end_pos;
241 if (dump_tokens) { 239 if (dump_tokens) {
242 tokens->push_back(TokenWithLocation(token, beg, end)); 240 tokens->push_back(TokenWithLocation(token, beg, end));
243 } 241 }
244 } while (token != Token::EOS); 242 } while (token != Token::EOS);
245 return timer.Elapsed(); 243 return timer.Elapsed();
246 } 244 }
247 245
248 246
249 void PrintTokens(const char* name, 247 void PrintTokens(const char* name,
250 const std::vector<TokenWithLocation>& tokens) { 248 const std::vector<TokenWithLocation>& tokens) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 if (run_experimental) { 417 if (run_experimental) {
420 if (benchmark.empty()) benchmark = "Experimental"; 418 if (benchmark.empty()) benchmark = "Experimental";
421 printf("%s(RunTime): %.f ms\n", benchmark.c_str(), 419 printf("%s(RunTime): %.f ms\n", benchmark.c_str(),
422 experimental_total); 420 experimental_total);
423 } 421 }
424 } 422 }
425 } 423 }
426 v8::V8::Dispose(); 424 v8::V8::Dispose();
427 return 0; 425 return 0;
428 } 426 }
OLDNEW
« no previous file with comments | « src/lexer/experimental-scanner.h ('k') | tools/lexer_generator/code_generator.jinja » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698