Skip to content

Commit cd7fda2

Browse files
mscdexevanlucas
authored andcommitted
build: add target for checking for perm deopts
PR-URL: #12456 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent c7118d6 commit cd7fda2

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ test-parallel: all
204204
test-valgrind: all
205205
$(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
206206

207+
test-check-deopts: all
208+
$(PYTHON) tools/test.py --mode=release --check-deopts parallel sequential -J
209+
207210
# Implicitly depends on $(NODE_EXE). We don't depend on it explicitly because
208211
# it always triggers a rebuild due to it being a .PHONY rule. See the comment
209212
# near the build-addons rule for more background.

tools/test.py

+45-1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,39 @@ def HasRun(self, output):
340340
def Done(self):
341341
pass
342342

343+
class DeoptsCheckProgressIndicator(SimpleProgressIndicator):
344+
345+
def Starting(self):
346+
pass
347+
348+
def AboutToRun(self, case):
349+
pass
350+
351+
def HasRun(self, output):
352+
# Print test name as (for example) "parallel/test-assert". Tests that are
353+
# scraped from the addons documentation are all named test.js, making it
354+
# hard to decipher what test is running when only the filename is printed.
355+
prefix = abspath(join(dirname(__file__), '../test')) + os.sep
356+
command = output.command[-1]
357+
if command.endswith('.js'): command = command[:-3]
358+
if command.startswith(prefix): command = command[len(prefix):]
359+
command = command.replace('\\', '/')
360+
361+
stdout = output.output.stdout.strip()
362+
printed_file = False
363+
for line in stdout.splitlines():
364+
if (line.startswith("[aborted optimiz") or \
365+
line.startswith("[disabled optimiz")) and \
366+
("because:" in line or "reason:" in line):
367+
if not printed_file:
368+
printed_file = True
369+
print '==== %s ====' % command
370+
self.failed.append(output)
371+
print ' %s' % line
372+
373+
def Done(self):
374+
pass
375+
343376

344377
class CompactProgressIndicator(ProgressIndicator):
345378

@@ -432,7 +465,8 @@ def ClearLine(self, last_line_length):
432465
'dots': DotsProgressIndicator,
433466
'color': ColorProgressIndicator,
434467
'tap': TapProgressIndicator,
435-
'mono': MonochromeProgressIndicator
468+
'mono': MonochromeProgressIndicator,
469+
'deopts': DeoptsCheckProgressIndicator
436470
}
437471

438472

@@ -1367,6 +1401,8 @@ def BuildOptions():
13671401
help="Expect test cases to fail", default=False, action="store_true")
13681402
result.add_option("--valgrind", help="Run tests through valgrind",
13691403
default=False, action="store_true")
1404+
result.add_option("--check-deopts", help="Check tests for permanent deoptimizations",
1405+
default=False, action="store_true")
13701406
result.add_option("--cat", help="Print the source of the tests",
13711407
default=False, action="store_true")
13721408
result.add_option("--flaky-tests",
@@ -1569,6 +1605,14 @@ def Main():
15691605
run_valgrind = join(workspace, "tools", "run-valgrind.py")
15701606
options.special_command = "python -u " + run_valgrind + " @"
15711607

1608+
if options.check_deopts:
1609+
options.node_args.append("--trace-opt")
1610+
options.node_args.append("--trace-file-names")
1611+
# --always-opt is needed because many tests do not run long enough for the
1612+
# optimizer to kick in, so this flag will force it to run.
1613+
options.node_args.append("--always-opt")
1614+
options.progress = "deopts"
1615+
15721616
shell = abspath(options.shell)
15731617
buildspace = dirname(shell)
15741618

vcbuild.bat

+12-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ set configure_flags=
4141
set build_addons=
4242
set dll=
4343
set test_node_inspect=
44+
set test_check_deopts=
4445

4546
:next-arg
4647
if "%1"=="" goto args-done
@@ -71,6 +72,7 @@ if /i "%1"=="test-pummel" set test_args=%test_args% pummel&goto arg-ok
7172
if /i "%1"=="test-all" set test_args=%test_args% sequential parallel message gc inspector internet pummel&set build_testgc_addon=1&set cpplint=1&set jslint=1&goto arg-ok
7273
if /i "%1"=="test-known-issues" set test_args=%test_args% known_issues&goto arg-ok
7374
if /i "%1"=="test-node-inspect" set test_node_inspect=1&goto arg-ok
75+
if /i "%1"=="test-check-deopts" set test_check_deopts=1&goto arg-ok
7476
if /i "%1"=="jslint" set jslint=1&goto arg-ok
7577
if /i "%1"=="jslint-ci" set jslint_ci=1&goto arg-ok
7678
if /i "%1"=="lint" set cpplint=1&set jslint=1&goto arg-ok
@@ -338,7 +340,16 @@ endlocal
338340
goto run-tests
339341

340342
:run-tests
341-
if not defined test_node_inspect goto node-tests
343+
if defined test_check_deopts goto node-check-deopts
344+
if defined test_node_inspect goto node-test-inspect
345+
goto node-tests
346+
347+
:node-check-deopts
348+
python tools\test.py --mode=release --check-deopts parallel sequential -J
349+
if defined test_node_inspect goto node-test-inspect
350+
goto node-tests
351+
352+
:node-test-inspect
342353
set USE_EMBEDDED_NODE_INSPECT=1
343354
%config%\node tools\test-npm-package.js --install deps\node-inspect test
344355
goto node-tests

0 commit comments

Comments
 (0)