Skip to content

Commit

Permalink
deps: V8: cherry-pick d724820c1d5d
Browse files Browse the repository at this point in the history
Original commit message:

    Merged: Squashed multiple commits.

    Merged: [test] Make finding build directory more flexible
    Revision: 4f015e85faf1d64466eafd897d1d59b1d77071f3

    Merged: [test] Use the correct precedence for choosing the build directory
    Revision: 7b24b13981e411602fc77db1305d0ae034a92fd8

    Merged: [test] Add fallback to legacy output directory
    Revision: bf3adea58aab3d21e36e23c60e1e0bbc994cd5b8

    Merged: [gcmole] Fix gcmole after property change
    Revision: c87bdbcf0d1d8f8bcc927f6b364d27e72c22736d

    Merged: [test] Overhaul mode processing in test runner
    Revision: 608b732d141689e8e10ee918afc8ed1fae1ab80c

    Merged: [test] Switch to flattened json output
    Revision: 373a9a8cfc8db3ef65fcdca0ec0c4ded9e4acc89

    BUG=chromium:1132088,v8:10893
    NOTRY=true
    NOTREECHECKS=true
    R=liviurau@chromium.org

    Change-Id: I3c1de04ca4fe62e36da29e706a20daec0b3d4d98
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2461745
    Reviewed-by: Liviu Rau <liviurau@chromium.org>
    Commit-Queue: Michael Achenbach <machenbach@chromium.org>
    Cr-Commit-Position: refs/branch-heads/8.6@{#20}
    Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1}
    Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472}

Refs: v8/v8@d724820

PR-URL: #38275
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
  • Loading branch information
targos committed Apr 30, 2021
1 parent aaeeb75 commit b10cce1
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 204 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.33',
'v8_embedder_string': '-node.34',

##### V8 defaults for Node.js #####

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/tools/gcmole/gcmole.lua
Expand Up @@ -116,7 +116,7 @@ local function MakeClangCommandLine(
.. " -DV8_INTL_SUPPORT"
.. " -I./"
.. " -Iinclude/"
.. " -Iout/Release/gen"
.. " -Iout/build/gen"
.. " -Ithird_party/icu/source/common"
.. " -Ithird_party/icu/source/i18n"
.. " " .. arch_options
Expand Down
6 changes: 3 additions & 3 deletions deps/v8/tools/gcmole/run-gcmole.py
Expand Up @@ -21,9 +21,9 @@

assert len(sys.argv) == 2

if not os.path.isfile("out/Release/gen/torque-generated/builtin-definitions-tq.h"):
print("Expected generated headers in out/Release/gen.")
print("Either build v8 in out/Release or change gcmole.lua:115")
if not os.path.isfile("out/build/gen/torque-generated/builtin-definitions-tq.h"):
print("Expected generated headers in out/build/gen.")
print("Either build v8 in out/build or change gcmole.lua:115")
sys.exit(-1)

proc = subprocess.Popen(
Expand Down
41 changes: 31 additions & 10 deletions deps/v8/tools/run_perf.py
Expand Up @@ -575,6 +575,32 @@ def FlattenRunnables(node, node_cb):
raise Exception('Invalid suite configuration.')


def find_build_directory(base_path, arch):
"""Returns the location of d8 or node in the build output directory.
This supports a seamless transition between legacy build location
(out/Release) and new build location (out/build).
"""
def is_build(path):
# We support d8 or node as executables. We don't support testing on
# Windows.
return (os.path.isfile(os.path.join(path, 'd8')) or
os.path.isfile(os.path.join(path, 'node')))
possible_paths = [
# Location developer wrapper scripts is using.
'%s.release' % arch,
# Current build location on bots.
'build',
# Legacy build location on bots.
'Release',
]
possible_paths = [os.path.join(base_path, p) for p in possible_paths]
actual_paths = filter(is_build, possible_paths)
assert actual_paths, 'No build directory found.'
assert len(actual_paths) == 1, 'Found ambiguous build directories.'
return actual_paths[0]


class Platform(object):
def __init__(self, args):
self.shell_dir = args.shell_dir
Expand Down Expand Up @@ -881,8 +907,7 @@ def Main(argv):
'to auto-detect.', default='x64',
choices=SUPPORTED_ARCHS + ['auto'])
parser.add_argument('--buildbot',
help='Adapt to path structure used on buildbots and adds '
'timestamps/level to all logged status messages',
help='Deprecated',
default=False, action='store_true')
parser.add_argument('-d', '--device',
help='The device ID to run Android tests on. If not '
Expand Down Expand Up @@ -978,13 +1003,9 @@ def Main(argv):

workspace = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))

