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

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

Issue 1716793002: [Interpreter] Support relevant FLAG_s in generate-bytecode-expectations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
« 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 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 7
8 #include "test/cctest/interpreter/bytecode-expectations-printer.h" 8 #include "test/cctest/interpreter/bytecode-expectations-printer.h"
9 9
10 #include "include/libplatform/libplatform.h" 10 #include "include/libplatform/libplatform.h"
(...skipping 14 matching lines...) Expand all
25 25
26 ProgramOptions() 26 ProgramOptions()
27 : parsing_failed_(false), 27 : parsing_failed_(false),
28 print_help_(false), 28 print_help_(false),
29 read_raw_js_snippet_(false), 29 read_raw_js_snippet_(false),
30 read_from_stdin_(false), 30 read_from_stdin_(false),
31 rebaseline_(false), 31 rebaseline_(false),
32 wrap_(true), 32 wrap_(true),
33 execute_(true), 33 execute_(true),
34 top_level_(false), 34 top_level_(false),
35 legacy_const_(false),
36 do_expressions_(false),
35 const_pool_type_( 37 const_pool_type_(
36 BytecodeExpectationsPrinter::ConstantPoolType::kMixed) {} 38 BytecodeExpectationsPrinter::ConstantPoolType::kMixed) {}
37 39
38 bool Validate() const; 40 bool Validate() const;
39 void UpdateFromHeader(std::istream& stream); // NOLINT 41 void UpdateFromHeader(std::istream& stream); // NOLINT
40 void PrintHeader(std::ostream& stream) const; // NOLINT 42 void PrintHeader(std::ostream& stream) const; // NOLINT
41 43
42 bool parsing_failed() const { return parsing_failed_; } 44 bool parsing_failed() const { return parsing_failed_; }
43 bool print_help() const { return print_help_; } 45 bool print_help() const { return print_help_; }
44 bool read_raw_js_snippet() const { return read_raw_js_snippet_; } 46 bool read_raw_js_snippet() const { return read_raw_js_snippet_; }
45 bool read_from_stdin() const { return read_from_stdin_; } 47 bool read_from_stdin() const { return read_from_stdin_; }
46 bool write_to_stdout() const { 48 bool write_to_stdout() const {
47 return output_filename_.empty() && !rebaseline_; 49 return output_filename_.empty() && !rebaseline_;
48 } 50 }
49 bool rebaseline() const { return rebaseline_; } 51 bool rebaseline() const { return rebaseline_; }
50 bool wrap() const { return wrap_; } 52 bool wrap() const { return wrap_; }
51 bool execute() const { return execute_; } 53 bool execute() const { return execute_; }
52 bool top_level() const { return top_level_; } 54 bool top_level() const { return top_level_; }
55 bool legacy_const() const { return legacy_const_; }
56 bool do_expressions() const { return do_expressions_; }
53 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type() const { 57 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type() const {
54 return const_pool_type_; 58 return const_pool_type_;
55 } 59 }
56 std::string input_filename() const { return input_filename_; } 60 std::string input_filename() const { return input_filename_; }
57 std::string output_filename() const { return output_filename_; } 61 std::string output_filename() const { return output_filename_; }
58 std::string test_function_name() const { return test_function_name_; } 62 std::string test_function_name() const { return test_function_name_; }
59 63
60 private: 64 private:
61 bool parsing_failed_; 65 bool parsing_failed_;
62 bool print_help_; 66 bool print_help_;
63 bool read_raw_js_snippet_; 67 bool read_raw_js_snippet_;
64 bool read_from_stdin_; 68 bool read_from_stdin_;
65 bool rebaseline_; 69 bool rebaseline_;
66 bool wrap_; 70 bool wrap_;
67 bool execute_; 71 bool execute_;
68 bool top_level_; 72 bool top_level_;
73 bool legacy_const_;
74 bool do_expressions_;
69 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_; 75 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_;
70 std::string input_filename_; 76 std::string input_filename_;
71 std::string output_filename_; 77 std::string output_filename_;
72 std::string test_function_name_; 78 std::string test_function_name_;
73 }; 79 };
74 80
75 class ArrayBufferAllocator final : public v8::ArrayBuffer::Allocator { 81 class ArrayBufferAllocator final : public v8::ArrayBuffer::Allocator {
76 public: 82 public:
77 void* Allocate(size_t length) override { 83 void* Allocate(size_t length) override {
78 void* data = AllocateUninitialized(length); 84 void* data = AllocateUninitialized(length);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } else if (strcmp(argv[i], "--stdin") == 0) { 158 } else if (strcmp(argv[i], "--stdin") == 0) {
153 options.read_from_stdin_ = true; 159 options.read_from_stdin_ = true;
154 } else if (strcmp(argv[i], "--rebaseline") == 0) { 160 } else if (strcmp(argv[i], "--rebaseline") == 0) {
155 options.rebaseline_ = true; 161 options.rebaseline_ = true;
156 } else if (strcmp(argv[i], "--no-wrap") == 0) { 162 } else if (strcmp(argv[i], "--no-wrap") == 0) {
157 options.wrap_ = false; 163 options.wrap_ = false;
158 } else if (strcmp(argv[i], "--no-execute") == 0) { 164 } else if (strcmp(argv[i], "--no-execute") == 0) {
159 options.execute_ = false; 165 options.execute_ = false;
160 } else if (strcmp(argv[i], "--top-level") == 0) { 166 } else if (strcmp(argv[i], "--top-level") == 0) {
161 options.top_level_ = true; 167 options.top_level_ = true;
168 } else if (strcmp(argv[i], "--legacy-const") == 0) {
169 options.legacy_const_ = true;
170 } else if (strcmp(argv[i], "--do-expressions") == 0) {
171 options.do_expressions_ = true;
162 } else if (strncmp(argv[i], "--output=", 9) == 0) { 172 } else if (strncmp(argv[i], "--output=", 9) == 0) {
163 options.output_filename_ = argv[i] + 9; 173 options.output_filename_ = argv[i] + 9;
164 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) { 174 } else if (strncmp(argv[i], "--test-function-name=", 21) == 0) {
165 options.test_function_name_ = argv[i] + 21; 175 options.test_function_name_ = argv[i] + 21;
166 } else if (strncmp(argv[i], "--", 2) != 0) { // It doesn't start with -- 176 } else if (strncmp(argv[i], "--", 2) != 0) { // It doesn't start with --
167 if (!options.input_filename_.empty()) { 177 if (!options.input_filename_.empty()) {
168 std::cerr << "ERROR: More than one input file specified\n"; 178 std::cerr << "ERROR: More than one input file specified\n";
169 options.parsing_failed_ = true; 179 options.parsing_failed_ = true;
170 break; 180 break;
171 } 181 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (line.compare(0, 11, "pool type: ") == 0) { 236 if (line.compare(0, 11, "pool type: ") == 0) {
227 const_pool_type_ = ParseConstantPoolType(line.c_str() + 11); 237 const_pool_type_ = ParseConstantPoolType(line.c_str() + 11);
228 } else if (line.compare(0, 9, "execute: ") == 0) { 238 } else if (line.compare(0, 9, "execute: ") == 0) {
229 execute_ = ParseBoolean(line.c_str() + 9); 239 execute_ = ParseBoolean(line.c_str() + 9);
230 } else if (line.compare(0, 6, "wrap: ") == 0) { 240 } else if (line.compare(0, 6, "wrap: ") == 0) {
231 wrap_ = ParseBoolean(line.c_str() + 6); 241 wrap_ = ParseBoolean(line.c_str() + 6);
232 } else if (line.compare(0, 20, "test function name: ") == 0) { 242 } else if (line.compare(0, 20, "test function name: ") == 0) {
233 test_function_name_ = line.c_str() + 20; 243 test_function_name_ = line.c_str() + 20;
234 } else if (line.compare(0, 11, "top level: ") == 0) { 244 } else if (line.compare(0, 11, "top level: ") == 0) {
235 top_level_ = ParseBoolean(line.c_str() + 11); 245 top_level_ = ParseBoolean(line.c_str() + 11);
246 } else if (line.compare(0, 14, "legacy const: ") == 0) {
247 legacy_const_ = ParseBoolean(line.c_str() + 14);
248 } else if (line.compare(0, 16, "do expressions: ") == 0) {
249 do_expressions_ = ParseBoolean(line.c_str() + 16);
236 } else if (line == "---") { 250 } else if (line == "---") {
237 break; 251 break;
238 } else if (line.empty()) { 252 } else if (line.empty()) {
239 continue; 253 continue;
240 } else { 254 } else {
241 UNREACHABLE(); 255 UNREACHABLE();
242 return; 256 return;
243 } 257 }
244 } 258 }
245 } 259 }
246 260
247 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT 261 void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT
248 stream << "---" 262 stream << "---"
249 "\npool type: " 263 "\npool type: "
250 << ConstantPoolTypeToString(const_pool_type_) 264 << ConstantPoolTypeToString(const_pool_type_)
251 << "\nexecute: " << BooleanToString(execute_) 265 << "\nexecute: " << BooleanToString(execute_)
252 << "\nwrap: " << BooleanToString(wrap_); 266 << "\nwrap: " << BooleanToString(wrap_);
253 267
254 if (!test_function_name_.empty()) { 268 if (!test_function_name_.empty()) {
255 stream << "\ntest function name: " << test_function_name_; 269 stream << "\ntest function name: " << test_function_name_;
256 } 270 }
257 271
258 if (top_level_) stream << "\ntop level: yes"; 272 if (top_level_) stream << "\ntop level: yes";
273 if (legacy_const_) stream << "\nlegacy const: yes";
274 if (do_expressions_) stream << "\ndo expressions: yes";
259 275
260 stream << "\n\n"; 276 stream << "\n\n";
261 } 277 }
262 278
263 V8InitializationScope::V8InitializationScope(const char* exec_path) 279 V8InitializationScope::V8InitializationScope(const char* exec_path)
264 : platform_(v8::platform::CreateDefaultPlatform()) { 280 : platform_(v8::platform::CreateDefaultPlatform()) {
265 i::FLAG_ignition = true; 281 i::FLAG_ignition = true;
266 i::FLAG_always_opt = false; 282 i::FLAG_always_opt = false;
267 i::FLAG_allow_natives_syntax = true; 283 i::FLAG_allow_natives_syntax = true;
268 284
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 371
356 BytecodeExpectationsPrinter printer(platform.isolate(), 372 BytecodeExpectationsPrinter printer(platform.isolate(),
357 options.const_pool_type()); 373 options.const_pool_type());
358 printer.set_wrap(options.wrap()); 374 printer.set_wrap(options.wrap());
359 printer.set_execute(options.execute()); 375 printer.set_execute(options.execute());
360 printer.set_top_level(options.top_level()); 376 printer.set_top_level(options.top_level());
361 if (!options.test_function_name().empty()) { 377 if (!options.test_function_name().empty()) {
362 printer.set_test_function_name(options.test_function_name()); 378 printer.set_test_function_name(options.test_function_name());
363 } 379 }
364 380
381 if (options.legacy_const()) i::FLAG_legacy_const = true;
382 if (options.do_expressions()) i::FLAG_harmony_do_expressions = true;
383
365 stream << "#\n# Autogenerated by generate-bytecode-expectations\n#\n\n"; 384 stream << "#\n# Autogenerated by generate-bytecode-expectations\n#\n\n";
366 options.PrintHeader(stream); 385 options.PrintHeader(stream);
367 for (const std::string& snippet : snippet_list) { 386 for (const std::string& snippet : snippet_list) {
368 printer.PrintExpectation(stream, snippet); 387 printer.PrintExpectation(stream, snippet);
369 } 388 }
370 } 389 }
371 } 390 }
372 391
373 void PrintUsage(const char* exec_path) { 392 void PrintUsage(const char* exec_path) {
374 std::cerr 393 std::cerr
375 << "\nUsage: " << exec_path 394 << "\nUsage: " << exec_path
376 << " [OPTIONS]... [INPUT FILE]\n\n" 395 << " [OPTIONS]... [INPUT FILE]\n\n"
377 "Options:\n" 396 "Options:\n"
378 " --help Print this help message.\n" 397 " --help Print this help message.\n"
379 " --raw-js Read raw JavaScript, instead of the output format.\n" 398 " --raw-js Read raw JavaScript, instead of the output format.\n"
380 " --stdin Read from standard input instead of file.\n" 399 " --stdin Read from standard input instead of file.\n"
381 " --rebaseline Rebaseline input snippet file.\n" 400 " --rebaseline Rebaseline input snippet file.\n"
382 " --no-wrap Do not wrap the snippet in a function.\n" 401 " --no-wrap Do not wrap the snippet in a function.\n"
383 " --no-execute Do not execute after compilation.\n" 402 " --no-execute Do not execute after compilation.\n"
384 " --test-function-name=foo " 403 " --test-function-name=foo "
385 "Specify the name of the test function.\n" 404 "Specify the name of the test function.\n"
386 " --top-level Process top level code, not the top-level function." 405 " --top-level Process top level code, not the top-level function."
406 " --legacy-const Flip legacy_const flag.\n"
rmcilroy 2016/02/19 14:22:18 /s/Flip/Enable the/
Stefano Sanfilippo 2016/02/19 14:35:01 Done.
407 " --do-expressions Flip harmony_do_expressions flag.\n"
rmcilroy 2016/02/19 14:22:18 ditto
Stefano Sanfilippo 2016/02/19 14:35:01 Done.
387 " --output=file.name\n" 408 " --output=file.name\n"
388 " Specify the output file. If not specified, output goes to " 409 " Specify the output file. If not specified, output goes to "
389 "stdout.\n" 410 "stdout.\n"
390 " --pool-type=(int|double|string|mixed)\n" 411 " --pool-type=(int|double|string|mixed)\n"
391 " Specify the type of the entries in the constant pool " 412 " Specify the type of the entries in the constant pool "
392 "(default: mixed).\n" 413 "(default: mixed).\n"
393 "\n" 414 "\n"
394 "When using --rebaseline, flags --no-wrap, --no-execute, " 415 "When using --rebaseline, flags --no-wrap, --no-execute, "
395 "--test-function-name\nand --pool-type will be overridden by the " 416 "--test-function-name\nand --pool-type will be overridden by the "
396 "options specified in the input file\nheader.\n\n" 417 "options specified in the input file\nheader.\n\n"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 std::cerr << "ERROR: Could not open '" << options.output_filename() 460 std::cerr << "ERROR: Could not open '" << options.output_filename()
440 << "' for writing.\n"; 461 << "' for writing.\n";
441 return 3; 462 return 3;
442 } 463 }
443 } 464 }
444 std::ostream& output_stream = 465 std::ostream& output_stream =
445 options.write_to_stdout() ? std::cout : output_file_handle; 466 options.write_to_stdout() ? std::cout : output_file_handle;
446 467
447 GenerateExpectationsFile(output_stream, snippet_list, options, argv[0]); 468 GenerateExpectationsFile(output_stream, snippet_list, options, argv[0]);
448 } 469 }
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