Commit 4f0be519 authored by ssanfilippo's avatar ssanfilippo Committed by Commit bot

[Interpreter] Support relevant FLAG_s in generate-bytecode-expectations.

FLAG_legacy_const and FLAG_harmony_do_expressions can now be toggled
both through the command line and through the option header.

BUG=v8:4280
LOG=N

Review URL: https://codereview.chromium.org/1716793002

Cr-Commit-Position: refs/heads/master@{#34160}
parent bd6ddb83
......@@ -32,6 +32,8 @@ class ProgramOptions final {
wrap_(true),
execute_(true),
top_level_(false),
legacy_const_(false),
do_expressions_(false),
const_pool_type_(
BytecodeExpectationsPrinter::ConstantPoolType::kMixed) {}
......@@ -50,6 +52,8 @@ class ProgramOptions final {
bool wrap() const { return wrap_; }
bool execute() const { return execute_; }
bool top_level() const { return top_level_; }
bool legacy_const() const { return legacy_const_; }
bool do_expressions() const { return do_expressions_; }
BytecodeExpectationsPrinter::ConstantPoolType const_pool_type() const {
return const_pool_type_;
}
......@@ -66,6 +70,8 @@ class ProgramOptions final {
bool wrap_;
bool execute_;
bool top_level_;
bool legacy_const_;
bool do_expressions_;
BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_;
std::string input_filename_;
std::string output_filename_;
......@@ -159,6 +165,10 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) {
options.execute_ = false;
} else if (strcmp(argv[i], "--top-level") == 0) {
options.top_level_ = true;
} else if (strcmp(argv[i], "--legacy-const") == 0) {
options.legacy_const_ = true;
} else if (strcmp(argv[i], "--do-expressions") == 0) {
options.do_expressions_ = true;
} else if (strncmp(argv[i], "--output=", 9) == 0) {
options.output_filename_ = argv[i] + 9;
} else if (strncmp(argv[i], "--test-function-name=", 21) == 0) {
......@@ -233,6 +243,10 @@ void ProgramOptions::UpdateFromHeader(std::istream& stream) {
test_function_name_ = line.c_str() + 20;
} else if (line.compare(0, 11, "top level: ") == 0) {
top_level_ = ParseBoolean(line.c_str() + 11);
} else if (line.compare(0, 14, "legacy const: ") == 0) {
legacy_const_ = ParseBoolean(line.c_str() + 14);
} else if (line.compare(0, 16, "do expressions: ") == 0) {
do_expressions_ = ParseBoolean(line.c_str() + 16);
} else if (line == "---") {
break;
} else if (line.empty()) {
......@@ -256,6 +270,8 @@ void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT
}
if (top_level_) stream << "\ntop level: yes";
if (legacy_const_) stream << "\nlegacy const: yes";
if (do_expressions_) stream << "\ndo expressions: yes";
stream << "\n\n";
}
......@@ -362,6 +378,9 @@ void GenerateExpectationsFile(std::ostream& stream, // NOLINT
printer.set_test_function_name(options.test_function_name());
}
if (options.legacy_const()) i::FLAG_legacy_const = true;
if (options.do_expressions()) i::FLAG_harmony_do_expressions = true;
stream << "#\n# Autogenerated by generate-bytecode-expectations\n#\n\n";
options.PrintHeader(stream);
for (const std::string& snippet : snippet_list) {
......@@ -384,6 +403,8 @@ void PrintUsage(const char* exec_path) {
" --test-function-name=foo "
"Specify the name of the test function.\n"
" --top-level Process top level code, not the top-level function."
" --legacy-const Enable legacy_const flag.\n"
" --do-expressions Enable harmony_do_expressions flag.\n"
" --output=file.name\n"
" Specify the output file. If not specified, output goes to "
"stdout.\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment