[gcmole] Simplify gcmole directives and add tests

This prepares work for speeding up gcmole infrastructure by adding
more checks and testing.

- Add a presubmit check that verifies gcmole directives in gn files.
- Simplify gcmole directives in gn files. Drop all but the
  architecture property as the others were unused. Simplify regular
  expressions.
- Fix some gcmole directives (fly by - only on untested
  architectures).
- Add a python test for the changed function in gcmole.py. There's
  no other testing yet and this starts somewhere. The test simulates
  real BUILD.gn files via checked-in test data.

Bug: v8:12660
Change-Id: I9ca3152b2c3b806de5d4509c152283b36294950d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4020268
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Alexander Schulze <alexschulze@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84239}
This commit is contained in:
Michael Achenbach 2022-11-14 13:16:56 +01:00 committed by V8 LUCI CQ
parent 6ae0cd3717
commit 2b133ebc9e
9 changed files with 293 additions and 84 deletions

View File

@ -2454,57 +2454,57 @@ v8_source_set("v8_initializers") {
if (v8_current_cpu == "x86") { if (v8_current_cpu == "x86") {
sources += [ sources += [
### gcmole(arch:ia32) ### ### gcmole(ia32) ###
"src/builtins/ia32/builtins-ia32.cc", "src/builtins/ia32/builtins-ia32.cc",
] ]
} else if (v8_current_cpu == "x64") { } else if (v8_current_cpu == "x64") {
sources += [ sources += [
### gcmole(arch:x64) ### ### gcmole(x64) ###
"src/builtins/x64/builtins-x64.cc", "src/builtins/x64/builtins-x64.cc",
] ]
} else if (v8_current_cpu == "arm") { } else if (v8_current_cpu == "arm") {
sources += [ sources += [
### gcmole(arch:arm) ### ### gcmole(arm) ###
"src/builtins/arm/builtins-arm.cc", "src/builtins/arm/builtins-arm.cc",
] ]
} else if (v8_current_cpu == "arm64") { } else if (v8_current_cpu == "arm64") {
sources += [ sources += [
### gcmole(arch:arm64) ### ### gcmole(arm64) ###
"src/builtins/arm64/builtins-arm64.cc", "src/builtins/arm64/builtins-arm64.cc",
] ]
} else if (v8_current_cpu == "mips64" || v8_current_cpu == "mips64el") { } else if (v8_current_cpu == "mips64" || v8_current_cpu == "mips64el") {
sources += [ sources += [
### gcmole(arch:mips64el) ### ### gcmole(mips64el) ###
"src/builtins/mips64/builtins-mips64.cc", "src/builtins/mips64/builtins-mips64.cc",
] ]
} else if (v8_current_cpu == "loong64") { } else if (v8_current_cpu == "loong64") {
sources += [ sources += [
### gcmole(arch:loong64) ### ### gcmole(loong64) ###
"src/builtins/loong64/builtins-loong64.cc", "src/builtins/loong64/builtins-loong64.cc",
] ]
} else if (v8_current_cpu == "ppc") { } else if (v8_current_cpu == "ppc") {
sources += [ sources += [
### gcmole(arch:ppc) ### ### gcmole(ppc) ###
"src/builtins/ppc/builtins-ppc.cc", "src/builtins/ppc/builtins-ppc.cc",
] ]
} else if (v8_current_cpu == "ppc64") { } else if (v8_current_cpu == "ppc64") {
sources += [ sources += [
### gcmole(arch:ppc64) ### ### gcmole(ppc64) ###
"src/builtins/ppc/builtins-ppc.cc", "src/builtins/ppc/builtins-ppc.cc",
] ]
} else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") { } else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") {
sources += [ sources += [
### gcmole(arch:s390) ### ### gcmole(s390) ###
"src/builtins/s390/builtins-s390.cc", "src/builtins/s390/builtins-s390.cc",
] ]
} else if (v8_current_cpu == "riscv64") { } else if (v8_current_cpu == "riscv64") {
sources += [ sources += [
### gcmole(arch:riscv64) ### ### gcmole(riscv64) ###
"src/builtins/riscv/builtins-riscv.cc", "src/builtins/riscv/builtins-riscv.cc",
] ]
} else if (v8_current_cpu == "riscv32") { } else if (v8_current_cpu == "riscv32") {
sources += [ sources += [
### gcmole(arch:riscv32) ### ### gcmole(riscv32) ###
"src/builtins/riscv/builtins-riscv.cc", "src/builtins/riscv/builtins-riscv.cc",
] ]
} }
@ -3758,7 +3758,8 @@ v8_header_set("v8_internal_headers") {
} }
if (v8_current_cpu == "x86") { if (v8_current_cpu == "x86") {
sources += [ ### gcmole(arch:ia32) ### sources += [
### gcmole(ia32) ###
"src/baseline/ia32/baseline-assembler-ia32-inl.h", "src/baseline/ia32/baseline-assembler-ia32-inl.h",
"src/baseline/ia32/baseline-compiler-ia32-inl.h", "src/baseline/ia32/baseline-compiler-ia32-inl.h",
"src/codegen/ia32/assembler-ia32-inl.h", "src/codegen/ia32/assembler-ia32-inl.h",
@ -3776,7 +3777,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/ia32/liftoff-assembler-ia32.h", "src/wasm/baseline/ia32/liftoff-assembler-ia32.h",
] ]
} else if (v8_current_cpu == "x64") { } else if (v8_current_cpu == "x64") {
sources += [ ### gcmole(arch:x64) ### sources += [
### gcmole(x64) ###
"src/baseline/x64/baseline-assembler-x64-inl.h", "src/baseline/x64/baseline-assembler-x64-inl.h",
"src/baseline/x64/baseline-compiler-x64-inl.h", "src/baseline/x64/baseline-compiler-x64-inl.h",
"src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.h",
@ -3812,7 +3814,8 @@ v8_header_set("v8_internal_headers") {
} }
} }
} else if (v8_current_cpu == "arm") { } else if (v8_current_cpu == "arm") {
sources += [ ### gcmole(arch:arm) ### sources += [
### gcmole(arm) ###
"src/baseline/arm/baseline-assembler-arm-inl.h", "src/baseline/arm/baseline-assembler-arm-inl.h",
"src/baseline/arm/baseline-compiler-arm-inl.h", "src/baseline/arm/baseline-compiler-arm-inl.h",
"src/codegen/arm/assembler-arm-inl.h", "src/codegen/arm/assembler-arm-inl.h",
@ -3830,7 +3833,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/arm/liftoff-assembler-arm.h", "src/wasm/baseline/arm/liftoff-assembler-arm.h",
] ]
} else if (v8_current_cpu == "arm64") { } else if (v8_current_cpu == "arm64") {
sources += [ ### gcmole(arch:arm64) ### sources += [
### gcmole(arm64) ###
"src/baseline/arm64/baseline-assembler-arm64-inl.h", "src/baseline/arm64/baseline-assembler-arm64-inl.h",
"src/baseline/arm64/baseline-compiler-arm64-inl.h", "src/baseline/arm64/baseline-compiler-arm64-inl.h",
"src/codegen/arm64/assembler-arm64-inl.h", "src/codegen/arm64/assembler-arm64-inl.h",
@ -3872,7 +3876,8 @@ v8_header_set("v8_internal_headers") {
sources += [ "src/diagnostics/unwinding-info-win64.h" ] sources += [ "src/diagnostics/unwinding-info-win64.h" ]
} }
} else if (v8_current_cpu == "mips64" || v8_current_cpu == "mips64el") { } else if (v8_current_cpu == "mips64" || v8_current_cpu == "mips64el") {
sources += [ ### gcmole(arch:mips64el) ### sources += [
### gcmole(mips64el) ###
"src/baseline/mips64/baseline-assembler-mips64-inl.h", "src/baseline/mips64/baseline-assembler-mips64-inl.h",
"src/baseline/mips64/baseline-compiler-mips64-inl.h", "src/baseline/mips64/baseline-compiler-mips64-inl.h",
"src/codegen/mips64/assembler-mips64-inl.h", "src/codegen/mips64/assembler-mips64-inl.h",
@ -3888,7 +3893,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/mips64/liftoff-assembler-mips64.h", "src/wasm/baseline/mips64/liftoff-assembler-mips64.h",
] ]
} else if (v8_current_cpu == "loong64") { } else if (v8_current_cpu == "loong64") {
sources += [ ### gcmole(arch:loong64) ### sources += [
### gcmole(loong64) ###
"src/baseline/loong64/baseline-assembler-loong64-inl.h", "src/baseline/loong64/baseline-assembler-loong64-inl.h",
"src/baseline/loong64/baseline-compiler-loong64-inl.h", "src/baseline/loong64/baseline-compiler-loong64-inl.h",
"src/codegen/loong64/assembler-loong64-inl.h", "src/codegen/loong64/assembler-loong64-inl.h",
@ -3904,7 +3910,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/loong64/liftoff-assembler-loong64.h", "src/wasm/baseline/loong64/liftoff-assembler-loong64.h",
] ]
} else if (v8_current_cpu == "ppc") { } else if (v8_current_cpu == "ppc") {
sources += [ ### gcmole(arch:ppc) ### sources += [
### gcmole(ppc) ###
"src/codegen/ppc/assembler-ppc-inl.h", "src/codegen/ppc/assembler-ppc-inl.h",
"src/codegen/ppc/assembler-ppc.h", "src/codegen/ppc/assembler-ppc.h",
"src/codegen/ppc/constants-ppc.h", "src/codegen/ppc/constants-ppc.h",
@ -3920,7 +3927,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/ppc/liftoff-assembler-ppc.h", "src/wasm/baseline/ppc/liftoff-assembler-ppc.h",
] ]
} else if (v8_current_cpu == "ppc64") { } else if (v8_current_cpu == "ppc64") {
sources += [ ### gcmole(arch:ppc64) ### sources += [
### gcmole(ppc64) ###
"src/baseline/ppc/baseline-assembler-ppc-inl.h", "src/baseline/ppc/baseline-assembler-ppc-inl.h",
"src/baseline/ppc/baseline-compiler-ppc-inl.h", "src/baseline/ppc/baseline-compiler-ppc-inl.h",
"src/codegen/ppc/assembler-ppc-inl.h", "src/codegen/ppc/assembler-ppc-inl.h",
@ -3938,7 +3946,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/ppc/liftoff-assembler-ppc.h", "src/wasm/baseline/ppc/liftoff-assembler-ppc.h",
] ]
} else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") { } else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") {
sources += [ ### gcmole(arch:s390) ### sources += [
### gcmole(s390) ###
"src/baseline/s390/baseline-assembler-s390-inl.h", "src/baseline/s390/baseline-assembler-s390-inl.h",
"src/baseline/s390/baseline-compiler-s390-inl.h", "src/baseline/s390/baseline-compiler-s390-inl.h",
"src/codegen/s390/assembler-s390-inl.h", "src/codegen/s390/assembler-s390-inl.h",
@ -3956,7 +3965,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/s390/liftoff-assembler-s390.h", "src/wasm/baseline/s390/liftoff-assembler-s390.h",
] ]
} else if (v8_current_cpu == "riscv64") { } else if (v8_current_cpu == "riscv64") {
sources += [ ### gcmole(arch:riscv64) ### sources += [
### gcmole(riscv64) ###
"src/baseline/riscv/baseline-assembler-riscv-inl.h", "src/baseline/riscv/baseline-assembler-riscv-inl.h",
"src/baseline/riscv/baseline-compiler-riscv-inl.h", "src/baseline/riscv/baseline-compiler-riscv-inl.h",
"src/codegen/riscv/assembler-riscv-inl.h", "src/codegen/riscv/assembler-riscv-inl.h",
@ -3995,7 +4005,8 @@ v8_header_set("v8_internal_headers") {
"src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h", "src/wasm/baseline/riscv64/liftoff-assembler-riscv64.h",
] ]
} else if (v8_current_cpu == "riscv32") { } else if (v8_current_cpu == "riscv32") {
sources += [ ### gcmole(arch:riscv32) ### sources += [
### gcmole(riscv32) ###
"src/baseline/riscv/baseline-assembler-riscv-inl.h", "src/baseline/riscv/baseline-assembler-riscv-inl.h",
"src/baseline/riscv/baseline-compiler-riscv-inl.h", "src/baseline/riscv/baseline-compiler-riscv-inl.h",
"src/codegen/riscv/assembler-riscv.h", "src/codegen/riscv/assembler-riscv.h",
@ -4771,7 +4782,8 @@ v8_source_set("v8_base_without_compiler") {
} }
if (v8_enable_webassembly) { if (v8_enable_webassembly) {
sources += [ ### gcmole(all) ### sources += [
### gcmole(all) ###
"src/asmjs/asm-js.cc", "src/asmjs/asm-js.cc",
"src/asmjs/asm-parser.cc", "src/asmjs/asm-parser.cc",
"src/asmjs/asm-scanner.cc", "src/asmjs/asm-scanner.cc",
@ -4853,7 +4865,8 @@ v8_source_set("v8_base_without_compiler") {
} }
if (v8_current_cpu == "x86") { if (v8_current_cpu == "x86") {
sources += [ ### gcmole(arch:ia32) ### sources += [
### gcmole(ia32) ###
"src/codegen/ia32/assembler-ia32.cc", "src/codegen/ia32/assembler-ia32.cc",
"src/codegen/ia32/cpu-ia32.cc", "src/codegen/ia32/cpu-ia32.cc",
"src/codegen/ia32/macro-assembler-ia32.cc", "src/codegen/ia32/macro-assembler-ia32.cc",
@ -4868,7 +4881,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/ia32/regexp-macro-assembler-ia32.cc", "src/regexp/ia32/regexp-macro-assembler-ia32.cc",
] ]
} else if (v8_current_cpu == "x64") { } else if (v8_current_cpu == "x64") {
sources += [ ### gcmole(arch:x64) ### sources += [
### gcmole(x64) ###
"src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.cc", "src/codegen/shared-ia32-x64/macro-assembler-shared-ia32-x64.cc",
"src/codegen/x64/assembler-x64.cc", "src/codegen/x64/assembler-x64.cc",
"src/codegen/x64/cpu-x64.cc", "src/codegen/x64/cpu-x64.cc",
@ -4906,7 +4920,8 @@ v8_source_set("v8_base_without_compiler") {
} }
} }
} else if (v8_current_cpu == "arm") { } else if (v8_current_cpu == "arm") {
sources += [ ### gcmole(arch:arm) ### sources += [
### gcmole(arm) ###
"src/codegen/arm/assembler-arm.cc", "src/codegen/arm/assembler-arm.cc",
"src/codegen/arm/constants-arm.cc", "src/codegen/arm/constants-arm.cc",
"src/codegen/arm/cpu-arm.cc", "src/codegen/arm/cpu-arm.cc",
@ -4924,7 +4939,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/arm/regexp-macro-assembler-arm.cc", "src/regexp/arm/regexp-macro-assembler-arm.cc",
] ]
} else if (v8_current_cpu == "arm64") { } else if (v8_current_cpu == "arm64") {
sources += [ ### gcmole(arch:arm64) ### sources += [
### gcmole(arm64) ###
"src/codegen/arm64/assembler-arm64.cc", "src/codegen/arm64/assembler-arm64.cc",
"src/codegen/arm64/cpu-arm64.cc", "src/codegen/arm64/cpu-arm64.cc",
"src/codegen/arm64/decoder-arm64.cc", "src/codegen/arm64/decoder-arm64.cc",
@ -4971,7 +4987,8 @@ v8_source_set("v8_base_without_compiler") {
sources += [ "src/diagnostics/unwinding-info-win64.cc" ] sources += [ "src/diagnostics/unwinding-info-win64.cc" ]
} }
} else if (v8_current_cpu == "mips64" || v8_current_cpu == "mips64el") { } else if (v8_current_cpu == "mips64" || v8_current_cpu == "mips64el") {
sources += [ ### gcmole(arch:mips64el) ### sources += [
### gcmole(mips64el) ###
"src/codegen/mips64/assembler-mips64.cc", "src/codegen/mips64/assembler-mips64.cc",
"src/codegen/mips64/constants-mips64.cc", "src/codegen/mips64/constants-mips64.cc",
"src/codegen/mips64/cpu-mips64.cc", "src/codegen/mips64/cpu-mips64.cc",
@ -4988,7 +5005,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/mips64/regexp-macro-assembler-mips64.cc", "src/regexp/mips64/regexp-macro-assembler-mips64.cc",
] ]
} else if (v8_current_cpu == "loong64") { } else if (v8_current_cpu == "loong64") {
sources += [ ### gcmole(arch:loong64) ### sources += [
### gcmole(loong64) ###
"src/codegen/loong64/assembler-loong64.cc", "src/codegen/loong64/assembler-loong64.cc",
"src/codegen/loong64/constants-loong64.cc", "src/codegen/loong64/constants-loong64.cc",
"src/codegen/loong64/cpu-loong64.cc", "src/codegen/loong64/cpu-loong64.cc",
@ -5005,7 +5023,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/loong64/regexp-macro-assembler-loong64.cc", "src/regexp/loong64/regexp-macro-assembler-loong64.cc",
] ]
} else if (v8_current_cpu == "ppc") { } else if (v8_current_cpu == "ppc") {
sources += [ ### gcmole(arch:ppc) ### sources += [
### gcmole(ppc) ###
"src/codegen/ppc/assembler-ppc.cc", "src/codegen/ppc/assembler-ppc.cc",
"src/codegen/ppc/constants-ppc.cc", "src/codegen/ppc/constants-ppc.cc",
"src/codegen/ppc/cpu-ppc.cc", "src/codegen/ppc/cpu-ppc.cc",
@ -5023,7 +5042,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/ppc/regexp-macro-assembler-ppc.cc", "src/regexp/ppc/regexp-macro-assembler-ppc.cc",
] ]
} else if (v8_current_cpu == "ppc64") { } else if (v8_current_cpu == "ppc64") {
sources += [ ### gcmole(arch:ppc64) ### sources += [
### gcmole(ppc64) ###
"src/codegen/ppc/assembler-ppc.cc", "src/codegen/ppc/assembler-ppc.cc",
"src/codegen/ppc/constants-ppc.cc", "src/codegen/ppc/constants-ppc.cc",
"src/codegen/ppc/cpu-ppc.cc", "src/codegen/ppc/cpu-ppc.cc",
@ -5041,7 +5061,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/ppc/regexp-macro-assembler-ppc.cc", "src/regexp/ppc/regexp-macro-assembler-ppc.cc",
] ]
} else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") { } else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") {
sources += [ ### gcmole(arch:s390) ### sources += [
### gcmole(s390) ###
"src/codegen/s390/assembler-s390.cc", "src/codegen/s390/assembler-s390.cc",
"src/codegen/s390/constants-s390.cc", "src/codegen/s390/constants-s390.cc",
"src/codegen/s390/cpu-s390.cc", "src/codegen/s390/cpu-s390.cc",
@ -5059,7 +5080,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/s390/regexp-macro-assembler-s390.cc", "src/regexp/s390/regexp-macro-assembler-s390.cc",
] ]
} else if (v8_current_cpu == "riscv64") { } else if (v8_current_cpu == "riscv64") {
sources += [ ### gcmole(arch:riscv64) ### sources += [
### gcmole(riscv64) ###
"src/codegen/riscv/assembler-riscv.cc", "src/codegen/riscv/assembler-riscv.cc",
"src/codegen/riscv/base-assembler-riscv.cc", "src/codegen/riscv/base-assembler-riscv.cc",
"src/codegen/riscv/base-constants-riscv.cc", "src/codegen/riscv/base-constants-riscv.cc",
@ -5085,7 +5107,8 @@ v8_source_set("v8_base_without_compiler") {
"src/regexp/riscv/regexp-macro-assembler-riscv.cc", "src/regexp/riscv/regexp-macro-assembler-riscv.cc",
] ]
} else if (v8_current_cpu == "riscv32") { } else if (v8_current_cpu == "riscv32") {
sources += [ ### gcmole(arch:riscv32) ### sources += [
### gcmole(riscv32) ###
"src/codegen/riscv/assembler-riscv.cc", "src/codegen/riscv/assembler-riscv.cc",
"src/codegen/riscv/base-assembler-riscv.cc", "src/codegen/riscv/base-assembler-riscv.cc",
"src/codegen/riscv/base-constants-riscv.cc", "src/codegen/riscv/base-constants-riscv.cc",

View File

@ -85,6 +85,7 @@ def _V8PresubmitChecks(input_api, output_api):
sys.path.append(input_api.os_path.join( sys.path.append(input_api.os_path.join(
input_api.PresubmitLocalPath(), 'tools')) input_api.PresubmitLocalPath(), 'tools'))
from v8_presubmit import CppLintProcessor from v8_presubmit import CppLintProcessor
from v8_presubmit import GCMoleProcessor
from v8_presubmit import JSLintProcessor from v8_presubmit import JSLintProcessor
from v8_presubmit import TorqueLintProcessor from v8_presubmit import TorqueLintProcessor
from v8_presubmit import SourceProcessor from v8_presubmit import SourceProcessor
@ -126,6 +127,9 @@ def _V8PresubmitChecks(input_api, output_api):
if not StatusFilesProcessor().RunOnFiles( if not StatusFilesProcessor().RunOnFiles(
input_api.AffectedFiles(include_deletes=True)): input_api.AffectedFiles(include_deletes=True)):
results.append(output_api.PresubmitError("Status file check failed")) results.append(output_api.PresubmitError("Status file check failed"))
if not GCMoleProcessor().RunOnFiles(
input_api.AffectedFiles(include_deletes=False)):
results.append(output_api.PresubmitError("GCMole pattern check failed"))
results.extend(input_api.canned_checks.CheckAuthorizedAuthor( results.extend(input_api.canned_checks.CheckAuthorizedAuthor(
input_api, output_api, bot_allowlist=[ input_api, output_api, bot_allowlist=[
'v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com' 'v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com'

View File

@ -207,7 +207,8 @@ v8_source_set("cctest_sources") {
] ]
if (v8_current_cpu == "arm") { if (v8_current_cpu == "arm") {
sources += [ ### gcmole(arch:arm) ### sources += [
### gcmole(arm) ###
"assembler-helper-arm.cc", "assembler-helper-arm.cc",
"assembler-helper-arm.h", "assembler-helper-arm.h",
"test-assembler-arm.cc", "test-assembler-arm.cc",
@ -215,7 +216,8 @@ v8_source_set("cctest_sources") {
"test-sync-primitives-arm.cc", "test-sync-primitives-arm.cc",
] ]
} else if (v8_current_cpu == "arm64") { } else if (v8_current_cpu == "arm64") {
sources += [ ### gcmole(arch:arm64) ### sources += [
### gcmole(arm64) ###
"test-assembler-arm64.cc", "test-assembler-arm64.cc",
"test-fuzz-arm64.cc", "test-fuzz-arm64.cc",
"test-javascript-arm64.cc", "test-javascript-arm64.cc",
@ -228,48 +230,60 @@ v8_source_set("cctest_sources") {
sources += [ "test-stack-unwinding-win64.cc" ] sources += [ "test-stack-unwinding-win64.cc" ]
} }
} else if (v8_current_cpu == "x86") { } else if (v8_current_cpu == "x86") {
sources += [ ### gcmole(arch:ia32) ### sources += [
### gcmole(ia32) ###
"test-assembler-ia32.cc", "test-assembler-ia32.cc",
"test-log-stack-tracer.cc", "test-log-stack-tracer.cc",
] ]
} else if (v8_current_cpu == "mips64") { } else if (v8_current_cpu == "mips64") {
sources += [ ### gcmole(arch:mips64) ### sources += [
### gcmole(mips64) ###
"test-assembler-mips64.cc", "test-assembler-mips64.cc",
"test-macro-assembler-mips64.cc", "test-macro-assembler-mips64.cc",
] ]
} else if (v8_current_cpu == "mips64el") { } else if (v8_current_cpu == "mips64el") {
sources += [ ### gcmole(arch:mips64el) ### sources += [
### gcmole(mips64el) ###
"test-assembler-mips64.cc", "test-assembler-mips64.cc",
"test-macro-assembler-mips64.cc", "test-macro-assembler-mips64.cc",
] ]
} else if (v8_current_cpu == "x64") { } else if (v8_current_cpu == "x64") {
sources += [ sources += [
### gcmole(arch:x64) ### ### gcmole(x64) ###
"test-log-stack-tracer.cc", "test-log-stack-tracer.cc",
] ]
if (is_win) { if (is_win) {
sources += [ "test-stack-unwinding-win64.cc" ] sources += [ "test-stack-unwinding-win64.cc" ]
} }
} else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") { } else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") {
sources += [ "test-assembler-ppc.cc" ] ### gcmole(arch:ppc) ### sources += [
### gcmole(ppc) ###
"test-assembler-ppc.cc",
]
} else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") { } else if (v8_current_cpu == "s390" || v8_current_cpu == "s390x") {
sources += [ "test-assembler-s390.cc" ] ### gcmole(arch:s390) ### sources += [
### gcmole(s390) ###
"test-assembler-s390.cc",
]
} else if (v8_current_cpu == "riscv64") { } else if (v8_current_cpu == "riscv64") {
sources += [ ### gcmole(arch:riscv64) ### sources += [
### gcmole(riscv64) ###
"test-assembler-riscv64.cc", "test-assembler-riscv64.cc",
"test-helper-riscv64.cc", "test-helper-riscv64.cc",
"test-macro-assembler-riscv64.cc", "test-macro-assembler-riscv64.cc",
"test-simple-riscv64.cc", "test-simple-riscv64.cc",
] ]
} else if (v8_current_cpu == "riscv32") { } else if (v8_current_cpu == "riscv32") {
sources += [ ### gcmole(arch:riscv32) ### sources += [
### gcmole(riscv32) ###
"test-assembler-riscv32.cc", "test-assembler-riscv32.cc",
"test-helper-riscv32.cc", "test-helper-riscv32.cc",
"test-macro-assembler-riscv32.cc", "test-macro-assembler-riscv32.cc",
"test-simple-riscv32.cc", "test-simple-riscv32.cc",
] ]
} else if (v8_current_cpu == "loong64") { } else if (v8_current_cpu == "loong64") {
sources += [ ### gcmole(arch:loong64) ### sources += [
### gcmole(loong64) ###
"test-assembler-loong64.cc", "test-assembler-loong64.cc",
"test-macro-assembler-loong64.cc", "test-macro-assembler-loong64.cc",
] ]

