11cb0ef41Sopenharmony_ci# Copyright 2016 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci# found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci# Use this to run several variants of the tests.
61cb0ef41Sopenharmony_ciALL_VARIANT_FLAGS = {
71cb0ef41Sopenharmony_ci  "assert_types": [["--assert-types"]],
81cb0ef41Sopenharmony_ci  "code_serializer": [["--cache=code"]],
91cb0ef41Sopenharmony_ci  "default": [[]],
101cb0ef41Sopenharmony_ci  "future": [["--future"]],
111cb0ef41Sopenharmony_ci  "gc_stats": [["--gc-stats=1"]],
121cb0ef41Sopenharmony_ci  # Alias of exhaustive variants, but triggering new test framework features.
131cb0ef41Sopenharmony_ci  "infra_staging": [[]],
141cb0ef41Sopenharmony_ci  "interpreted_regexp": [["--regexp-interpret-all"]],
151cb0ef41Sopenharmony_ci  "experimental_regexp":  [["--default-to-experimental-regexp-engine"]],
161cb0ef41Sopenharmony_ci  "jitless": [["--jitless"]],
171cb0ef41Sopenharmony_ci  "sparkplug": [["--sparkplug"]],
181cb0ef41Sopenharmony_ci  # TODO(v8:v8:7700): Support concurrent compilation and remove flag.
191cb0ef41Sopenharmony_ci  "maglev": [["--maglev", "--no-concurrent-recompilation"]],
201cb0ef41Sopenharmony_ci  "concurrent_sparkplug": [["--concurrent-sparkplug", "--sparkplug"]],
211cb0ef41Sopenharmony_ci  "always_sparkplug": [["--always-sparkplug", "--sparkplug"]],
221cb0ef41Sopenharmony_ci  "minor_mc": [["--minor-mc"]],
231cb0ef41Sopenharmony_ci  "no_lfa": [["--no-lazy-feedback-allocation"]],
241cb0ef41Sopenharmony_ci  # No optimization means disable all optimizations. OptimizeFunctionOnNextCall
251cb0ef41Sopenharmony_ci  # would not force optimization too. It turns into a Nop. Please see
261cb0ef41Sopenharmony_ci  # https://chromium-review.googlesource.com/c/452620/ for more discussion.
271cb0ef41Sopenharmony_ci  # For WebAssembly, we test "Liftoff-only" in the nooptimization variant and
281cb0ef41Sopenharmony_ci  # "TurboFan-only" in the stress variant. The WebAssembly configuration is
291cb0ef41Sopenharmony_ci  # independent of JS optimizations, so we can combine those configs.
301cb0ef41Sopenharmony_ci  "nooptimization": [["--no-opt", "--liftoff", "--no-wasm-tier-up"]],
311cb0ef41Sopenharmony_ci  "slow_path": [["--force-slow-path"]],
321cb0ef41Sopenharmony_ci  "stress": [["--stress-opt", "--no-liftoff", "--stress-lazy-source-positions",
331cb0ef41Sopenharmony_ci              "--no-wasm-generic-wrapper"]],
341cb0ef41Sopenharmony_ci  "stress_concurrent_allocation": [["--stress-concurrent-allocation"]],
351cb0ef41Sopenharmony_ci  "stress_concurrent_inlining": [["--stress-concurrent-inlining"]],
361cb0ef41Sopenharmony_ci  "stress_js_bg_compile_wasm_code_gc": [["--stress-background-compile",
371cb0ef41Sopenharmony_ci                                         "--stress-wasm-code-gc"]],
381cb0ef41Sopenharmony_ci  "stress_incremental_marking": [["--stress-incremental-marking"]],
391cb0ef41Sopenharmony_ci  "stress_snapshot": [["--stress-snapshot"]],
401cb0ef41Sopenharmony_ci  # Trigger stress sampling allocation profiler with sample interval = 2^14
411cb0ef41Sopenharmony_ci  "stress_sampling": [["--stress-sampling-allocation-profiler=16384"]],
421cb0ef41Sopenharmony_ci  "no_wasm_traps": [["--no-wasm-trap-handler"]],
431cb0ef41Sopenharmony_ci  "instruction_scheduling": [["--turbo-instruction-scheduling"]],
441cb0ef41Sopenharmony_ci  "stress_instruction_scheduling": [["--turbo-stress-instruction-scheduling"]],
451cb0ef41Sopenharmony_ci  "wasm_write_protect_code": [["--wasm-write-protect-code-memory"]],
461cb0ef41Sopenharmony_ci  # Google3 variants.
471cb0ef41Sopenharmony_ci  "google3_icu": [[]],
481cb0ef41Sopenharmony_ci  "google3_noicu": [[]],
491cb0ef41Sopenharmony_ci}
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci# Flags that lead to a contradiction with the flags provided by the respective
521cb0ef41Sopenharmony_ci# variant. This depends on the flags specified in ALL_VARIANT_FLAGS and on the
531cb0ef41Sopenharmony_ci# implications defined in flag-definitions.h.
541cb0ef41Sopenharmony_ciINCOMPATIBLE_FLAGS_PER_VARIANT = {
551cb0ef41Sopenharmony_ci    "jitless": [
561cb0ef41Sopenharmony_ci        "--opt", "--always-opt", "--liftoff", "--track-field-types",
571cb0ef41Sopenharmony_ci        "--validate-asm", "--sparkplug", "--concurrent-sparkplug", "--maglev",
581cb0ef41Sopenharmony_ci        "--always-sparkplug", "--regexp-tier-up", "--no-regexp-interpret-all",
591cb0ef41Sopenharmony_ci        "--maglev"
601cb0ef41Sopenharmony_ci    ],
611cb0ef41Sopenharmony_ci    "nooptimization": ["--always-opt"],
621cb0ef41Sopenharmony_ci    "slow_path": ["--no-force-slow-path"],
631cb0ef41Sopenharmony_ci    "stress_concurrent_allocation": ["--single-threaded-gc", "--predictable"],
641cb0ef41Sopenharmony_ci    "stress_concurrent_inlining": [
651cb0ef41Sopenharmony_ci        "--single-threaded", "--predictable", "--lazy-feedback-allocation",
661cb0ef41Sopenharmony_ci        "--assert-types", "--no-concurrent-recompilation"
671cb0ef41Sopenharmony_ci    ],
681cb0ef41Sopenharmony_ci    # The fast API tests initialize an embedder object that never needs to be
691cb0ef41Sopenharmony_ci    # serialized to the snapshot, so we don't have a
701cb0ef41Sopenharmony_ci    # SerializeInternalFieldsCallback for it, so they are incompatible with
711cb0ef41Sopenharmony_ci    # stress_snapshot.
721cb0ef41Sopenharmony_ci    "stress_snapshot": ["--expose-fast-api"],
731cb0ef41Sopenharmony_ci    "stress": [
741cb0ef41Sopenharmony_ci        "--always-opt", "--no-always-opt", "--max-inlined-bytecode-size=*",
751cb0ef41Sopenharmony_ci        "--max-inlined-bytecode-size-cumulative=*", "--stress-inline",
761cb0ef41Sopenharmony_ci        "--liftoff-only", "--wasm-speculative-inlining",
771cb0ef41Sopenharmony_ci        "--wasm-dynamic-tiering"
781cb0ef41Sopenharmony_ci    ],
791cb0ef41Sopenharmony_ci    "sparkplug": ["--jitless"],
801cb0ef41Sopenharmony_ci    "concurrent_sparkplug": ["--jitless"],
811cb0ef41Sopenharmony_ci    # TODO(v8:v8:7700): Support concurrent compilation and remove incompatible flags.
821cb0ef41Sopenharmony_ci    "maglev": [
831cb0ef41Sopenharmony_ci        "--jitless", "--concurrent-recompilation",
841cb0ef41Sopenharmony_ci        "--stress-concurrent-inlining"
851cb0ef41Sopenharmony_ci    ],
861cb0ef41Sopenharmony_ci    "always_sparkplug": ["--jitless"],
871cb0ef41Sopenharmony_ci    "code_serializer": [
881cb0ef41Sopenharmony_ci        "--cache=after-execute", "--cache=full-code-cache", "--cache=none"
891cb0ef41Sopenharmony_ci    ],
901cb0ef41Sopenharmony_ci    "experimental_regexp": ["--no-enable-experimental-regexp-engine"],
911cb0ef41Sopenharmony_ci    # There is a negative implication: --perf-prof disables
921cb0ef41Sopenharmony_ci    # --wasm-write-protect-code-memory.
931cb0ef41Sopenharmony_ci    "wasm_write_protect_code": ["--perf-prof"],
941cb0ef41Sopenharmony_ci    "assert_types": [
951cb0ef41Sopenharmony_ci        "--concurrent-recompilation", "--stress_concurrent_inlining",
961cb0ef41Sopenharmony_ci        "--no-assert-types"
971cb0ef41Sopenharmony_ci    ],
981cb0ef41Sopenharmony_ci}
991cb0ef41Sopenharmony_ci
1001cb0ef41Sopenharmony_ci# Flags that lead to a contradiction under certain build variables.
1011cb0ef41Sopenharmony_ci# This corresponds to the build variables usable in status files as generated
1021cb0ef41Sopenharmony_ci# in _get_statusfile_variables in base_runner.py.
1031cb0ef41Sopenharmony_ci# The conflicts might be directly contradictory flags or be caused by the
1041cb0ef41Sopenharmony_ci# implications defined in flag-definitions.h.
1051cb0ef41Sopenharmony_ciINCOMPATIBLE_FLAGS_PER_BUILD_VARIABLE = {
1061cb0ef41Sopenharmony_ci  "lite_mode": ["--no-lazy-feedback-allocation", "--max-semi-space-size=*",
1071cb0ef41Sopenharmony_ci                "--stress-concurrent-inlining"]
1081cb0ef41Sopenharmony_ci               + INCOMPATIBLE_FLAGS_PER_VARIANT["jitless"],
1091cb0ef41Sopenharmony_ci  "predictable": ["--parallel-compile-tasks-for-eager-toplevel",
1101cb0ef41Sopenharmony_ci                  "--parallel-compile-tasks-for-lazy",
1111cb0ef41Sopenharmony_ci                  "--concurrent-recompilation",
1121cb0ef41Sopenharmony_ci                  "--stress-concurrent-allocation",
1131cb0ef41Sopenharmony_ci                  "--stress-concurrent-inlining"],
1141cb0ef41Sopenharmony_ci  "dict_property_const_tracking": [
1151cb0ef41Sopenharmony_ci                  "--stress-concurrent-inlining"],
1161cb0ef41Sopenharmony_ci}
1171cb0ef41Sopenharmony_ci
1181cb0ef41Sopenharmony_ci# Flags that lead to a contradiction when a certain extra-flag is present.
1191cb0ef41Sopenharmony_ci# Such extra-flags are defined for example in infra/testing/builders.pyl or in
1201cb0ef41Sopenharmony_ci# standard_runner.py.
1211cb0ef41Sopenharmony_ci# The conflicts might be directly contradictory flags or be caused by the
1221cb0ef41Sopenharmony_ci# implications defined in flag-definitions.h.
1231cb0ef41Sopenharmony_ciINCOMPATIBLE_FLAGS_PER_EXTRA_FLAG = {
1241cb0ef41Sopenharmony_ci  "--concurrent-recompilation": ["--predictable", "--assert-types"],
1251cb0ef41Sopenharmony_ci  "--parallel-compile-tasks-for-eager-toplevel": ["--predictable"],
1261cb0ef41Sopenharmony_ci  "--parallel-compile-tasks-for-lazy": ["--predictable"],
1271cb0ef41Sopenharmony_ci  "--gc-interval=*": ["--gc-interval=*"],
1281cb0ef41Sopenharmony_ci  "--optimize-for-size": ["--max-semi-space-size=*"],
1291cb0ef41Sopenharmony_ci  "--stress_concurrent_allocation":
1301cb0ef41Sopenharmony_ci        INCOMPATIBLE_FLAGS_PER_VARIANT["stress_concurrent_allocation"],
1311cb0ef41Sopenharmony_ci  "--stress-concurrent-inlining":
1321cb0ef41Sopenharmony_ci        INCOMPATIBLE_FLAGS_PER_VARIANT["stress_concurrent_inlining"],
1331cb0ef41Sopenharmony_ci}
1341cb0ef41Sopenharmony_ci
1351cb0ef41Sopenharmony_ciSLOW_VARIANTS = set([
1361cb0ef41Sopenharmony_ci  'stress',
1371cb0ef41Sopenharmony_ci  'stress_snapshot',
1381cb0ef41Sopenharmony_ci  'nooptimization',
1391cb0ef41Sopenharmony_ci])
1401cb0ef41Sopenharmony_ci
1411cb0ef41Sopenharmony_ciFAST_VARIANTS = set([
1421cb0ef41Sopenharmony_ci  'default'
1431cb0ef41Sopenharmony_ci])
1441cb0ef41Sopenharmony_ci
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_cidef _variant_order_key(v):
1471cb0ef41Sopenharmony_ci  if v in SLOW_VARIANTS:
1481cb0ef41Sopenharmony_ci    return 0
1491cb0ef41Sopenharmony_ci  if v in FAST_VARIANTS:
1501cb0ef41Sopenharmony_ci    return 100
1511cb0ef41Sopenharmony_ci  return 50
1521cb0ef41Sopenharmony_ci
1531cb0ef41Sopenharmony_ciALL_VARIANTS = sorted(ALL_VARIANT_FLAGS.keys(),
1541cb0ef41Sopenharmony_ci                      key=_variant_order_key)
1551cb0ef41Sopenharmony_ci
1561cb0ef41Sopenharmony_ci# Check {SLOW,FAST}_VARIANTS entries
1571cb0ef41Sopenharmony_cifor variants in [SLOW_VARIANTS, FAST_VARIANTS]:
1581cb0ef41Sopenharmony_ci  for v in variants:
1591cb0ef41Sopenharmony_ci    assert v in ALL_VARIANT_FLAGS
160