Commit c21d0148 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[testrunner] Implicitly detect trivial flag contraditions

This changes the test runner to automatically treat cases in which
both a flag and its negation are present as a flag contradiction.
Example: "--foo --no-foo".

With this change it's no longer necessary to explicitly specify these
trivial contraditions in variants.py.

Note: since negations are created through simple string operations,
bogus constructions are possible ("--nobodys-perfect" ->
"--bodys-perfect"). We accept these as unlikely-to-cause-problems.

Bug: v8:10577
Change-Id: Ic52a92ed1e884b495ee4136f6e2f3257cca243c2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2904218Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74773}
parent e39711a6
...@@ -16,7 +16,7 @@ ALL_VARIANT_FLAGS = { ...@@ -16,7 +16,7 @@ ALL_VARIANT_FLAGS = {
"concurrent_inlining": [["--concurrent-inlining"]], "concurrent_inlining": [["--concurrent-inlining"]],
"jitless": [["--jitless"]], "jitless": [["--jitless"]],
"sparkplug": [["--sparkplug"]], "sparkplug": [["--sparkplug"]],
"always_sparkplug": [[ "--always-sparkplug" ]], "always_sparkplug": [[ "--always-sparkplug", "--sparkplug"]],
"minor_mc": [["--minor-mc"]], "minor_mc": [["--minor-mc"]],
"no_lfa": [["--no-lazy-feedback-allocation"]], "no_lfa": [["--no-lazy-feedback-allocation"]],
# No optimization means disable all optimizations. OptimizeFunctionOnNextCall # No optimization means disable all optimizations. OptimizeFunctionOnNextCall
...@@ -30,7 +30,8 @@ ALL_VARIANT_FLAGS = { ...@@ -30,7 +30,8 @@ ALL_VARIANT_FLAGS = {
"stress": [["--stress-opt", "--no-liftoff", "--stress-lazy-source-positions", "stress": [["--stress-opt", "--no-liftoff", "--stress-lazy-source-positions",
"--no-wasm-generic-wrapper"]], "--no-wasm-generic-wrapper"]],
"stress_concurrent_allocation": [["--stress-concurrent-allocation"]], "stress_concurrent_allocation": [["--stress-concurrent-allocation"]],
"stress_concurrent_inlining": [["--stress-concurrent-inlining"]], "stress_concurrent_inlining": [["--stress-concurrent-inlining",
"--concurrent-inlining"]],
"stress_js_bg_compile_wasm_code_gc": [["--stress-background-compile", "stress_js_bg_compile_wasm_code_gc": [["--stress-background-compile",
"--stress-wasm-code-gc"]], "--stress-wasm-code-gc"]],
"stress_incremental_marking": [["--stress-incremental-marking"]], "stress_incremental_marking": [["--stress-incremental-marking"]],
...@@ -40,7 +41,7 @@ ALL_VARIANT_FLAGS = { ...@@ -40,7 +41,7 @@ ALL_VARIANT_FLAGS = {
"trusted": [["--no-untrusted-code-mitigations"]], "trusted": [["--no-untrusted-code-mitigations"]],
"no_wasm_traps": [["--no-wasm-trap-handler"]], "no_wasm_traps": [["--no-wasm-trap-handler"]],
"turboprop": [["--turboprop"]], "turboprop": [["--turboprop"]],
"turboprop_as_toptier": [["--turboprop-as-toptier"]], "turboprop_as_toptier": [["--turboprop-as-toptier", "--turboprop"]],
"instruction_scheduling": [["--turbo-instruction-scheduling"]], "instruction_scheduling": [["--turbo-instruction-scheduling"]],
"stress_instruction_scheduling": [["--turbo-stress-instruction-scheduling"]], "stress_instruction_scheduling": [["--turbo-stress-instruction-scheduling"]],
"top_level_await": [["--harmony-top-level-await"]], "top_level_await": [["--harmony-top-level-await"]],
...@@ -51,33 +52,22 @@ ALL_VARIANT_FLAGS = { ...@@ -51,33 +52,22 @@ ALL_VARIANT_FLAGS = {
# variant. This depends on the flags specified in ALL_VARIANT_FLAGS and on the # variant. This depends on the flags specified in ALL_VARIANT_FLAGS and on the
# implications defined in flag-definitions.h. # implications defined in flag-definitions.h.
INCOMPATIBLE_FLAGS_PER_VARIANT = { INCOMPATIBLE_FLAGS_PER_VARIANT = {
"assert_types": ["--no-assert-types"],
"jitless": ["--opt", "--always-opt", "--liftoff", "--track-field-types", "jitless": ["--opt", "--always-opt", "--liftoff", "--track-field-types",
"--validate-asm", "--sparkplug", "--always-sparkplug"], "--validate-asm", "--sparkplug", "--always-sparkplug"],
"no_wasm_traps": ["--wasm-trap-handler"], "nooptimization": ["--always-opt"],
"nooptimization": ["--opt", "--always-opt", "--no-liftoff",
"--wasm-tier-up"],
"slow_path": ["--no-force-slow-path"], "slow_path": ["--no-force-slow-path"],
"stress_concurrent_allocation": ["--single-threaded-gc", "--predictable"], "stress_concurrent_allocation": ["--single-threaded-gc", "--predictable"],
"stress_concurrent_inlining": ["--single-threaded", "--predictable", "stress_concurrent_inlining": ["--single-threaded", "--predictable"],
"--no-concurrent-inlining"], "stress": ["--always-opt", "--no-always-opt",
"concurrent_inlining": ["--no-concurrent-inlining"],
"stress_incremental_marking": ["--no-stress-incremental-marking"],
"stress_js_bg_compile_wasm_code_gc": ["--no-stress-background-compile"],
"stress": ["--no-stress-opt", "--always-opt", "--no-always-opt", "--liftoff",
"--max-inlined-bytecode-size=*", "--max-inlined-bytecode-size=*",
"--max-inlined-bytecode-size-cumulative=*", "--stress-inline", "--max-inlined-bytecode-size-cumulative=*", "--stress-inline"],
"--wasm-generic-wrapper"], "sparkplug": ["--jitless"],
"sparkplug": ["--jitless", "--no-sparkplug" ], "always_sparkplug": ["--jitless"],
"always_sparkplug": ["--jitless", "--no-sparkplug", "--no-always-sparkplug"], "turboprop": ["--interrupt-budget=*"],
"turboprop": ["--interrupt-budget=*", "--no-turboprop"], "turboprop_as_toptier": ["--interrupt-budget=*"],
"turboprop_as_toptier": ["--interrupt-budget=*", "--no-turboprop",
"--no-turboprop-as-toptier"],
"code_serializer": ["--cache=after-execute", "--cache=full-code-cache", "code_serializer": ["--cache=after-execute", "--cache=full-code-cache",
"--cache=none"], "--cache=none"],
"no_local_heaps": ["--concurrent-inlining", "--turboprop"], "experimental_regexp": ["--no-enable-experimental-regexp-engine"],
"experimental_regexp": ["--no-enable-experimental-regexp-engine",
"--no-default-to-experimental-regexp-engine"],
# There is a negative implication: --perf-prof disables # There is a negative implication: --perf-prof disables
# --wasm-write-protect-code-memory. # --wasm-write-protect-code-memory.
"wasm_write_protect_code": ["--perf-prof"], "wasm_write_protect_code": ["--perf-prof"],
...@@ -103,20 +93,13 @@ INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE = { ...@@ -103,20 +93,13 @@ INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE = {
# The conflicts might be directly contradictory flags or be caused by the # The conflicts might be directly contradictory flags or be caused by the
# implications defined in flag-definitions.h. # implications defined in flag-definitions.h.
INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG = { INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG = {
"--concurrent-inlining": "--concurrent-recompilation": ["--predictable"],
INCOMPATIBLE_FLAGS_PER_VARIANT["concurrent_inlining"],
"--concurrent-recompilation": ["--no-concurrent-recompilation", "--predictable"],
"--enable-armv8": ["--no-enable-armv8"],
"--gc-interval=*": ["--gc-interval=*"], "--gc-interval=*": ["--gc-interval=*"],
"--no-enable-sse3": ["--enable-sse3"],
"--no-enable-ssse3": ["--enable-ssse3"],
"--no-enable-sse4-1": ["--enable-sse4-1"],
"--optimize-for-size": ["--max-semi-space-size=*"], "--optimize-for-size": ["--max-semi-space-size=*"],
"--stress_concurrent_allocation": ["--single-threaded-gc", "--predictable"], "--stress_concurrent_allocation":
INCOMPATIBLE_FLAGS_PER_VARIANT["stress_concurrent_allocation"],
"--stress-concurrent-inlining": "--stress-concurrent-inlining":
INCOMPATIBLE_FLAGS_PER_VARIANT["stress_concurrent_inlining"], INCOMPATIBLE_FLAGS_PER_VARIANT["stress_concurrent_inlining"],
"--stress-flush-bytecode": ["--no-stress-flush-bytecode"],
"--stress-incremental-marking": INCOMPATIBLE_FLAGS_PER_VARIANT["stress_incremental_marking"],
} }
SLOW_VARIANTS = set([ SLOW_VARIANTS = set([
......
...@@ -34,6 +34,7 @@ from ..outproc import base as outproc ...@@ -34,6 +34,7 @@ from ..outproc import base as outproc
from ..local import command from ..local import command
from ..local import statusfile from ..local import statusfile
from ..local import utils from ..local import utils
from ..local.variants import ALL_VARIANT_FLAGS
from ..local.variants import INCOMPATIBLE_FLAGS_PER_VARIANT from ..local.variants import INCOMPATIBLE_FLAGS_PER_VARIANT
from ..local.variants import INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE from ..local.variants import INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE
from ..local.variants import INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG from ..local.variants import INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG
...@@ -166,9 +167,30 @@ class TestCase(object): ...@@ -166,9 +167,30 @@ class TestCase(object):
@property @property
def expected_outcomes(self): def expected_outcomes(self):
def is_flag(maybe_flag):
return maybe_flag.startswith("--") # Best-effort heuristic.
# Filter to flags, e.g.: ["--foo", "3", "--bar"] -> ["--foo", "--bar"].
def filter_flags(normalized_flags):
return [f for f in normalized_flags if is_flag(f)];
def normalize_flag(flag): def normalize_flag(flag):
return flag.replace("_", "-").replace("--no-", "--no") return flag.replace("_", "-").replace("--no-", "--no")
def normalize_flags(flags):
return [normalize_flag(flag) for flag in filter_flags(flags)]
# Note this can get it wrong if the flag name starts with the characters
# "--no" where "no" is part of the flag name, e.g. "--nobodys-perfect".
# In that case the negation "--bodys-perfect" would be returned. This is
# a weakness we accept and hope to never run into.
def negate_flag(normalized_flag):
return ("--" + normalized_flag[4:] if normalized_flag.startswith("--no")
else "--no" + normalized_flag[2:])
def negate_flags(normalized_flags):
return [negate_flag(flag) for flag in normalized_flags]
def has_flag(conflicting_flag, flags): def has_flag(conflicting_flag, flags):
conflicting_flag = normalize_flag(conflicting_flag) conflicting_flag = normalize_flag(conflicting_flag)
if conflicting_flag in flags: if conflicting_flag in flags:
...@@ -191,18 +213,31 @@ class TestCase(object): ...@@ -191,18 +213,31 @@ class TestCase(object):
file_specific_flags = (self._get_source_flags() + self._get_suite_flags() file_specific_flags = (self._get_source_flags() + self._get_suite_flags()
+ self._get_statusfile_flags()) + self._get_statusfile_flags())
file_specific_flags = [normalize_flag(flag) for flag in file_specific_flags] file_specific_flags = normalize_flags(file_specific_flags)
extra_flags = [normalize_flag(flag) for flag in self._get_extra_flags()] extra_flags = normalize_flags(self._get_extra_flags())
# Contradiction: flags contains both a flag --foo and its negation
# --no-foo.
if self.variant in ALL_VARIANT_FLAGS:
for flags in ALL_VARIANT_FLAGS[self.variant]:
all_flags = (file_specific_flags + extra_flags
+ normalize_flags(flags))
check_flags(negate_flags(all_flags), all_flags, "Flag negations")
# Contradiction: flags specified through the "Flags:" annotation are
# incompatible with the variant.
if self.variant in INCOMPATIBLE_FLAGS_PER_VARIANT: if self.variant in INCOMPATIBLE_FLAGS_PER_VARIANT:
check_flags(INCOMPATIBLE_FLAGS_PER_VARIANT[self.variant], file_specific_flags, check_flags(INCOMPATIBLE_FLAGS_PER_VARIANT[self.variant], file_specific_flags,
"INCOMPATIBLE_FLAGS_PER_VARIANT[\""+self.variant+"\"]") "INCOMPATIBLE_FLAGS_PER_VARIANT[\""+self.variant+"\"]")
# Contradiction: flags specified through the "Flags:" annotation are
# incompatible with the build.
for variable, incompatible_flags in INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE.items(): for variable, incompatible_flags in INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE.items():
if self.suite.statusfile.variables[variable]: if self.suite.statusfile.variables[variable]:
check_flags(incompatible_flags, file_specific_flags, check_flags(incompatible_flags, file_specific_flags,
"INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE[\""+variable+"\"]") "INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE[\""+variable+"\"]")
# Contradiction: flags passed through --extra-flags are incompatible.
for extra_flag, incompatible_flags in INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG.items(): for extra_flag, incompatible_flags in INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG.items():
if has_flag(extra_flag, extra_flags): if has_flag(extra_flag, extra_flags):
check_flags(incompatible_flags, file_specific_flags, check_flags(incompatible_flags, file_specific_flags,
......
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