OLD | NEW |
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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "test/cctest/interpreter/bytecode-expectations-printer.h" | 9 #include "test/cctest/interpreter/bytecode-expectations-printer.h" |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 ProgramOptions() | 37 ProgramOptions() |
38 : parsing_failed_(false), | 38 : parsing_failed_(false), |
39 print_help_(false), | 39 print_help_(false), |
40 read_raw_js_snippet_(false), | 40 read_raw_js_snippet_(false), |
41 read_from_stdin_(false), | 41 read_from_stdin_(false), |
42 rebaseline_(false), | 42 rebaseline_(false), |
43 wrap_(true), | 43 wrap_(true), |
44 execute_(true), | 44 execute_(true), |
45 top_level_(false), | 45 top_level_(false), |
46 do_expressions_(false), | 46 do_expressions_(false), |
| 47 ignition_generators_(false), |
47 verbose_(false), | 48 verbose_(false), |
48 const_pool_type_( | 49 const_pool_type_( |
49 BytecodeExpectationsPrinter::ConstantPoolType::kMixed) {} | 50 BytecodeExpectationsPrinter::ConstantPoolType::kMixed) {} |
50 | 51 |
51 bool Validate() const; | 52 bool Validate() const; |
52 void UpdateFromHeader(std::istream& stream); // NOLINT | 53 void UpdateFromHeader(std::istream& stream); // NOLINT |
53 void PrintHeader(std::ostream& stream) const; // NOLINT | 54 void PrintHeader(std::ostream& stream) const; // NOLINT |
54 | 55 |
55 bool parsing_failed() const { return parsing_failed_; } | 56 bool parsing_failed() const { return parsing_failed_; } |
56 bool print_help() const { return print_help_; } | 57 bool print_help() const { return print_help_; } |
57 bool read_raw_js_snippet() const { return read_raw_js_snippet_; } | 58 bool read_raw_js_snippet() const { return read_raw_js_snippet_; } |
58 bool read_from_stdin() const { return read_from_stdin_; } | 59 bool read_from_stdin() const { return read_from_stdin_; } |
59 bool write_to_stdout() const { | 60 bool write_to_stdout() const { |
60 return output_filename_.empty() && !rebaseline_; | 61 return output_filename_.empty() && !rebaseline_; |
61 } | 62 } |
62 bool rebaseline() const { return rebaseline_; } | 63 bool rebaseline() const { return rebaseline_; } |
63 bool wrap() const { return wrap_; } | 64 bool wrap() const { return wrap_; } |
64 bool execute() const { return execute_; } | 65 bool execute() const { return execute_; } |
65 bool top_level() const { return top_level_; } | 66 bool top_level() const { return top_level_; } |
66 bool do_expressions() const { return do_expressions_; } | 67 bool do_expressions() const { return do_expressions_; } |
| 68 bool ignition_generators() const { return ignition_generators_; } |
67 bool verbose() const { return verbose_; } | 69 bool verbose() const { return verbose_; } |
68 bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; } | 70 bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; } |
69 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type() const { | 71 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type() const { |
70 return const_pool_type_; | 72 return const_pool_type_; |
71 } | 73 } |
72 std::vector<std::string> input_filenames() const { return input_filenames_; } | 74 std::vector<std::string> input_filenames() const { return input_filenames_; } |
73 std::string output_filename() const { return output_filename_; } | 75 std::string output_filename() const { return output_filename_; } |
74 std::string test_function_name() const { return test_function_name_; } | 76 std::string test_function_name() const { return test_function_name_; } |
75 | 77 |
76 private: | 78 private: |
77 bool parsing_failed_; | 79 bool parsing_failed_; |
78 bool print_help_; | 80 bool print_help_; |
79 bool read_raw_js_snippet_; | 81 bool read_raw_js_snippet_; |
80 bool read_from_stdin_; | 82 bool read_from_stdin_; |
81 bool rebaseline_; | 83 bool rebaseline_; |
82 bool wrap_; | 84 bool wrap_; |
83 bool execute_; | 85 bool execute_; |
84 bool top_level_; | 86 bool top_level_; |
85 bool do_expressions_; | 87 bool do_expressions_; |
| 88 bool ignition_generators_; |
86 bool verbose_; | 89 bool verbose_; |
87 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_; | 90 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_; |
88 std::vector<std::string> input_filenames_; | 91 std::vector<std::string> input_filenames_; |
89 std::string output_filename_; | 92 std::string output_filename_; |
90 std::string test_function_name_; | 93 std::string test_function_name_; |
91 }; | 94 }; |
92 | 95 |
93 class ArrayBufferAllocator final : public v8::ArrayBuffer::Allocator { | 96 class ArrayBufferAllocator final : public v8::ArrayBuffer::Allocator { |
94 public: | 97 public: |
95 void* Allocate(size_t length) override { | 98 void* Allocate(size_t length) override { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } else if (strcmp(argv[i], "--rebaseline") == 0) { | 208 } else if (strcmp(argv[i], "--rebaseline") == 0) { |
206 options.rebaseline_ = true; | 209 options.rebaseline_ = true; |
207 } else if (strcmp(argv[i], "--no-wrap") == 0) { | 210 } else if (strcmp(argv[i], "--no-wrap") == 0) { |
208 options.wrap_ = false; | 211 options.wrap_ = false; |
209 } else if (strcmp(argv[i], "--no-execute") == 0) { | 212 } else if (strcmp(argv[i], "--no-execute") == 0) { |
210 options.execute_ = false; | 213 options.execute_ = false; |
211 } else if (strcmp(argv[i], "--top-level") == 0) { | 214 } else if (strcmp(argv[i], "--top-level") == 0) { |
212 options.top_level_ = true; | 215 options.top_level_ = true; |
213 } else if (strcmp(argv[i], "--do-expressions") == 0) { | 216 } else if (strcmp(argv[i], "--do-expressions") == 0) { |
214 options.do_expressions_ = true; | 217 options.do_expressions_ = true; |
| 218 } else if (strcmp(argv[i], "--ignition-generators") == 0) { |
| 219 options.ignition_generators_ = true; |
215 } else if (strcmp(argv[i], "--verbose") == 0) { | 220 } else if (strcmp(argv[i], "--verbose") == 0) { |
216 options.verbose_ = true; | 221 options.verbose_ = true; |
217 } else if (strncmp(argv[i], "--output=", 9) == 0) { | 222 } else if (strncmp(argv[i], "--output=", 9) == 0) { |
218 options.output_filename_ = argv[i] + 9; | 223 options.output_filename_ = argv[i] + 9; |
219 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) { | 224 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) { |
220 options.test_function_name_ = argv[i] + 21; | 225 options.test_function_name_ = argv[i] + 21; |
221 } else if (strncmp(argv[i], "--", 2) != 0) { // It doesn't start with -- | 226 } else if (strncmp(argv[i], "--", 2) != 0) { // It doesn't start with -- |
222 options.input_filenames_.push_back(argv[i]); | 227 options.input_filenames_.push_back(argv[i]); |
223 } else { | 228 } else { |
224 REPORT_ERROR("Unknown option " << argv[i]); | 229 REPORT_ERROR("Unknown option " << argv[i]); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } else if (line.compare(0, 9, "execute: ") == 0) { | 314 } else if (line.compare(0, 9, "execute: ") == 0) { |
310 execute_ = ParseBoolean(line.c_str() + 9); | 315 execute_ = ParseBoolean(line.c_str() + 9); |
311 } else if (line.compare(0, 6, "wrap: ") == 0) { | 316 } else if (line.compare(0, 6, "wrap: ") == 0) { |
312 wrap_ = ParseBoolean(line.c_str() + 6); | 317 wrap_ = ParseBoolean(line.c_str() + 6); |
313 } else if (line.compare(0, 20, "test function name: ") == 0) { | 318 } else if (line.compare(0, 20, "test function name: ") == 0) { |
314 test_function_name_ = line.c_str() + 20; | 319 test_function_name_ = line.c_str() + 20; |
315 } else if (line.compare(0, 11, "top level: ") == 0) { | 320 } else if (line.compare(0, 11, "top level: ") == 0) { |
316 top_level_ = ParseBoolean(line.c_str() + 11); | 321 top_level_ = ParseBoolean(line.c_str() + 11); |
317 } else if (line.compare(0, 16, "do expressions: ") == 0) { | 322 } else if (line.compare(0, 16, "do expressions: ") == 0) { |
318 do_expressions_ = ParseBoolean(line.c_str() + 16); | 323 do_expressions_ = ParseBoolean(line.c_str() + 16); |
| 324 } else if (line.compare(0, 21, "ignition generators: ") == 0) { |
| 325 do_expressions_ = ParseBoolean(line.c_str() + 21); |
319 } else if (line == "---") { | 326 } else if (line == "---") { |
320 break; | 327 break; |
321 } else if (line.empty()) { | 328 } else if (line.empty()) { |
322 continue; | 329 continue; |
323 } else { | 330 } else { |
324 UNREACHABLE(); | 331 UNREACHABLE(); |
325 return; | 332 return; |
326 } | 333 } |
327 } | 334 } |
328 } | 335 } |
329 | 336 |
330 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT | 337 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT |
331 stream << "---" | 338 stream << "---" |
332 "\npool type: " | 339 "\npool type: " |
333 << ConstantPoolTypeToString(const_pool_type_) | 340 << ConstantPoolTypeToString(const_pool_type_) |
334 << "\nexecute: " << BooleanToString(execute_) | 341 << "\nexecute: " << BooleanToString(execute_) |
335 << "\nwrap: " << BooleanToString(wrap_); | 342 << "\nwrap: " << BooleanToString(wrap_); |
336 | 343 |
337 if (!test_function_name_.empty()) { | 344 if (!test_function_name_.empty()) { |
338 stream << "\ntest function name: " << test_function_name_; | 345 stream << "\ntest function name: " << test_function_name_; |
339 } | 346 } |
340 | 347 |
341 if (top_level_) stream << "\ntop level: yes"; | 348 if (top_level_) stream << "\ntop level: yes"; |
342 if (do_expressions_) stream << "\ndo expressions: yes"; | 349 if (do_expressions_) stream << "\ndo expressions: yes"; |
| 350 if (ignition_generators_) stream << "\nignition generators: yes"; |
343 | 351 |
344 stream << "\n\n"; | 352 stream << "\n\n"; |
345 } | 353 } |
346 | 354 |
347 V8InitializationScope::V8InitializationScope(const char* exec_path) | 355 V8InitializationScope::V8InitializationScope(const char* exec_path) |
348 : platform_(v8::platform::CreateDefaultPlatform()) { | 356 : platform_(v8::platform::CreateDefaultPlatform()) { |
349 i::FLAG_ignition = true; | 357 i::FLAG_ignition = true; |
350 i::FLAG_always_opt = false; | 358 i::FLAG_always_opt = false; |
351 i::FLAG_allow_natives_syntax = true; | 359 i::FLAG_allow_natives_syntax = true; |
352 | 360 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 BytecodeExpectationsPrinter printer(platform.isolate(), | 446 BytecodeExpectationsPrinter printer(platform.isolate(), |
439 options.const_pool_type()); | 447 options.const_pool_type()); |
440 printer.set_wrap(options.wrap()); | 448 printer.set_wrap(options.wrap()); |
441 printer.set_execute(options.execute()); | 449 printer.set_execute(options.execute()); |
442 printer.set_top_level(options.top_level()); | 450 printer.set_top_level(options.top_level()); |
443 if (!options.test_function_name().empty()) { | 451 if (!options.test_function_name().empty()) { |
444 printer.set_test_function_name(options.test_function_name()); | 452 printer.set_test_function_name(options.test_function_name()); |
445 } | 453 } |
446 | 454 |
447 if (options.do_expressions()) i::FLAG_harmony_do_expressions = true; | 455 if (options.do_expressions()) i::FLAG_harmony_do_expressions = true; |
| 456 if (options.ignition_generators()) i::FLAG_ignition_generators = true; |
448 | 457 |
449 stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n"; | 458 stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n"; |
450 options.PrintHeader(stream); | 459 options.PrintHeader(stream); |
451 for (const std::string& snippet : snippet_list) { | 460 for (const std::string& snippet : snippet_list) { |
452 printer.PrintExpectation(stream, snippet); | 461 printer.PrintExpectation(stream, snippet); |
453 } | 462 } |
454 | 463 |
455 i::FLAG_harmony_do_expressions = false; | 464 i::FLAG_harmony_do_expressions = false; |
456 } | 465 } |
457 | 466 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 " --verbose Emit messages about the progress of the tool.\n" | 499 " --verbose Emit messages about the progress of the tool.\n" |
491 " --raw-js Read raw JavaScript, instead of the output format.\n" | 500 " --raw-js Read raw JavaScript, instead of the output format.\n" |
492 " --stdin Read from standard input instead of file.\n" | 501 " --stdin Read from standard input instead of file.\n" |
493 " --rebaseline Rebaseline input snippet file.\n" | 502 " --rebaseline Rebaseline input snippet file.\n" |
494 " --no-wrap Do not wrap the snippet in a function.\n" | 503 " --no-wrap Do not wrap the snippet in a function.\n" |
495 " --no-execute Do not execute after compilation.\n" | 504 " --no-execute Do not execute after compilation.\n" |
496 " --test-function-name=foo " | 505 " --test-function-name=foo " |
497 "Specify the name of the test function.\n" | 506 "Specify the name of the test function.\n" |
498 " --top-level Process top level code, not the top-level function.\n" | 507 " --top-level Process top level code, not the top-level function.\n" |
499 " --do-expressions Enable harmony_do_expressions flag.\n" | 508 " --do-expressions Enable harmony_do_expressions flag.\n" |
| 509 " --ignition-generators Enable ignition_generators flag.\n" |
500 " --output=file.name\n" | 510 " --output=file.name\n" |
501 " Specify the output file. If not specified, output goes to " | 511 " Specify the output file. If not specified, output goes to " |
502 "stdout.\n" | 512 "stdout.\n" |
503 " --pool-type=(number|string|mixed)\n" | 513 " --pool-type=(number|string|mixed)\n" |
504 " Specify the type of the entries in the constant pool " | 514 " Specify the type of the entries in the constant pool " |
505 "(default: mixed).\n" | 515 "(default: mixed).\n" |
506 "\n" | 516 "\n" |
507 "When using --rebaseline, flags --no-wrap, --no-execute, " | 517 "When using --rebaseline, flags --no-wrap, --no-execute, " |
508 "--test-function-name\nand --pool-type will be overridden by the " | 518 "--test-function-name\nand --pool-type will be overridden by the " |
509 "options specified in the input file\nheader.\n\n" | 519 "options specified in the input file\nheader.\n\n" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 } | 575 } |
566 } | 576 } |
567 | 577 |
568 if (!options.rebaseline()) { | 578 if (!options.rebaseline()) { |
569 if (!WriteExpectationsFile(snippet_list, platform, options, | 579 if (!WriteExpectationsFile(snippet_list, platform, options, |
570 options.output_filename())) { | 580 options.output_filename())) { |
571 return 3; | 581 return 3; |
572 } | 582 } |
573 } | 583 } |
574 } | 584 } |
OLD | NEW |