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

Side by Side Diff: test/cctest/interpreter/generate-bytecode-expectations.cc

Issue 2390163003: [interpreter] Remove redundant flag from bytecode cctest suite. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include <cstring> 5 #include <cstring>
6 #include <fstream> 6 #include <fstream>
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "test/cctest/interpreter/bytecode-expectations-printer.h" 10 #include "test/cctest/interpreter/bytecode-expectations-printer.h"
(...skipping 22 matching lines...) Expand all
33 public: 33 public:
34 static ProgramOptions FromCommandLine(int argc, char** argv); 34 static ProgramOptions FromCommandLine(int argc, char** argv);
35 35
36 ProgramOptions() 36 ProgramOptions()
37 : parsing_failed_(false), 37 : parsing_failed_(false),
38 print_help_(false), 38 print_help_(false),
39 read_raw_js_snippet_(false), 39 read_raw_js_snippet_(false),
40 read_from_stdin_(false), 40 read_from_stdin_(false),
41 rebaseline_(false), 41 rebaseline_(false),
42 wrap_(true), 42 wrap_(true),
43 execute_(true),
44 top_level_(false), 43 top_level_(false),
45 do_expressions_(false), 44 do_expressions_(false),
46 verbose_(false) {} 45 verbose_(false) {}
47 46
48 bool Validate() const; 47 bool Validate() const;
49 void UpdateFromHeader(std::istream& stream); // NOLINT 48 void UpdateFromHeader(std::istream& stream); // NOLINT
50 void PrintHeader(std::ostream& stream) const; // NOLINT 49 void PrintHeader(std::ostream& stream) const; // NOLINT
51 50
52 bool parsing_failed() const { return parsing_failed_; } 51 bool parsing_failed() const { return parsing_failed_; }
53 bool print_help() const { return print_help_; } 52 bool print_help() const { return print_help_; }
54 bool read_raw_js_snippet() const { return read_raw_js_snippet_; } 53 bool read_raw_js_snippet() const { return read_raw_js_snippet_; }
55 bool read_from_stdin() const { return read_from_stdin_; } 54 bool read_from_stdin() const { return read_from_stdin_; }
56 bool write_to_stdout() const { 55 bool write_to_stdout() const {
57 return output_filename_.empty() && !rebaseline_; 56 return output_filename_.empty() && !rebaseline_;
58 } 57 }
59 bool rebaseline() const { return rebaseline_; } 58 bool rebaseline() const { return rebaseline_; }
60 bool wrap() const { return wrap_; } 59 bool wrap() const { return wrap_; }
61 bool execute() const { return execute_; }
62 bool top_level() const { return top_level_; } 60 bool top_level() const { return top_level_; }
63 bool do_expressions() const { return do_expressions_; } 61 bool do_expressions() const { return do_expressions_; }
64 bool verbose() const { return verbose_; } 62 bool verbose() const { return verbose_; }
65 bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; } 63 bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; }
66 std::vector<std::string> input_filenames() const { return input_filenames_; } 64 std::vector<std::string> input_filenames() const { return input_filenames_; }
67 std::string output_filename() const { return output_filename_; } 65 std::string output_filename() const { return output_filename_; }
68 std::string test_function_name() const { return test_function_name_; } 66 std::string test_function_name() const { return test_function_name_; }
69 67
70 private: 68 private:
71 bool parsing_failed_; 69 bool parsing_failed_;
72 bool print_help_; 70 bool print_help_;
73 bool read_raw_js_snippet_; 71 bool read_raw_js_snippet_;
74 bool read_from_stdin_; 72 bool read_from_stdin_;
75 bool rebaseline_; 73 bool rebaseline_;
76 bool wrap_; 74 bool wrap_;
77 bool execute_;
78 bool top_level_; 75 bool top_level_;
79 bool do_expressions_; 76 bool do_expressions_;
80 bool verbose_; 77 bool verbose_;
81 std::vector<std::string> input_filenames_; 78 std::vector<std::string> input_filenames_;
82 std::string output_filename_; 79 std::string output_filename_;
83 std::string test_function_name_; 80 std::string test_function_name_;
84 }; 81 };
85 82
86 class V8InitializationScope final { 83 class V8InitializationScope final {
87 public: 84 public:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (strcmp(argv[i], "--help") == 0) { 150 if (strcmp(argv[i], "--help") == 0) {
154 options.print_help_ = true; 151 options.print_help_ = true;
155 } else if (strcmp(argv[i], "--raw-js") == 0) { 152 } else if (strcmp(argv[i], "--raw-js") == 0) {
156 options.read_raw_js_snippet_ = true; 153 options.read_raw_js_snippet_ = true;
157 } else if (strcmp(argv[i], "--stdin") == 0) { 154 } else if (strcmp(argv[i], "--stdin") == 0) {
158 options.read_from_stdin_ = true; 155 options.read_from_stdin_ = true;
159 } else if (strcmp(argv[i], "--rebaseline") == 0) { 156 } else if (strcmp(argv[i], "--rebaseline") == 0) {
160 options.rebaseline_ = true; 157 options.rebaseline_ = true;
161 } else if (strcmp(argv[i], "--no-wrap") == 0) { 158 } else if (strcmp(argv[i], "--no-wrap") == 0) {
162 options.wrap_ = false; 159 options.wrap_ = false;
163 } else if (strcmp(argv[i], "--no-execute") == 0) {
164 options.execute_ = false;
165 } else if (strcmp(argv[i], "--top-level") == 0) { 160 } else if (strcmp(argv[i], "--top-level") == 0) {
166 options.top_level_ = true; 161 options.top_level_ = true;
167 } else if (strcmp(argv[i], "--do-expressions") == 0) { 162 } else if (strcmp(argv[i], "--do-expressions") == 0) {
168 options.do_expressions_ = true; 163 options.do_expressions_ = true;
169 } else if (strcmp(argv[i], "--verbose") == 0) { 164 } else if (strcmp(argv[i], "--verbose") == 0) {
170 options.verbose_ = true; 165 options.verbose_ = true;
171 } else if (strncmp(argv[i], "--output=", 9) == 0) { 166 } else if (strncmp(argv[i], "--output=", 9) == 0) {
172 options.output_filename_ = argv[i] + 9; 167 options.output_filename_ = argv[i] + 9;
173 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) { 168 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) {
174 options.test_function_name_ = argv[i] + 21; 169 options.test_function_name_ = argv[i] + 21;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 240
246 void ProgramOptions::UpdateFromHeader(std::istream& stream) { 241 void ProgramOptions::UpdateFromHeader(std::istream& stream) {
247 std::string line; 242 std::string line;
248 243
249 // Skip to the beginning of the options header 244 // Skip to the beginning of the options header
250 while (std::getline(stream, line)) { 245 while (std::getline(stream, line)) {
251 if (line == "---") break; 246 if (line == "---") break;
252 } 247 }
253 248
254 while (std::getline(stream, line)) { 249 while (std::getline(stream, line)) {
255 if (line.compare(0, 9, "execute: ") == 0) { 250 if (line.compare(0, 6, "wrap: ") == 0) {
256 execute_ = ParseBoolean(line.c_str() + 9);
257 } else if (line.compare(0, 6, "wrap: ") == 0) {
258 wrap_ = ParseBoolean(line.c_str() + 6); 251 wrap_ = ParseBoolean(line.c_str() + 6);
259 } else if (line.compare(0, 20, "test function name: ") == 0) { 252 } else if (line.compare(0, 20, "test function name: ") == 0) {
260 test_function_name_ = line.c_str() + 20; 253 test_function_name_ = line.c_str() + 20;
261 } else if (line.compare(0, 11, "top level: ") == 0) { 254 } else if (line.compare(0, 11, "top level: ") == 0) {
262 top_level_ = ParseBoolean(line.c_str() + 11); 255 top_level_ = ParseBoolean(line.c_str() + 11);
263 } else if (line.compare(0, 16, "do expressions: ") == 0) { 256 } else if (line.compare(0, 16, "do expressions: ") == 0) {
264 do_expressions_ = ParseBoolean(line.c_str() + 16); 257 do_expressions_ = ParseBoolean(line.c_str() + 16);
265 } else if (line == "---") { 258 } else if (line == "---") {
266 break; 259 break;
267 } else if (line.empty()) { 260 } else if (line.empty()) {
268 continue; 261 continue;
269 } else { 262 } else {
270 UNREACHABLE(); 263 UNREACHABLE();
271 return; 264 return;
272 } 265 }
273 } 266 }
274 } 267 }
275 268
276 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT 269 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT
277 stream << "---" 270 stream << "---"
278 << "\nexecute: " << BooleanToString(execute_)
279 << "\nwrap: " << BooleanToString(wrap_); 271 << "\nwrap: " << BooleanToString(wrap_);
280 272
281 if (!test_function_name_.empty()) { 273 if (!test_function_name_.empty()) {
282 stream << "\ntest function name: " << test_function_name_; 274 stream << "\ntest function name: " << test_function_name_;
283 } 275 }
284 276
285 if (top_level_) stream << "\ntop level: yes"; 277 if (top_level_) stream << "\ntop level: yes";
286 if (do_expressions_) stream << "\ndo expressions: yes"; 278 if (do_expressions_) stream << "\ndo expressions: yes";
287 279
288 stream << "\n\n"; 280 stream << "\n\n";
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 const std::vector<std::string>& snippet_list, 366 const std::vector<std::string>& snippet_list,
375 const V8InitializationScope& platform, 367 const V8InitializationScope& platform,
376 const ProgramOptions& options) { 368 const ProgramOptions& options) {
377 v8::Isolate::Scope isolate_scope(platform.isolate()); 369 v8::Isolate::Scope isolate_scope(platform.isolate());
378 v8::HandleScope handle_scope(platform.isolate()); 370 v8::HandleScope handle_scope(platform.isolate());
379 v8::Local<v8::Context> context = v8::Context::New(platform.isolate()); 371 v8::Local<v8::Context> context = v8::Context::New(platform.isolate());
380 v8::Context::Scope context_scope(context); 372 v8::Context::Scope context_scope(context);
381 373
382 BytecodeExpectationsPrinter printer(platform.isolate()); 374 BytecodeExpectationsPrinter printer(platform.isolate());
383 printer.set_wrap(options.wrap()); 375 printer.set_wrap(options.wrap());
384 printer.set_execute(options.execute());
385 printer.set_top_level(options.top_level()); 376 printer.set_top_level(options.top_level());
386 if (!options.test_function_name().empty()) { 377 if (!options.test_function_name().empty()) {
387 printer.set_test_function_name(options.test_function_name()); 378 printer.set_test_function_name(options.test_function_name());
388 } 379 }
389 380
390 if (options.do_expressions()) i::FLAG_harmony_do_expressions = true; 381 if (options.do_expressions()) i::FLAG_harmony_do_expressions = true;
391 382
392 stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n"; 383 stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n";
393 options.PrintHeader(stream); 384 options.PrintHeader(stream);
394 for (const std::string& snippet : snippet_list) { 385 for (const std::string& snippet : snippet_list) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 std::cerr 419 std::cerr
429 << "\nUsage: " << exec_path 420 << "\nUsage: " << exec_path
430 << " [OPTIONS]... [INPUT FILES]...\n\n" 421 << " [OPTIONS]... [INPUT FILES]...\n\n"
431 "Options:\n" 422 "Options:\n"
432 " --help Print this help message.\n" 423 " --help Print this help message.\n"
433 " --verbose Emit messages about the progress of the tool.\n" 424 " --verbose Emit messages about the progress of the tool.\n"
434 " --raw-js Read raw JavaScript, instead of the output format.\n" 425 " --raw-js Read raw JavaScript, instead of the output format.\n"
435 " --stdin Read from standard input instead of file.\n" 426 " --stdin Read from standard input instead of file.\n"
436 " --rebaseline Rebaseline input snippet file.\n" 427 " --rebaseline Rebaseline input snippet file.\n"
437 " --no-wrap Do not wrap the snippet in a function.\n" 428 " --no-wrap Do not wrap the snippet in a function.\n"
438 " --no-execute Do not execute after compilation.\n"
439 " --test-function-name=foo " 429 " --test-function-name=foo "
440 "Specify the name of the test function.\n" 430 "Specify the name of the test function.\n"
441 " --top-level Process top level code, not the top-level function.\n" 431 " --top-level Process top level code, not the top-level function.\n"
442 " --do-expressions Enable harmony_do_expressions flag.\n" 432 " --do-expressions Enable harmony_do_expressions flag.\n"
443 " --output=file.name\n" 433 " --output=file.name\n"
444 " Specify the output file. If not specified, output goes to " 434 " Specify the output file. If not specified, output goes to "
445 "stdout.\n" 435 "stdout.\n"
446 " --pool-type=(number|string|mixed)\n" 436 " --pool-type=(number|string|mixed)\n"
447 " Specify the type of the entries in the constant pool " 437 " Specify the type of the entries in the constant pool "
448 "(default: mixed).\n" 438 "(default: mixed).\n"
449 "\n" 439 "\n"
450 "When using --rebaseline, flags --no-wrap, --no-execute, " 440 "When using --rebaseline, flags --no-wrap, --test-function-name \n"
451 "--test-function-name\nand --pool-type will be overridden by the " 441 "and --pool-type will be overridden by the options specified in \n"
452 "options specified in the input file\nheader.\n\n" 442 "the input file header.\n\n"
453 "Each raw JavaScript file is interpreted as a single snippet.\n\n" 443 "Each raw JavaScript file is interpreted as a single snippet.\n\n"
454 "This tool is intended as a help in writing tests.\n" 444 "This tool is intended as a help in writing tests.\n"
455 "Please, DO NOT blindly copy and paste the output " 445 "Please, DO NOT blindly copy and paste the output "
456 "into the test suite.\n"; 446 "into the test suite.\n";
457 } 447 }
458 448
459 } // namespace 449 } // namespace
460 450
461 int main(int argc, char** argv) { 451 int main(int argc, char** argv) {
462 ProgramOptions options = ProgramOptions::FromCommandLine(argc, argv); 452 ProgramOptions options = ProgramOptions::FromCommandLine(argc, argv);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 } 498 }
509 } 499 }
510 500
511 if (!options.rebaseline()) { 501 if (!options.rebaseline()) {
512 if (!WriteExpectationsFile(snippet_list, platform, options, 502 if (!WriteExpectationsFile(snippet_list, platform, options,
513 options.output_filename())) { 503 options.output_filename())) {
514 return 3; 504 return 3;
515 } 505 }
516 } 506 }
517 } 507 }
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/WithStatement.golden ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698