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

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

Issue 2645313003: [async-iteration] implement Async-from-Sync Iterator (Closed)
Patch Set: cleanmerge Created 3 years, 10 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 25 matching lines...) Expand all
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 module_(false), 43 module_(false),
44 top_level_(false), 44 top_level_(false),
45 do_expressions_(false), 45 do_expressions_(false),
46 async_iteration_(false),
46 verbose_(false) {} 47 verbose_(false) {}
47 48
48 bool Validate() const; 49 bool Validate() const;
49 void UpdateFromHeader(std::istream& stream); // NOLINT 50 void UpdateFromHeader(std::istream& stream); // NOLINT
50 void PrintHeader(std::ostream& stream) const; // NOLINT 51 void PrintHeader(std::ostream& stream) const; // NOLINT
51 52
52 bool parsing_failed() const { return parsing_failed_; } 53 bool parsing_failed() const { return parsing_failed_; }
53 bool print_help() const { return print_help_; } 54 bool print_help() const { return print_help_; }
54 bool read_raw_js_snippet() const { return read_raw_js_snippet_; } 55 bool read_raw_js_snippet() const { return read_raw_js_snippet_; }
55 bool read_from_stdin() const { return read_from_stdin_; } 56 bool read_from_stdin() const { return read_from_stdin_; }
56 bool write_to_stdout() const { 57 bool write_to_stdout() const {
57 return output_filename_.empty() && !rebaseline_; 58 return output_filename_.empty() && !rebaseline_;
58 } 59 }
59 bool rebaseline() const { return rebaseline_; } 60 bool rebaseline() const { return rebaseline_; }
60 bool wrap() const { return wrap_; } 61 bool wrap() const { return wrap_; }
61 bool module() const { return module_; } 62 bool module() const { return module_; }
62 bool top_level() const { return top_level_; } 63 bool top_level() const { return top_level_; }
63 bool do_expressions() const { return do_expressions_; } 64 bool do_expressions() const { return do_expressions_; }
65 bool async_iteration() const { return async_iteration_; }
64 bool verbose() const { return verbose_; } 66 bool verbose() const { return verbose_; }
65 bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; } 67 bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; }
66 std::vector<std::string> input_filenames() const { return input_filenames_; } 68 std::vector<std::string> input_filenames() const { return input_filenames_; }
67 std::string output_filename() const { return output_filename_; } 69 std::string output_filename() const { return output_filename_; }
68 std::string test_function_name() const { return test_function_name_; } 70 std::string test_function_name() const { return test_function_name_; }
69 71
70 private: 72 private:
71 bool parsing_failed_; 73 bool parsing_failed_;
72 bool print_help_; 74 bool print_help_;
73 bool read_raw_js_snippet_; 75 bool read_raw_js_snippet_;
74 bool read_from_stdin_; 76 bool read_from_stdin_;
75 bool rebaseline_; 77 bool rebaseline_;
76 bool wrap_; 78 bool wrap_;
77 bool module_; 79 bool module_;
78 bool top_level_; 80 bool top_level_;
79 bool do_expressions_; 81 bool do_expressions_;
82 bool async_iteration_;
80 bool verbose_; 83 bool verbose_;
81 std::vector<std::string> input_filenames_; 84 std::vector<std::string> input_filenames_;
82 std::string output_filename_; 85 std::string output_filename_;
83 std::string test_function_name_; 86 std::string test_function_name_;
84 }; 87 };
85 88
86 class V8InitializationScope final { 89 class V8InitializationScope final {
87 public: 90 public:
88 explicit V8InitializationScope(const char* exec_path); 91 explicit V8InitializationScope(const char* exec_path);
89 ~V8InitializationScope(); 92 ~V8InitializationScope();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } else if (strcmp(argv[i], "--rebaseline") == 0) { 161 } else if (strcmp(argv[i], "--rebaseline") == 0) {
159 options.rebaseline_ = true; 162 options.rebaseline_ = true;
160 } else if (strcmp(argv[i], "--no-wrap") == 0) { 163 } else if (strcmp(argv[i], "--no-wrap") == 0) {
161 options.wrap_ = false; 164 options.wrap_ = false;
162 } else if (strcmp(argv[i], "--module") == 0) { 165 } else if (strcmp(argv[i], "--module") == 0) {
163 options.module_ = true; 166 options.module_ = true;
164 } else if (strcmp(argv[i], "--top-level") == 0) { 167 } else if (strcmp(argv[i], "--top-level") == 0) {
165 options.top_level_ = true; 168 options.top_level_ = true;
166 } else if (strcmp(argv[i], "--do-expressions") == 0) { 169 } else if (strcmp(argv[i], "--do-expressions") == 0) {
167 options.do_expressions_ = true; 170 options.do_expressions_ = true;
171 } else if (strcmp(argv[i], "--async-iteration") == 0) {
172 options.async_iteration_ = true;
168 } else if (strcmp(argv[i], "--verbose") == 0) { 173 } else if (strcmp(argv[i], "--verbose") == 0) {
169 options.verbose_ = true; 174 options.verbose_ = true;
170 } else if (strncmp(argv[i], "--output=", 9) == 0) { 175 } else if (strncmp(argv[i], "--output=", 9) == 0) {
171 options.output_filename_ = argv[i] + 9; 176 options.output_filename_ = argv[i] + 9;
172 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) { 177 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) {
173 options.test_function_name_ = argv[i] + 21; 178 options.test_function_name_ = argv[i] + 21;
174 } else if (strncmp(argv[i], "--", 2) != 0) { // It doesn't start with -- 179 } else if (strncmp(argv[i], "--", 2) != 0) { // It doesn't start with --
175 options.input_filenames_.push_back(argv[i]); 180 options.input_filenames_.push_back(argv[i]);
176 } else { 181 } else {
177 REPORT_ERROR("Unknown option " << argv[i]); 182 REPORT_ERROR("Unknown option " << argv[i]);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (line.compare(0, 8, "module: ") == 0) { 265 if (line.compare(0, 8, "module: ") == 0) {
261 module_ = ParseBoolean(line.c_str() + 8); 266 module_ = ParseBoolean(line.c_str() + 8);
262 } else if (line.compare(0, 6, "wrap: ") == 0) { 267 } else if (line.compare(0, 6, "wrap: ") == 0) {
263 wrap_ = ParseBoolean(line.c_str() + 6); 268 wrap_ = ParseBoolean(line.c_str() + 6);
264 } else if (line.compare(0, 20, "test function name: ") == 0) { 269 } else if (line.compare(0, 20, "test function name: ") == 0) {
265 test_function_name_ = line.c_str() + 20; 270 test_function_name_ = line.c_str() + 20;
266 } else if (line.compare(0, 11, "top level: ") == 0) { 271 } else if (line.compare(0, 11, "top level: ") == 0) {
267 top_level_ = ParseBoolean(line.c_str() + 11); 272 top_level_ = ParseBoolean(line.c_str() + 11);
268 } else if (line.compare(0, 16, "do expressions: ") == 0) { 273 } else if (line.compare(0, 16, "do expressions: ") == 0) {
269 do_expressions_ = ParseBoolean(line.c_str() + 16); 274 do_expressions_ = ParseBoolean(line.c_str() + 16);
275 } else if (line.compare(0, 17, "async iteration: ") == 0) {
276 async_iteration_ = ParseBoolean(line.c_str() + 17);
270 } else if (line == "---") { 277 } else if (line == "---") {
271 break; 278 break;
272 } else if (line.empty()) { 279 } else if (line.empty()) {
273 continue; 280 continue;
274 } else { 281 } else {
275 UNREACHABLE(); 282 UNREACHABLE();
276 return; 283 return;
277 } 284 }
278 } 285 }
279 } 286 }
280 287
281 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT 288 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT
282 stream << "---" 289 stream << "---"
283 << "\nwrap: " << BooleanToString(wrap_); 290 << "\nwrap: " << BooleanToString(wrap_);
284 291
285 if (!test_function_name_.empty()) { 292 if (!test_function_name_.empty()) {
286 stream << "\ntest function name: " << test_function_name_; 293 stream << "\ntest function name: " << test_function_name_;
287 } 294 }
288 295
289 if (module_) stream << "\nmodule: yes"; 296 if (module_) stream << "\nmodule: yes";
290 if (top_level_) stream << "\ntop level: yes"; 297 if (top_level_) stream << "\ntop level: yes";
291 if (do_expressions_) stream << "\ndo expressions: yes"; 298 if (do_expressions_) stream << "\ndo expressions: yes";
299 if (async_iteration_) stream << "\nasync iteration: yes";
292 300
293 stream << "\n\n"; 301 stream << "\n\n";
294 } 302 }
295 303
296 V8InitializationScope::V8InitializationScope(const char* exec_path) 304 V8InitializationScope::V8InitializationScope(const char* exec_path)
297 : platform_(v8::platform::CreateDefaultPlatform()) { 305 : platform_(v8::platform::CreateDefaultPlatform()) {
298 i::FLAG_ignition = true; 306 i::FLAG_ignition = true;
299 i::FLAG_always_opt = false; 307 i::FLAG_always_opt = false;
300 i::FLAG_allow_natives_syntax = true; 308 i::FLAG_allow_natives_syntax = true;
301 309
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 394
387 BytecodeExpectationsPrinter printer(platform.isolate()); 395 BytecodeExpectationsPrinter printer(platform.isolate());
388 printer.set_wrap(options.wrap()); 396 printer.set_wrap(options.wrap());
389 printer.set_module(options.module()); 397 printer.set_module(options.module());
390 printer.set_top_level(options.top_level()); 398 printer.set_top_level(options.top_level());
391 if (!options.test_function_name().empty()) { 399 if (!options.test_function_name().empty()) {
392 printer.set_test_function_name(options.test_function_name()); 400 printer.set_test_function_name(options.test_function_name());
393 } 401 }
394 402
395 if (options.do_expressions()) i::FLAG_harmony_do_expressions = true; 403 if (options.do_expressions()) i::FLAG_harmony_do_expressions = true;
404 if (options.async_iteration()) i::FLAG_harmony_async_iteration = true;
396 405
397 stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n"; 406 stream << "#\n# Autogenerated by generate-bytecode-expectations.\n#\n\n";
398 options.PrintHeader(stream); 407 options.PrintHeader(stream);
399 for (const std::string& snippet : snippet_list) { 408 for (const std::string& snippet : snippet_list) {
400 printer.PrintExpectation(stream, snippet); 409 printer.PrintExpectation(stream, snippet);
401 } 410 }
402 411
403 i::FLAG_harmony_do_expressions = false; 412 i::FLAG_harmony_do_expressions = false;
413 i::FLAG_harmony_async_iteration = false;
404 } 414 }
405 415
406 bool WriteExpectationsFile(const std::vector<std::string>& snippet_list, 416 bool WriteExpectationsFile(const std::vector<std::string>& snippet_list,
407 const V8InitializationScope& platform, 417 const V8InitializationScope& platform,
408 const ProgramOptions& options, 418 const ProgramOptions& options,
409 const std::string& output_filename) { 419 const std::string& output_filename) {
410 std::ofstream output_file_handle; 420 std::ofstream output_file_handle;
411 if (!options.write_to_stdout()) { 421 if (!options.write_to_stdout()) {
412 output_file_handle.open(output_filename.c_str()); 422 output_file_handle.open(output_filename.c_str());
413 if (!output_file_handle.is_open()) { 423 if (!output_file_handle.is_open()) {
(...skipping 24 matching lines...) Expand all
438 " --verbose Emit messages about the progress of the tool.\n" 448 " --verbose Emit messages about the progress of the tool.\n"
439 " --raw-js Read raw JavaScript, instead of the output format.\n" 449 " --raw-js Read raw JavaScript, instead of the output format.\n"
440 " --stdin Read from standard input instead of file.\n" 450 " --stdin Read from standard input instead of file.\n"
441 " --rebaseline Rebaseline input snippet file.\n" 451 " --rebaseline Rebaseline input snippet file.\n"
442 " --no-wrap Do not wrap the snippet in a function.\n" 452 " --no-wrap Do not wrap the snippet in a function.\n"
443 " --module Compile as JavaScript module.\n" 453 " --module Compile as JavaScript module.\n"
444 " --test-function-name=foo " 454 " --test-function-name=foo "
445 "Specify the name of the test function.\n" 455 "Specify the name of the test function.\n"
446 " --top-level Process top level code, not the top-level function.\n" 456 " --top-level Process top level code, not the top-level function.\n"
447 " --do-expressions Enable harmony_do_expressions flag.\n" 457 " --do-expressions Enable harmony_do_expressions flag.\n"
458 " --async-iteration Enable harmony_async_iteration flag.\n"
448 " --output=file.name\n" 459 " --output=file.name\n"
449 " Specify the output file. If not specified, output goes to " 460 " Specify the output file. If not specified, output goes to "
450 "stdout.\n" 461 "stdout.\n"
451 " --pool-type=(number|string|mixed)\n" 462 " --pool-type=(number|string|mixed)\n"
452 " Specify the type of the entries in the constant pool " 463 " Specify the type of the entries in the constant pool "
453 "(default: mixed).\n" 464 "(default: mixed).\n"
454 "\n" 465 "\n"
455 "When using --rebaseline, flags --no-wrap, --test-function-name \n" 466 "When using --rebaseline, flags --no-wrap, --test-function-name \n"
456 "and --pool-type will be overridden by the options specified in \n" 467 "and --pool-type will be overridden by the options specified in \n"
457 "the input file header.\n\n" 468 "the input file header.\n\n"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 524 }
514 } 525 }
515 526
516 if (!options.rebaseline()) { 527 if (!options.rebaseline()) {
517 if (!WriteExpectationsFile(snippet_list, platform, options, 528 if (!WriteExpectationsFile(snippet_list, platform, options,
518 options.output_filename())) { 529 options.output_filename())) {
519 return 3; 530 return 3;
520 } 531 }
521 } 532 }
522 } 533 }
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698