Skip to content

Commit 7a5bac5

Browse files
committed
build: add target for checking for perm deopts
PR-URL: #12456 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 91ccea6 commit 7a5bac5

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ test-parallel: all
205205
test-valgrind: all
206206
$(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message
207207

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

tools/test.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,39 @@ def HasRun(self, output):
341341
def Done(self):
342342
pass
343343

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

345378
class CompactProgressIndicator(ProgressIndicator):
346379

@@ -433,7 +466,8 @@ def ClearLine(self, last_line_length):
433466
'dots': DotsProgressIndicator,
434467
'color': ColorProgressIndicator,
435468
'tap': TapProgressIndicator,
436-
'mono': MonochromeProgressIndicator
469+
'mono': MonochromeProgressIndicator,
470+
'deopts': DeoptsCheckProgressIndicator
437471
}
438472

439473

@@ -1383,6 +1417,8 @@ def BuildOptions():
13831417
help="Expect test cases to fail", default=False, action="store_true")
13841418
result.add_option("--valgrind", help="Run tests through valgrind",
13851419
default=False, action="store_true")
1420+
result.add_option("--check-deopts", help="Check tests for permanent deoptimizations",
1421+
default=False, action="store_true")
13861422
result.add_option("--cat", help="Print the source of the tests",
13871423
default=False, action="store_true")
13881424
result.add_option("--flaky-tests",
@@ -1586,6 +1622,14 @@ def Main():
15861622
run_valgrind = join(workspace, "tools", "run-valgrind.py")
15871623
options.special_command = "python -u " + run_valgrind + " @"
15881624

1625+
if options.check_deopts:
1626+
options.node_args.append("--trace-opt")
1627+
options.node_args.append("--trace-file-names")
1628+
# --always-opt is needed because many tests do not run long enough for the
1629+
# optimizer to kick in, so this flag will force it to run.
1630+
options.node_args.append("--always-opt")
1631+
options.progress = "deopts"
1632+
15891633
shell = abspath(options.shell)
15901634
buildspace = dirname(shell)
15911635

vcbuild.bat

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set build_addons=
4242
set dll=
4343
set build_addons_napi=
4444
set test_node_inspect=
45+
set test_check_deopts=
4546

4647
:next-arg
4748
if "%1"=="" goto args-done
@@ -74,6 +75,7 @@ if /i "%1"=="test-pummel" set test_args=%test_args% pummel&goto arg-ok
7475
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
7576
if /i "%1"=="test-known-issues" set test_args=%test_args% known_issues&goto arg-ok
7677
if /i "%1"=="test-node-inspect" set test_node_inspect=1&goto arg-ok
78+
if /i "%1"=="test-check-deopts" set test_check_deopts=1&goto arg-ok
7779
if /i "%1"=="jslint" set jslint=1&goto arg-ok
7880
if /i "%1"=="jslint-ci" set jslint_ci=1&goto arg-ok
7981
if /i "%1"=="lint" set cpplint=1&set jslint=1&goto arg-ok
@@ -361,7 +363,16 @@ endlocal
361363
goto run-tests
362364

363365
:run-tests
364-
if not defined test_node_inspect goto node-tests
366+
if defined test_check_deopts goto node-check-deopts
367+
if defined test_node_inspect goto node-test-inspect
368+
goto node-tests
369+
370+
:node-check-deopts
371+
python tools\test.py --mode=release --check-deopts parallel sequential -J
372+
if defined test_node_inspect goto node-test-inspect
373+
goto node-tests
374+
375+
:node-test-inspect
365376
set USE_EMBEDDED_NODE_INSPECT=1
366377
%config%\node tools\test-npm-package.js --install deps\node-inspect test
367378
goto node-tests

0 commit comments

Comments
 (0)