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

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

Issue 71673002: Experimental parser: Add an option to lexer shell to ignore after ILLEGAL. (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 | « no previous file | no next file » | 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 191
192 std::pair<TimeDelta, TimeDelta> ProcessFile( 192 std::pair<TimeDelta, TimeDelta> ProcessFile(
193 const char* fname, 193 const char* fname,
194 Encoding encoding, 194 Encoding encoding,
195 Isolate* isolate, 195 Isolate* isolate,
196 bool run_baseline, 196 bool run_baseline,
197 bool run_experimental, 197 bool run_experimental,
198 bool print_tokens, 198 bool print_tokens,
199 bool check_tokens, 199 bool check_tokens,
200 bool break_after_illegal,
200 int repeat) { 201 int repeat) {
201 if (print_tokens) { 202 if (print_tokens) {
202 printf("Processing file %s\n", fname); 203 printf("Processing file %s\n", fname);
203 } 204 }
204 HandleScope handle_scope(isolate); 205 HandleScope handle_scope(isolate);
205 std::vector<TokenWithLocation> baseline_tokens, experimental_tokens; 206 std::vector<TokenWithLocation> baseline_tokens, experimental_tokens;
206 TimeDelta baseline_time, experimental_time; 207 TimeDelta baseline_time, experimental_time;
207 if (run_baseline) { 208 if (run_baseline) {
208 baseline_time = RunBaselineScanner( 209 baseline_time = RunBaselineScanner(
209 fname, isolate, encoding, print_tokens || check_tokens, 210 fname, isolate, encoding, print_tokens || check_tokens,
(...skipping 13 matching lines...) Expand all
223 if ((print_tokens || check_tokens) && run_baseline && run_experimental) { 224 if ((print_tokens || check_tokens) && run_baseline && run_experimental) {
224 if (print_tokens) { 225 if (print_tokens) {
225 printf("No of tokens in Baseline: %d\n", 226 printf("No of tokens in Baseline: %d\n",
226 static_cast<int>(baseline_tokens.size())); 227 static_cast<int>(baseline_tokens.size()));
227 printf("No of tokens in Experimental: %d\n", 228 printf("No of tokens in Experimental: %d\n",
228 static_cast<int>(experimental_tokens.size())); 229 static_cast<int>(experimental_tokens.size()));
229 printf("Baseline and Experimental:\n"); 230 printf("Baseline and Experimental:\n");
230 } 231 }
231 for (size_t i = 0; i < experimental_tokens.size(); ++i) { 232 for (size_t i = 0; i < experimental_tokens.size(); ++i) {
232 if (print_tokens) experimental_tokens[i].Print("=>"); 233 if (print_tokens) experimental_tokens[i].Print("=>");
234 if (baseline_tokens[i].value == Token::ILLEGAL) {
235 if (experimental_tokens[i].value != Token::ILLEGAL ||
236 experimental_tokens[i].beg != baseline_tokens[i].beg) {
237 printf("MISMATCH:\n");
238 baseline_tokens[i].Print("Expected: ");
239 experimental_tokens[i].Print("Actual: ");
240 exit(1);
241 }
242 if (break_after_illegal)
243 break;
244 continue;
245 }
233 if (experimental_tokens[i] != baseline_tokens[i]) { 246 if (experimental_tokens[i] != baseline_tokens[i]) {
234 printf("MISMATCH:\n"); 247 printf("MISMATCH:\n");
235 baseline_tokens[i].Print("Expected: "); 248 baseline_tokens[i].Print("Expected: ");
236 experimental_tokens[i].Print("Actual: "); 249 experimental_tokens[i].Print("Actual: ");
237 exit(1); 250 exit(1);
238 } 251 }
239 } 252 }
240 } 253 }
241 return std::make_pair(baseline_time, experimental_time); 254 return std::make_pair(baseline_time, experimental_time);
242 } 255 }
243 256
244 257
245 int main(int argc, char* argv[]) { 258 int main(int argc, char* argv[]) {
246 v8::V8::InitializeICU(); 259 v8::V8::InitializeICU();
247 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 260 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
248 Encoding encoding = LATIN1; 261 Encoding encoding = LATIN1;
249 bool print_tokens = false; 262 bool print_tokens = false;
250 bool run_baseline = true; 263 bool run_baseline = true;
251 bool run_experimental = true; 264 bool run_experimental = true;
252 bool check_tokens = true; 265 bool check_tokens = true;
266 bool break_after_illegal = false;
253 std::vector<std::string> fnames; 267 std::vector<std::string> fnames;
254 std::string benchmark; 268 std::string benchmark;
255 int repeat = 1; 269 int repeat = 1;
256 for (int i = 0; i < argc; ++i) { 270 for (int i = 0; i < argc; ++i) {
257 if (strcmp(argv[i], "--latin1") == 0) { 271 if (strcmp(argv[i], "--latin1") == 0) {
258 encoding = LATIN1; 272 encoding = LATIN1;
259 } else if (strcmp(argv[i], "--utf8") == 0) { 273 } else if (strcmp(argv[i], "--utf8") == 0) {
260 encoding = UTF8; 274 encoding = UTF8;
261 } else if (strcmp(argv[i], "--utf16") == 0) { 275 } else if (strcmp(argv[i], "--utf16") == 0) {
262 encoding = UTF16; 276 encoding = UTF16;
263 } else if (strcmp(argv[i], "--print-tokens") == 0) { 277 } else if (strcmp(argv[i], "--print-tokens") == 0) {
264 print_tokens = true; 278 print_tokens = true;
265 } else if (strcmp(argv[i], "--no-baseline") == 0) { 279 } else if (strcmp(argv[i], "--no-baseline") == 0) {
266 run_baseline = false; 280 run_baseline = false;
267 } else if (strcmp(argv[i], "--no-experimental") == 0) { 281 } else if (strcmp(argv[i], "--no-experimental") == 0) {
268 run_experimental = false; 282 run_experimental = false;
269 } else if (strcmp(argv[i], "--no-check") == 0) { 283 } else if (strcmp(argv[i], "--no-check") == 0) {
270 check_tokens = false; 284 check_tokens = false;
285 } else if (strcmp(argv[i], "--break-after-illegal") == 0) {
286 break_after_illegal = true;
271 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) { 287 } else if (strncmp(argv[i], "--benchmark=", 12) == 0) {
272 benchmark = std::string(argv[i]).substr(12); 288 benchmark = std::string(argv[i]).substr(12);
273 } else if (strncmp(argv[i], "--repeat=", 9) == 0) { 289 } else if (strncmp(argv[i], "--repeat=", 9) == 0) {
274 std::string repeat_str = std::string(argv[i]).substr(9); 290 std::string repeat_str = std::string(argv[i]).substr(9);
275 repeat = atoi(repeat_str.c_str()); 291 repeat = atoi(repeat_str.c_str());
276 } else if (i > 0 && argv[i][0] != '-') { 292 } else if (i > 0 && argv[i][0] != '-') {
277 fnames.push_back(std::string(argv[i])); 293 fnames.push_back(std::string(argv[i]));
278 } 294 }
279 } 295 }
280 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 296 v8::Isolate* isolate = v8::Isolate::GetCurrent();
281 { 297 {
282 v8::HandleScope handle_scope(isolate); 298 v8::HandleScope handle_scope(isolate);
283 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); 299 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
284 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global); 300 v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
285 ASSERT(!context.IsEmpty()); 301 ASSERT(!context.IsEmpty());
286 { 302 {
287 v8::Context::Scope scope(context); 303 v8::Context::Scope scope(context);
288 Isolate* isolate = Isolate::Current(); 304 Isolate* isolate = Isolate::Current();
289 double baseline_total = 0, experimental_total = 0; 305 double baseline_total = 0, experimental_total = 0;
290 for (size_t i = 0; i < fnames.size(); i++) { 306 for (size_t i = 0; i < fnames.size(); i++) {
291 std::pair<TimeDelta, TimeDelta> times; 307 std::pair<TimeDelta, TimeDelta> times;
292 check_tokens = check_tokens && run_baseline && run_experimental; 308 check_tokens = check_tokens && run_baseline && run_experimental;
293 times = ProcessFile(fnames[i].c_str(), encoding, isolate, run_baseline, 309 times = ProcessFile(fnames[i].c_str(), encoding, isolate, run_baseline,
294 run_experimental, print_tokens, check_tokens, 310 run_experimental, print_tokens, check_tokens,
295 repeat); 311 break_after_illegal, repeat);
296 baseline_total += times.first.InMillisecondsF(); 312 baseline_total += times.first.InMillisecondsF();
297 experimental_total += times.second.InMillisecondsF(); 313 experimental_total += times.second.InMillisecondsF();
298 } 314 }
299 if (run_baseline) { 315 if (run_baseline) {
300 printf("Baseline%s(RunTime): %.f ms\n", benchmark.c_str(), 316 printf("Baseline%s(RunTime): %.f ms\n", benchmark.c_str(),
301 baseline_total); 317 baseline_total);
302 } 318 }
303 if (run_experimental) { 319 if (run_experimental) {
304 if (benchmark.empty()) benchmark = "Experimental"; 320 if (benchmark.empty()) benchmark = "Experimental";
305 printf("%s(RunTime): %.f ms\n", benchmark.c_str(), 321 printf("%s(RunTime): %.f ms\n", benchmark.c_str(),
306 experimental_total); 322 experimental_total);
307 } 323 }
308 } 324 }
309 } 325 }
310 v8::V8::Dispose(); 326 v8::V8::Dispose();
311 return 0; 327 return 0;
312 } 328 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698