32
tools/gcmole/PRESUBMIT.py Normal file
View File

@ -0,0 +1,32 @@
# Copyright 2022 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
USE_PYTHON3 = True
def _RunTests(input_api, output_api):
return input_api.RunTests(
input_api.canned_checks.GetUnitTestsInDirectory(
input_api,
output_api,
'.',
files_to_check=[r'.+_test\.py$'],
run_on_python2=False))
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
checks = [
_RunTests,
]
return sum([check(input_api, output_api) for check in checks], [])
def CheckChangeOnCommit(input_api, output_api):
return _CommonChecks(input_api, output_api)
def CheckChangeOnUpload(input_api, output_api):
return _CommonChecks(input_api, output_api)

View File

@ -222,58 +222,42 @@ def invoke_clang_plugin_for_each_file(filenames, plugin, plugin_args, options):
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
def parse_gn_file(options, for_test): def build_file_list(options, for_test):
"""Calculates the list of source files to be checked with gcmole.
The list comprises all files from marked source sections in the
listed BUILD.gn files. All files preceeded by the following comment and
until the end of the source section are used:
### gcmole(arch) ###
Where arch can either be all (all architectures) or one of the supported V8
architectures.
The structure of these directives is also checked by presubmit via:
tools/v8_presubmit.py::GCMoleProcessor.
Returns: List of file paths (of type Path).
"""
if for_test: if for_test:
return {"all": [options.v8_root_dir / "tools/gcmole/gcmole-test.cc"]} return [options.v8_root_dir / "tools/gcmole/gcmole-test.cc"]
result = {} result = []
gn_files = [ gn_files = [
("BUILD.gn", re.compile('"([^"]*?\.cc)"'), ""), ("BUILD.gn", re.compile('"([^"]*?\.cc)"'), ""),
("test/cctest/BUILD.gn", re.compile('"(test-[^"]*?\.cc)"'), ("test/cctest/BUILD.gn", re.compile('"(test-[^"]*?\.cc)"'),
Path("test/cctest/")), Path("test/cctest/")),
] ]
for filename, pattern, prefix in gn_files: gn_re = re.compile(f"### gcmole\((all|{options.v8_target_cpu})\) ###(.*?)\]",
re.MULTILINE | re.DOTALL)
for filename, file_pattern, prefix in gn_files:
path = options.v8_root_dir / filename path = options.v8_root_dir / filename
with open(path) as gn_file: with open(path) as gn_file:
gn = gn_file.read() gn = gn_file.read()
for condition, sources in re.findall("### gcmole\((.*?)\) ###(.*?)\]", gn, for _, sources in gn_re.findall(gn):
re.MULTILINE | re.DOTALL): for file in file_pattern.findall(sources):
if condition not in result: result.append(options.v8_root_dir / prefix / file)
result[condition] = []
for file in pattern.findall(sources):
result[condition].append(options.v8_root_dir / prefix / file)
return result return result
def evaluate_condition(cond, props):
if cond == "all":
return True
m = re.match("(\w+):(\w+)", cond)
if m is None:
fatal("failed to parse condition: {}", cond)
p, v = m.groups()
if p not in props:
fatal("undefined configuration property: {}", p)
return props[p] == v
def build_file_list(options, for_test):
sources = parse_gn_file(options, for_test)
props = {
"os": "linux",
"arch": options.v8_target_cpu,
"mode": "debug",
"simulator": ""
}
ret = []
for condition, files in list(sources.items()):
if evaluate_condition(condition, props):
ret += files
return ret
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# GCSuspects Generation # GCSuspects Generation