if args.buildbot:
build_config = 'Release'
else:
build_config = '%s.release' % args.arch

if args.binary_override_path == None:
args.shell_dir = os.path.join(workspace, args.outdir, build_config)
args.shell_dir = find_build_directory(
os.path.join(workspace, args.outdir), args.arch)
default_binary_name = 'd8'
else:
if not os.path.isfile(args.binary_override_path):
Expand All @@ -998,8 +1019,8 @@ def Main(argv):
default_binary_name = os.path.basename(args.binary_override_path)

if args.outdir_secondary:
args.shell_dir_secondary = os.path.join(
workspace, args.outdir_secondary, build_config)
args.shell_dir_secondary = find_build_directory(
os.path.join(workspace, args.outdir_secondary), args.arch)
else:
args.shell_dir_secondary = None

Expand Down
170 changes: 57 additions & 113 deletions deps/v8/tools/testrunner/base_runner.py
Expand Up @@ -6,7 +6,7 @@
from __future__ import print_function
from functools import reduce

from collections import OrderedDict
from collections import OrderedDict, namedtuple
import json
import multiprocessing
import optparse
Expand Down Expand Up @@ -115,52 +115,35 @@
]


class ModeConfig(object):
def __init__(self, flags, timeout_scalefactor, status_mode, execution_mode):
self.flags = flags
self.timeout_scalefactor = timeout_scalefactor
self.status_mode = status_mode
self.execution_mode = execution_mode

ModeConfig = namedtuple(
'ModeConfig', 'label flags timeout_scalefactor status_mode')

DEBUG_FLAGS = ["--nohard-abort", "--enable-slow-asserts", "--verify-heap"]
RELEASE_FLAGS = ["--nohard-abort"]
MODES = {
"debug": ModeConfig(
flags=DEBUG_FLAGS,
timeout_scalefactor=4,
status_mode="debug",
execution_mode="debug",
),
"optdebug": ModeConfig(

DEBUG_MODE = ModeConfig(
label='debug',
flags=DEBUG_FLAGS,
timeout_scalefactor=4,
status_mode="debug",
execution_mode="debug",
),
"release": ModeConfig(
)

RELEASE_MODE = ModeConfig(
label='release',
flags=RELEASE_FLAGS,
timeout_scalefactor=1,
status_mode="release",
execution_mode="release",
),
# Normal trybot release configuration. There, dchecks are always on which
# implies debug is set. Hence, the status file needs to assume debug-like
# behavior/timeouts.
"tryrelease": ModeConfig(
)

# Normal trybot release configuration. There, dchecks are always on which
# implies debug is set. Hence, the status file needs to assume debug-like
# behavior/timeouts.
TRY_RELEASE_MODE = ModeConfig(
label='release+dchecks',
flags=RELEASE_FLAGS,
timeout_scalefactor=1,
status_mode="debug",
execution_mode="release",
),
# This mode requires v8 to be compiled with dchecks and slow dchecks.
"slowrelease": ModeConfig(
flags=RELEASE_FLAGS + ["--enable-slow-asserts"],
timeout_scalefactor=2,
timeout_scalefactor=4,
status_mode="debug",
execution_mode="release",
),
}
)

