diff options
Diffstat (limited to 'deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc')
-rw-r--r-- | deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc | 90 |
1 files changed, 24 insertions, 66 deletions
diff --git a/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc b/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc index dd03c24b3c..e5dca853a5 100644 --- a/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc +++ b/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc @@ -13,7 +13,6 @@ #include "include/v8.h" #include "src/base/logging.h" -#include "src/compiler.h" #include "src/interpreter/interpreter.h" #ifdef V8_OS_POSIX @@ -41,12 +40,10 @@ class ProgramOptions final { read_from_stdin_(false), rebaseline_(false), wrap_(true), - execute_(true), + module_(false), top_level_(false), do_expressions_(false), - verbose_(false), - const_pool_type_( - BytecodeExpectationsPrinter::ConstantPoolType::kMixed) {} + verbose_(false) {} bool Validate() const; void UpdateFromHeader(std::istream& stream); // NOLINT @@ -61,14 +58,11 @@ class ProgramOptions final { } bool rebaseline() const { return rebaseline_; } bool wrap() const { return wrap_; } - bool execute() const { return execute_; } + bool module() const { return module_; } bool top_level() const { return top_level_; } bool do_expressions() const { return do_expressions_; } bool verbose() const { return verbose_; } bool suppress_runtime_errors() const { return rebaseline_ && !verbose_; } - BytecodeExpectationsPrinter::ConstantPoolType const_pool_type() const { - return const_pool_type_; - } std::vector<std::string> input_filenames() const { return input_filenames_; } std::string output_filename() const { return output_filename_; } std::string test_function_name() const { return test_function_name_; } @@ -80,11 +74,10 @@ class ProgramOptions final { bool read_from_stdin_; bool rebaseline_; bool wrap_; - bool execute_; + bool module_; bool top_level_; bool do_expressions_; bool verbose_; - BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_; std::vector<std::string> input_filenames_; std::string output_filename_; std::string test_function_name_; @@ -106,33 +99,6 @@ class V8InitializationScope final { DISALLOW_COPY_AND_ASSIGN(V8InitializationScope); }; -BytecodeExpectationsPrinter::ConstantPoolType ParseConstantPoolType( - const char* type_string) { - if (strcmp(type_string, "number") == 0) { - return BytecodeExpectationsPrinter::ConstantPoolType::kNumber; - } else if (strcmp(type_string, "string") == 0) { - return BytecodeExpectationsPrinter::ConstantPoolType::kString; - } else if (strcmp(type_string, "mixed") == 0) { - return BytecodeExpectationsPrinter::ConstantPoolType::kMixed; - } - return BytecodeExpectationsPrinter::ConstantPoolType::kUnknown; -} - -const char* ConstantPoolTypeToString( - BytecodeExpectationsPrinter::ConstantPoolType type) { - switch (type) { - case BytecodeExpectationsPrinter::ConstantPoolType::kNumber: - return "number"; - case BytecodeExpectationsPrinter::ConstantPoolType::kMixed: - return "mixed"; - case BytecodeExpectationsPrinter::ConstantPoolType::kString: - return "string"; - default: - UNREACHABLE(); - return nullptr; - } -} - bool ParseBoolean(const char* string) { if (strcmp(string, "yes") == 0) { return true; @@ -161,15 +127,14 @@ bool CollectGoldenFiles(std::vector<std::string>* golden_file_list, DIR* directory = opendir(directory_path); if (!directory) return false; - dirent entry_buffer; - dirent* entry; - - while (readdir_r(directory, &entry_buffer, &entry) == 0 && entry) { + dirent* entry = readdir(directory); + while (entry) { if (StrEndsWith(entry->d_name, ".golden")) { std::string golden_filename(kGoldenFilesPath); golden_filename += entry->d_name; golden_file_list->push_back(golden_filename); } + entry = readdir(directory); } closedir(directory); @@ -188,16 +153,14 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) { options.print_help_ = true; } else if (strcmp(argv[i], "--raw-js") == 0) { options.read_raw_js_snippet_ = true; - } else if (strncmp(argv[i], "--pool-type=", 12) == 0) { - options.const_pool_type_ = ParseConstantPoolType(argv[i] + 12); } else if (strcmp(argv[i], "--stdin") == 0) { options.read_from_stdin_ = true; } else if (strcmp(argv[i], "--rebaseline") == 0) { options.rebaseline_ = true; } else if (strcmp(argv[i], "--no-wrap") == 0) { options.wrap_ = false; - } else if (strcmp(argv[i], "--no-execute") == 0) { - options.execute_ = false; + } else if (strcmp(argv[i], "--module") == 0) { + options.module_ = true; } else if (strcmp(argv[i], "--top-level") == 0) { options.top_level_ = true; } else if (strcmp(argv[i], "--do-expressions") == 0) { @@ -239,12 +202,6 @@ bool ProgramOptions::Validate() const { if (parsing_failed_) return false; if (print_help_) return true; - if (const_pool_type_ == - BytecodeExpectationsPrinter::ConstantPoolType::kUnknown) { - REPORT_ERROR("Unknown constant pool type."); - return false; - } - if (!read_from_stdin_ && input_filenames_.empty()) { REPORT_ERROR("No input file specified."); return false; @@ -282,6 +239,12 @@ bool ProgramOptions::Validate() const { return false; } + if (module_ && (!top_level_ || wrap_)) { + REPORT_ERROR( + "The flag --module currently requires --top-level and --no-wrap."); + return false; + } + return true; } @@ -294,10 +257,8 @@ void ProgramOptions::UpdateFromHeader(std::istream& stream) { } while (std::getline(stream, line)) { - if (line.compare(0, 11, "pool type: ") == 0) { - const_pool_type_ = ParseConstantPoolType(line.c_str() + 11); - } else if (line.compare(0, 9, "execute: ") == 0) { - execute_ = ParseBoolean(line.c_str() + 9); + if (line.compare(0, 8, "module: ") == 0) { + module_ = ParseBoolean(line.c_str() + 8); } else if (line.compare(0, 6, "wrap: ") == 0) { wrap_ = ParseBoolean(line.c_str() + 6); } else if (line.compare(0, 20, "test function name: ") == 0) { @@ -319,15 +280,13 @@ void ProgramOptions::UpdateFromHeader(std::istream& stream) { void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT stream << "---" - "\npool type: " - << ConstantPoolTypeToString(const_pool_type_) - << "\nexecute: " << BooleanToString(execute_) << "\nwrap: " << BooleanToString(wrap_); if (!test_function_name_.empty()) { stream << "\ntest function name: " << test_function_name_; } + if (module_) stream << "\nmodule: yes"; if (top_level_) stream << "\ntop level: yes"; if (do_expressions_) stream << "\ndo expressions: yes"; @@ -425,10 +384,9 @@ void GenerateExpectationsFile(std::ostream& stream, // NOLINT v8::Local<v8::Context> context = v8::Context::New(platform.isolate()); v8::Context::Scope context_scope(context); - BytecodeExpectationsPrinter printer(platform.isolate(), - options.const_pool_type()); + BytecodeExpectationsPrinter printer(platform.isolate()); printer.set_wrap(options.wrap()); - printer.set_execute(options.execute()); + printer.set_module(options.module()); printer.set_top_level(options.top_level()); if (!options.test_function_name().empty()) { printer.set_test_function_name(options.test_function_name()); @@ -482,7 +440,7 @@ void PrintUsage(const char* exec_path) { " --stdin Read from standard input instead of file.\n" " --rebaseline Rebaseline input snippet file.\n" " --no-wrap Do not wrap the snippet in a function.\n" - " --no-execute Do not execute after compilation.\n" + " --module Compile as JavaScript module.\n" " --test-function-name=foo " "Specify the name of the test function.\n" " --top-level Process top level code, not the top-level function.\n" @@ -494,9 +452,9 @@ void PrintUsage(const char* exec_path) { " Specify the type of the entries in the constant pool " "(default: mixed).\n" "\n" - "When using --rebaseline, flags --no-wrap, --no-execute, " - "--test-function-name\nand --pool-type will be overridden by the " - "options specified in the input file\nheader.\n\n" + "When using --rebaseline, flags --no-wrap, --test-function-name \n" + "and --pool-type will be overridden by the options specified in \n" + "the input file header.\n\n" "Each raw JavaScript file is interpreted as a single snippet.\n\n" "This tool is intended as a help in writing tests.\n" "Please, DO NOT blindly copy and paste the output " |