View File

@ -0,0 +1,64 @@
#!/usr/bin/env python3
# Copyright 2022 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from pathlib import Path
import collections
import os
import unittest
import gcmole
TESTDATA_PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'testdata', 'v8')
Options = collections.namedtuple('Options', ['v8_root_dir', 'v8_target_cpu'])
def abs_test_file(f):
return Path(os.path.join(TESTDATA_PATH, f))
class FilesTest(unittest.TestCase):
def testFileList_for_testing(self):
options = Options(Path(TESTDATA_PATH), 'x64')
self.assertEqual(
gcmole.build_file_list(options, True),
list(map(abs_test_file, ['tools/gcmole/gcmole-test.cc'])))
def testFileList_x64(self):
options = Options(Path(TESTDATA_PATH), 'x64')
expected = [
'file1.cc',
'file2.cc',
'x64/file1.cc',
'x64/file2.cc',
'file3.cc',
'file4.cc',
'test/cctest/test-x64-file1.cc',
'test/cctest/test-x64-file2.cc',
]
self.assertEqual(
gcmole.build_file_list(options, False),
list(map(abs_test_file, expected)))
def testFileList_arm(self):
options = Options(Path(TESTDATA_PATH), 'arm')
expected = [
'file1.cc',
'file2.cc',
'file3.cc',
'file4.cc',
'arm/file1.cc',
'arm/file2.cc',
]
self.assertEqual(
gcmole.build_file_list(options, False),
list(map(abs_test_file, expected)))
if __name__ == '__main__':
unittest.main()