PROGRESS_INDICATORS = {
'verbose': progress.VerboseProgressIndicator,
Expand Down Expand Up @@ -240,12 +223,29 @@ def __str__(self):
return '\n'.join(detected_options)


def _do_load_build_config(outdir, verbose=False):
build_config_path = os.path.join(outdir, "v8_build_config.json")
if not os.path.exists(build_config_path):
if verbose:
print("Didn't find build config: %s" % build_config_path)
raise TestRunnerError()

with open(build_config_path) as f:
try:
build_config_json = json.load(f)
except Exception: # pragma: no cover
print("%s exists but contains invalid json. Is your build up-to-date?"
% build_config_path)
raise TestRunnerError()

return BuildConfig(build_config_json)


class BaseTestRunner(object):
def __init__(self, basedir=None):
self.basedir = basedir or BASE_DIR
self.outdir = None
self.build_config = None
self.mode_name = None
self.mode_options = None
self.target_os = None

Expand Down Expand Up @@ -279,7 +279,7 @@ def execute(self, sys_args=None):
tests = self._load_testsuite_generators(args, options)
self._setup_env()
print(">>> Running tests for %s.%s" % (self.build_config.arch,
self.mode_name))
self.mode_options.label))
exit_code = self._do_execute(tests, args, options)
if exit_code == utils.EXIT_CODE_FAILURES and options.json_test_results:
print("Force exit code 0 after failures. Json test results file "
Expand Down Expand Up @@ -313,9 +313,6 @@ def _add_parser_default_options(self, parser):
default="out")
parser.add_option("--arch",
help="The architecture to run tests for")
parser.add_option("-m", "--mode",
help="The test mode in which to run (uppercase for builds"
" in CI): %s" % MODES.keys())
parser.add_option("--shell-dir", help="DEPRECATED! Executables from build "
"directory will be used")
parser.add_option("--test-root", help="Root directory of the test suites",
Expand Down Expand Up @@ -400,17 +397,21 @@ def _add_parser_options(self, parser):
def _parse_args(self, parser, sys_args):
options, args = parser.parse_args(sys_args)

if any(map(lambda v: v and ',' in v,
[options.arch, options.mode])): # pragma: no cover
print('Multiple arch/mode are deprecated')
if options.arch and ',' in options.arch: # pragma: no cover
print('Multiple architectures are deprecated')
raise TestRunnerError()

return options, args

def _load_build_config(self, options):
for outdir in self._possible_outdirs(options):
try:
self.build_config = self._do_load_build_config(outdir, options.verbose)
self.build_config = _do_load_build_config(outdir, options.verbose)

# In auto-detect mode the outdir is always where we found the build config.
# This ensures that we'll also take the build products from there.
self.outdir = outdir
break
except TestRunnerError:
pass

Expand All @@ -433,26 +434,21 @@ def _load_build_config(self, options):
# Returns possible build paths in order:
# gn
# outdir
# outdir/arch.mode
# Each path is provided in two versions: <path> and <path>/mode for bots.
# outdir on bots
def _possible_outdirs(self, options):
def outdirs():
if options.gn:
yield self._get_gn_outdir()
return

yield options.outdir
if options.arch and options.mode:
yield os.path.join(options.outdir,
'%s.%s' % (options.arch, options.mode))

if os.path.basename(options.outdir) != 'build':
yield os.path.join(options.outdir, 'build')

for outdir in outdirs():
yield os.path.join(self.basedir, outdir)

# bot option
if options.mode:
yield os.path.join(self.basedir, outdir, options.mode)

def _get_gn_outdir(self):
gn_out_dir = os.path.join(self.basedir, DEFAULT_OUT_GN)
latest_timestamp = -1
Expand All @@ -468,51 +464,13 @@ def _get_gn_outdir(self):
print(">>> Latest GN build found: %s" % latest_config)
return os.path.join(DEFAULT_OUT_GN, latest_config)

def _do_load_build_config(self, outdir, verbose=False):
build_config_path = os.path.join(outdir, "v8_build_config.json")
if not os.path.exists(build_config_path):
if verbose:
print("Didn't find build config: %s" % build_config_path)
raise TestRunnerError()

with open(build_config_path) as f:
try:
build_config_json = json.load(f)
except Exception: # pragma: no cover
print("%s exists but contains invalid json. Is your build up-to-date?"
% build_config_path)
raise TestRunnerError()

# In auto-detect mode the outdir is always where we found the build config.
# This ensures that we'll also take the build products from there.
self.outdir = os.path.dirname(build_config_path)

return BuildConfig(build_config_json)

def _process_default_options(self, options):
# We don't use the mode for more path-magic.
# Therefore transform the bot mode here to fix build_config value.
if options.mode:
options.mode = self._bot_to_v8_mode(options.mode)

build_config_mode = 'debug' if self.build_config.is_debug else 'release'
if options.mode:
if options.mode not in MODES: # pragma: no cover
print('%s mode is invalid' % options.mode)
raise TestRunnerError()
if MODES[options.mode].execution_mode != build_config_mode:
print ('execution mode (%s) for %s is inconsistent with build config '
'(%s)' % (
MODES[options.mode].execution_mode,
options.mode,
build_config_mode))
raise TestRunnerError()

self.mode_name = options.mode
if self.build_config.is_debug:
self.mode_options = DEBUG_MODE
elif self.build_config.dcheck_always_on:
self.mode_options = TRY_RELEASE_MODE
else:
self.mode_name = build_config_mode

self.mode_options = MODES[self.mode_name]
self.mode_options = RELEASE_MODE

if options.arch and options.arch != self.build_config.arch:
print('--arch value (%s) inconsistent with build config (%s).' % (
Expand All @@ -533,15 +491,6 @@ def _process_default_options(self, options):
options.command_prefix = shlex.split(options.command_prefix)
options.extra_flags = sum(map(shlex.split, options.extra_flags), [])

def _bot_to_v8_mode(self, config):
"""Convert build configs from bots to configs understood by the v8 runner.
V8 configs are always lower case and without the additional _x64 suffix
for 64 bit builds on windows with ninja.
"""
mode = config[:-4] if config.endswith('_x64') else config
return mode.lower()

def _process_options(self, options):
pass

Expand Down Expand Up @@ -689,9 +638,7 @@ def _get_statusfile_variables(self, options):
"is_clang": self.build_config.is_clang,
"is_full_debug": self.build_config.is_full_debug,
"mips_arch_variant": mips_arch_variant,
"mode": self.mode_options.status_mode
if not self.build_config.dcheck_always_on
else "debug",
"mode": self.mode_options.status_mode,
"msan": self.build_config.msan,
"no_harness": options.no_harness,
"no_i18n": self.build_config.no_i18n,
Expand Down Expand Up @@ -804,10 +751,7 @@ def _create_progress_indicators(self, test_count, options):
procs.append(progress.JUnitTestProgressIndicator(options.junitout,
options.junittestsuite))
if options.json_test_results:
procs.append(progress.JsonTestProgressIndicator(
self.framework_name,
self.build_config.arch,
self.mode_options.execution_mode))
procs.append(progress.JsonTestProgressIndicator(self.framework_name))

for proc in procs:
proc.configure(options)
Expand Down
4 changes: 1 addition & 3 deletions deps/v8/tools/testrunner/standard_runner.py
Expand Up @@ -379,10 +379,8 @@ def _duration_results_text(test):
]

assert os.path.exists(options.json_test_results)
complete_results = []
with open(options.json_test_results, "r") as f:
complete_results = json.loads(f.read())
output = complete_results[0]
output = json.load(f)
lines = []
for test in output['slowest_tests']:
suffix = ''
Expand Down

0 comments on commit b10cce1

Please sign in to comment.