[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/+/2904218
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74773}
This commit is contained in:
Jakob Gruber 2021-05-19 14:10:48 +02:00 committed by V8 LUCI CQ
parent e39711a615
commit c21d0148d6
2 changed files with 53 additions and 35 deletions

View File

@ -16,7 +16,7 @@ ALL_VARIANT_FLAGS = {
"concurrent_inlining": [["--concurrent-inlining"]],
"jitless": [["--jitless"]],
"sparkplug": [["--sparkplug"]],
"always_sparkplug": [[ "--always-sparkplug" ]],
"always_sparkplug": [[ "--always-sparkplug", "--sparkplug"]],
"minor_mc": [["--minor-mc"]],
"no_lfa": [["--no-lazy-feedback-allocation"]],
# No optimization means disable all optimizations. OptimizeFunctionOnNextCall
@ -30,7 +30,8 @@ ALL_VARIANT_FLAGS = {
"stress": [["--stress-opt", "--no-liftoff", "--stress-lazy-source-positions",
"--no-wasm-generic-wrapper"]],
"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-wasm-code-gc"]],
"stress_incremental_marking": [["--stress-incremental-marking"]],
@ -40,7 +41,7 @@ ALL_VARIANT_FLAGS = {
"trusted": [["--no-untrusted-code-mitigations"]],
"no_wasm_traps": [["--no-wasm-trap-handler"]],
"turboprop": [["--turboprop"]],
"turboprop_as_toptier": [["--turboprop-as-toptier"]],
"turboprop_as_toptier": [["--turboprop-as-toptier", "--turboprop"]],
"instruction_scheduling": [["--turbo-instruction-scheduling"]],
"stress_instruction_scheduling": [["--turbo-stress-instruction-scheduling"]],
"top_level_await": [["--harmony-top-level-await"]],
@ -51,33 +52,22 @@ ALL_VARIANT_FLAGS = {
# variant. This depends on the flags specified in ALL_VARIANT_FLAGS and on the
# implications defined in flag-definitions.h.
INCOMPATIBLE_FLAGS_PER_VARIANT = {
"assert_types": ["--no-assert-types"],
"jitless": ["--opt", "--always-opt", "--liftoff", "--track-field-types",
"--validate-asm", "--sparkplug", "--always-sparkplug"],
"no_wasm_traps": ["--wasm-trap-handler"],
"nooptimization": ["--opt", "--always-opt", "--no-liftoff",
"--wasm-tier-up"],
"nooptimization": ["--always-opt"],
"slow_path": ["--no-force-slow-path"],
"stress_concurrent_allocation": ["--single-threaded-gc", "--predictable"],
"stress_concurrent_inlining": ["--single-threaded", "--predictable",
"--no-concurrent-inlining"],
"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",
"stress_concurrent_inlining": ["--single-threaded", "--predictable"],
"stress": ["--always-opt", "--no-always-opt",
"--max-inlined-bytecode-size=*",
"--max-inlined-bytecode-size-cumulative=*", "--stress-inline",
"--wasm-generic-wrapper"],
"sparkplug": ["--jitless", "--no-sparkplug" ],
"always_sparkplug": ["--jitless", "--no-sparkplug", "--no-always-sparkplug"],
"turboprop": ["--interrupt-budget=*", "--no-turboprop"],
"turboprop_as_toptier": ["--interrupt-budget=*", "--no-turboprop",
"--no-turboprop-as-toptier"],
"--max-inlined-bytecode-size-cumulative=*", "--stress-inline"],
"sparkplug": ["--jitless"],
"always_sparkplug": ["--jitless"],
"turboprop": ["--interrupt-budget=*"],
"turboprop_as_toptier": ["--interrupt-budget=*"],
"code_serializer": ["--cache=after-execute", "--cache=full-code-cache",
"--cache=none"],
"no_local_heaps": ["--concurrent-inlining", "--turboprop"],
"experimental_regexp": ["--no-enable-experimental-regexp-engine",
"--no-default-to-experimental-regexp-engine"],
"experimental_regexp": ["--no-enable-experimental-regexp-engine"],
# There is a negative implication: --perf-prof disables
# --wasm-write-protect-code-memory.
"wasm_write_protect_code": ["--perf-prof"],
@ -103,20 +93,13 @@ INCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE = {
# The conflicts might be directly contradictory flags or be caused by the
# implications defined in flag-definitions.h.
INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG = {
"--concurrent-inlining":
INCOMPATIBLE_FLAGS_PER_VARIANT["concurrent_inlining"],
"--concurrent-recompilation": ["--no-concurrent-recompilation", "--predictable"],
"--enable-armv8": ["--no-enable-armv8"],
"--concurrent-recompilation": ["--predictable"],
"--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=*"],
"--stress_concurrent_allocation": ["--single-threaded-gc", "--predictable"],
"--stress_concurrent_allocation":
INCOMPATIBLE_FLAGS_PER_VARIANT["stress_concurrent_allocation"],
"--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([

View File

@ -34,6 +34,7 @@ from ..outproc import base as outproc
from ..local import command
from ..local import statusfile
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_BUILD_VARIABLE
from ..local.variants import INCOMPATIBLE_FLAGS_PER_EXTRA_FLAG
@ -166,9 +167,30 @@ class TestCase(object):
@property
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):
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):
conflicting_flag = normalize_flag(conflicting_flag)
if conflicting_flag in flags:
@ -191,18 +213,31 @@ class TestCase(object):
file_specific_flags = (self._get_source_flags() + self._get_suite_flags()
+ self._get_statusfile_flags())
file_specific_flags = [normalize_flag(flag) for flag in file_specific_flags]
extra_flags = [normalize_flag(flag) for flag in self._get_extra_flags()]
file_specific_flags = normalize_flags(file_specific_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:
check_flags(INCOMPATIBLE_FLAGS_PER_VARIANT[self.variant], file_specific_flags,
"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():
if self.suite.statusfile.variables[variable]:
check_flags(incompatible_flags, file_specific_flags,
"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():
if has_flag(extra_flag, extra_flags):
check_flags(incompatible_flags, file_specific_flags,