35
tools/gcmole/testdata/v8/BUILD.gn vendored Normal file
View File

@ -0,0 +1,35 @@
# Copyright 2022 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Test data for gcmole.
some_sources = [
### gcmole(all) ###
"file1.cc",
"file1.h",
"file2.cc",
]
other_sources = [
### gcmole(x64) ###
"x64/file1.cc",
"x64/file1.h",
"x64/file2.cc",
]
yet_more_sources = [
### gcmole(all) ###
"file3.cc",
# Some other comment.
"file4.cc",
"file4.h",
]
the_last_sources = [
### gcmole(arm) ###
"arm/file1.cc",
"arm/file1.h",
"arm/file2.cc",
]

View File

@ -0,0 +1,12 @@
# Copyright 2022 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Test data for gcmole.
some_sources = [
### gcmole(x64) ###
"foo-x64-file1.cc",
"test-x64-file1.cc",
"test-x64-file2.cc",
]

View File

@ -719,6 +719,45 @@ class StatusFilesProcessor(SourceFileProcessor):
return status_files return status_files
class GCMoleProcessor(SourceFileProcessor):
"""Check relevant BUILD.gn files for correct gcmole file pattern.
The pattern must match the algorithm used in:
tools/gcmole/gcmole.py::build_file_list()
"""
gcmole_re = re.compile('### gcmole(.*)')
arch_re = re.compile('\((.+)\) ###')
def IsRelevant(self, name):
return True
def GetPathsToSearch(self):
# TODO(https://crbug.com/v8/12660): These should be directories according
# to the API, but in order to find the toplevel BUILD.gn, we'd need to walk
# the entire project.
return ['BUILD.gn', 'test/cctest/BUILD.gn']
def ProcessFiles(self, files):
success = True
for path in files:
with open(path) as f:
gn_file_text = f.read()
for suffix in self.gcmole_re.findall(gn_file_text):
arch_match = self.arch_re.match(suffix)
if not arch_match:
print(f'{path}: Malformed gcmole suffix: {suffix}')
success = False
continue
arch = arch_match.group(1)
if arch not in [
'all', 'ia32', 'x64', 'arm', 'arm64', 's390', 'ppc', 'ppc64',
'mips64', 'mips64el', 'riscv32', 'riscv64', 'loong64'
]:
print(f'{path}: Unknown architecture for gcmole: {arch}')
success = False
return success
def CheckDeps(workspace): def CheckDeps(workspace):
checkdeps_py = join(workspace, 'buildtools', 'checkdeps', 'checkdeps.py') checkdeps_py = join(workspace, 'buildtools', 'checkdeps', 'checkdeps.py')
return subprocess.call([sys.executable, checkdeps_py, workspace]) == 0 return subprocess.call([sys.executable, checkdeps_py, workspace]) == 0
@ -792,6 +831,8 @@ def Main():
success &= StatusFilesProcessor().RunOnPath(workspace) success &= StatusFilesProcessor().RunOnPath(workspace)
print("Running python tests...") print("Running python tests...")
success &= PyTests(workspace) success &= PyTests(workspace)
print("Running gcmole pattern check...")
success &= GCMoleProcessor().RunOnPath(workspace)
if success: if success:
return 0 return 0
else: else: