comparison mx/mx_graal.py @ 20000:e8a0a61526b2

added support for refining the tasks run by 'mx gate' (e.g., 'mx gate -t Economy' will only run tasks whose title contains the substring 'Economy')
author Doug Simon <doug.simon@oracle.com>
date Mon, 23 Mar 2015 13:36:04 +0100
parents c70ef0d09be9
children 5aa0cb2914f8
comparison
equal deleted inserted replaced
19999:43661c648060 20000:e8a0a61526b2
1423 vm(vmargs, vm=v, vmbuild=vmbuild) 1423 vm(vmargs, vm=v, vmbuild=vmbuild)
1424 allDuration = datetime.timedelta(seconds=time.time() - allStart) 1424 allDuration = datetime.timedelta(seconds=time.time() - allStart)
1425 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']') 1425 mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']')
1426 1426
1427 class Task: 1427 class Task:
1428 # None or a list of strings. If not None, only tasks whose title
1429 # matches at least one of the substrings in this list will return
1430 # a non-None value from __enter__. The body of a 'with Task(...) as t'
1431 # statement should check 't' and exit immediately if it is None.
1432 filters = None
1433
1428 def __init__(self, title, tasks=None): 1434 def __init__(self, title, tasks=None):
1429 self.start = time.time() 1435 self.tasks = tasks
1430 self.title = title 1436 self.title = title
1431 self.end = None 1437 self.skipped = Task.filters is not None and not any([f in title for f in Task.filters])
1432 self.duration = None 1438 if not self.skipped:
1433 self.tasks = tasks 1439 self.start = time.time()
1434 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: BEGIN: ') + title) 1440 self.end = None
1441 self.duration = None
1442 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: BEGIN: ') + title)
1435 def __enter__(self): 1443 def __enter__(self):
1436 assert self.tasks is not None, "using Task with 'with' statement requires to pass the tasks list in the constructor" 1444 assert self.tasks is not None, "using Task with 'with' statement requires to pass the tasks list in the constructor"
1445 if self.skipped:
1446 return None
1437 return self 1447 return self
1438 def __exit__(self, exc_type, exc_value, traceback): 1448 def __exit__(self, exc_type, exc_value, traceback):
1439 self.tasks.append(self.stop()) 1449 if not self.skipped:
1450 self.tasks.append(self.stop())
1440 def stop(self): 1451 def stop(self):
1441 self.end = time.time() 1452 self.end = time.time()
1442 self.duration = datetime.timedelta(seconds=self.end - self.start) 1453 self.duration = datetime.timedelta(seconds=self.end - self.start)
1443 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: END: ') + self.title + ' [' + str(self.duration) + ']') 1454 mx.log(time.strftime('gate: %d %b %Y %H:%M:%S: END: ') + self.title + ' [' + str(self.duration) + ']')
1444 return self 1455 return self
1479 vmargs += ['-Xbootclasspath/p:' + jar] 1490 vmargs += ['-Xbootclasspath/p:' + jar]
1480 vm(vmargs) 1491 vm(vmargs)
1481 1492
1482 def _basic_gate_body(args, tasks): 1493 def _basic_gate_body(args, tasks):
1483 # Build server-hosted-graal now so we can run the unit tests 1494 # Build server-hosted-graal now so we can run the unit tests
1484 with Task('BuildHotSpotGraalHosted: product', tasks): 1495 with Task('BuildHotSpotGraalHosted: product', tasks) as t:
1485 buildvms(['--vms', 'server', '--builds', 'product']) 1496 if t: buildvms(['--vms', 'server', '--builds', 'product'])
1486 1497
1487 # Run unit tests on server-hosted-graal 1498 # Run unit tests on server-hosted-graal
1488 with VM('server', 'product'): 1499 with VM('server', 'product'):
1489 with Task('UnitTests:hosted-product', tasks): 1500 with Task('UnitTests:hosted-product', tasks) as t:
1490 unittest(['--enable-timing', '--verbose', '--fail-fast']) 1501 if t: unittest(['--enable-timing', '--verbose', '--fail-fast'])
1491 1502
1492 # Build the other VM flavors 1503 # Build the other VM flavors
1493 with Task('BuildHotSpotGraalOthers: fastdebug,product', tasks): 1504 with Task('BuildHotSpotGraalOthers: fastdebug,product', tasks) as t:
1494 buildvms(['--vms', 'graal,server', '--builds', 'fastdebug,product']) 1505 if t: buildvms(['--vms', 'graal,server', '--builds', 'fastdebug,product'])
1495 1506
1496 with VM('graal', 'fastdebug'): 1507 with VM('graal', 'fastdebug'):
1497 with Task('BootstrapWithSystemAssertions:fastdebug', tasks): 1508 with Task('BootstrapWithSystemAssertions:fastdebug', tasks) as t:
1498 vm(['-esa', '-XX:-TieredCompilation', '-version']) 1509 if t: vm(['-esa', '-XX:-TieredCompilation', '-version'])
1499 1510
1500 with VM('graal', 'fastdebug'): 1511 with VM('graal', 'fastdebug'):
1501 with Task('BootstrapEconomyWithSystemAssertions:fastdebug', tasks): 1512 with Task('BootstrapEconomyWithSystemAssertions:fastdebug', tasks) as t:
1502 vm(['-esa', '-XX:-TieredCompilation', '-G:CompilerConfiguration=economy', '-version']) 1513 if t: vm(['-esa', '-XX:-TieredCompilation', '-G:CompilerConfiguration=economy', '-version'])
1503 1514
1504 with VM('graal', 'fastdebug'): 1515 with VM('graal', 'fastdebug'):
1505 with Task('BootstrapWithSystemAssertionsNoCoop:fastdebug', tasks): 1516 with Task('BootstrapWithSystemAssertionsNoCoop:fastdebug', tasks) as t:
1506 vm(['-esa', '-XX:-TieredCompilation', '-XX:-UseCompressedOops', '-version']) 1517 if t: vm(['-esa', '-XX:-TieredCompilation', '-XX:-UseCompressedOops', '-version'])
1507 1518
1508 with VM('graal', 'product'): 1519 with VM('graal', 'product'):
1509 with Task('BootstrapWithGCVerification:product', tasks): 1520 with Task('BootstrapWithGCVerification:product', tasks) as t:
1510 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write 1521 if t:
1511 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) 1522 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write
1523 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out)
1512 1524
1513 with VM('graal', 'product'): 1525 with VM('graal', 'product'):
1514 with Task('BootstrapWithG1GCVerification:product', tasks): 1526 with Task('BootstrapWithG1GCVerification:product', tasks) as t:
1515 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write 1527 if t:
1516 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) 1528 out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write
1529 vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out)
1517 1530
1518 with VM('graal', 'product'): 1531 with VM('graal', 'product'):
1519 with Task('BootstrapWithRegisterPressure:product', tasks): 1532 with Task('BootstrapWithRegisterPressure:product', tasks) as t:
1520 vm(['-XX:-TieredCompilation', '-G:RegisterPressure=rbx,r11,r10,r14,xmm3,xmm11,xmm14', '-esa', '-version']) 1533 if t: vm(['-XX:-TieredCompilation', '-G:RegisterPressure=rbx,r11,r10,r14,xmm3,xmm11,xmm14', '-esa', '-version'])
1521 1534
1522 with VM('graal', 'product'): 1535 with VM('graal', 'product'):
1523 with Task('BootstrapWithImmutableCode:product', tasks): 1536 with Task('BootstrapWithImmutableCode:product', tasks) as t:
1524 vm(['-XX:-TieredCompilation', '-G:+ImmutableCode', '-G:+VerifyPhases', '-esa', '-version']) 1537 if t: vm(['-XX:-TieredCompilation', '-G:+ImmutableCode', '-G:+VerifyPhases', '-esa', '-version'])
1525 1538
1526 for vmbuild in ['fastdebug', 'product']: 1539 for vmbuild in ['fastdebug', 'product']:
1527 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild) + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild): 1540 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild) + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild):
1528 with Task(str(test) + ':' + vmbuild, tasks) as t: 1541 with Task(str(test) + ':' + vmbuild, tasks) as t:
1529 if not test.test('graal'): 1542 if t and not test.test('graal'):
1530 t.abort(test.name + ' Failed') 1543 t.abort(test.name + ' Failed')
1531 1544
1532 # ensure -Xbatch still works 1545 # ensure -Xbatch still works
1533 with VM('graal', 'product'): 1546 with VM('graal', 'product'):
1534 with Task('DaCapo_pmd:BatchMode:product', tasks): 1547 with Task('DaCapo_pmd:BatchMode:product', tasks) as t:
1535 dacapo(['-Xbatch', 'pmd']) 1548 if t: dacapo(['-Xbatch', 'pmd'])
1536 1549
1537 # ensure -Xcomp still works 1550 # ensure -Xcomp still works
1538 with VM('graal', 'product'): 1551 with VM('graal', 'product'):
1539 with Task('XCompMode:product', tasks): 1552 with Task('XCompMode:product', tasks) as t:
1540 vm(['-Xcomp', '-version']) 1553 if t: vm(['-Xcomp', '-version'])
1541 1554
1542 if args.jacocout is not None: 1555 if args.jacocout is not None:
1543 jacocoreport([args.jacocout]) 1556 jacocoreport([args.jacocout])
1544 1557
1545 global _jacoco 1558 global _jacoco
1546 _jacoco = 'off' 1559 _jacoco = 'off'
1547 1560
1548 with Task('CleanAndBuildIdealGraphVisualizer', tasks): 1561 with Task('CleanAndBuildIdealGraphVisualizer', tasks) as t:
1549 env = _igvFallbackJDK(os.environ) 1562 if t:
1550 buildxml = mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')) 1563 env = _igvFallbackJDK(os.environ)
1551 mx.run(['ant', '-f', buildxml, '-q', 'clean', 'build'], env=env) 1564 buildxml = mx._cygpathU2W(join(_graal_home, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml'))
1565 mx.run(['ant', '-f', buildxml, '-q', 'clean', 'build'], env=env)
1552 1566
1553 # Prevent Graal modifications from breaking the standard builds 1567 # Prevent Graal modifications from breaking the standard builds
1554 if args.buildNonGraal: 1568 if args.buildNonGraal:
1555 with Task('BuildHotSpotVarieties', tasks): 1569 with Task('BuildHotSpotVarieties', tasks) as t:
1556 buildvms(['--vms', 'client,server', '--builds', 'fastdebug,product']) 1570 if t:
1557 if mx.get_os() not in ['windows', 'cygwin']: 1571 buildvms(['--vms', 'client,server', '--builds', 'fastdebug,product'])
1558 buildvms(['--vms', 'server-nograal', '--builds', 'product,optimized']) 1572 if mx.get_os() not in ['windows', 'cygwin']:
1573 buildvms(['--vms', 'server-nograal', '--builds', 'product,optimized'])
1559 1574
1560 for vmbuild in ['product', 'fastdebug']: 1575 for vmbuild in ['product', 'fastdebug']:
1561 for theVm in ['client', 'server']: 1576 for theVm in ['client', 'server']:
1562 if not isVMSupported(theVm): 1577 if not isVMSupported(theVm):
1563 mx.log('The' + theVm + ' VM is not supported on this platform') 1578 mx.log('The' + theVm + ' VM is not supported on this platform')
1564 continue 1579 continue
1565 with VM(theVm, vmbuild): 1580 with VM(theVm, vmbuild):
1566 with Task('DaCapo_pmd:' + theVm + ':' + vmbuild, tasks): 1581 with Task('DaCapo_pmd:' + theVm + ':' + vmbuild, tasks) as t:
1567 dacapo(['pmd']) 1582 if t: dacapo(['pmd'])
1568 1583
1569 with Task('UnitTests:' + theVm + ':' + vmbuild, tasks): 1584 with Task('UnitTests:' + theVm + ':' + vmbuild, tasks) as t:
1570 unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api']) 1585 if t: unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api'])
1571 1586
1572 1587
1573 def gate(args, gate_body=_basic_gate_body): 1588 def gate(args, gate_body=_basic_gate_body):
1574 """run the tests used to validate a push 1589 """run the tests used to validate a push
1575 1590
1578 1593
1579 parser = ArgumentParser(prog='mx gate') 1594 parser = ArgumentParser(prog='mx gate')
1580 parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code') 1595 parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code')
1581 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code') 1596 parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code')
1582 parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM') 1597 parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM')
1598 parser.add_argument('-t', '--task-filter', help='comma separated list of substrings to select subset of tasks to be run')
1583 parser.add_argument('--jacocout', help='specify the output directory for jacoco report') 1599 parser.add_argument('--jacocout', help='specify the output directory for jacoco report')
1584 1600
1585 args = parser.parse_args(args) 1601 args = parser.parse_args(args)
1586 1602
1587 global _jacoco 1603 global _jacoco
1604 if args.task_filter:
1605 Task.filters = args.task_filter.split(',')
1588 1606
1589 tasks = [] 1607 tasks = []
1590 total = Task('Gate') 1608 total = Task('Gate')
1591 try: 1609 try:
1592 with Task('Pylint', tasks): 1610 with Task('Pylint', tasks) as t:
1593 mx.pylint([]) 1611 if t: mx.pylint([])
1594 1612
1595 def _clean(name='Clean'): 1613 def _clean(name='Clean'):
1596 with Task(name, tasks): 1614 with Task(name, tasks) as t:
1597 cleanArgs = [] 1615 if t:
1598 if not args.cleanNative: 1616 cleanArgs = []
1599 cleanArgs.append('--no-native') 1617 if not args.cleanNative:
1600 if not args.cleanJava: 1618 cleanArgs.append('--no-native')
1601 cleanArgs.append('--no-java') 1619 if not args.cleanJava:
1602 clean(cleanArgs) 1620 cleanArgs.append('--no-java')
1621 clean(cleanArgs)
1603 _clean() 1622 _clean()
1604 1623
1605 with Task('IDEConfigCheck', tasks): 1624 with Task('IDEConfigCheck', tasks):
1606 mx.ideclean([]) 1625 if t:
1607 mx.ideinit([]) 1626 mx.ideclean([])
1627 mx.ideinit([])
1608 1628
1609 eclipse_exe = mx.get_env('ECLIPSE_EXE') 1629 eclipse_exe = mx.get_env('ECLIPSE_EXE')
1610 if eclipse_exe is not None: 1630 if eclipse_exe is not None:
1611 with Task('CodeFormatCheck', tasks) as t: 1631 with Task('CodeFormatCheck', tasks) as t:
1612 if mx.eclipseformat(['-e', eclipse_exe]) != 0: 1632 if t and mx.eclipseformat(['-e', eclipse_exe]) != 0:
1613 t.abort('Formatter modified files - run "mx eclipseformat", check in changes and repush') 1633 t.abort('Formatter modified files - run "mx eclipseformat", check in changes and repush')
1614 1634
1615 with Task('Canonicalization Check', tasks) as t: 1635 with Task('Canonicalization Check', tasks) as t:
1616 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...')) 1636 if t:
1617 if mx.canonicalizeprojects([]) != 0: 1637 mx.log(time.strftime('%d %b %Y %H:%M:%S - Ensuring mx/projects files are canonicalized...'))
1618 t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.') 1638 if mx.canonicalizeprojects([]) != 0:
1639 t.abort('Rerun "mx canonicalizeprojects" and check-in the modified mx/projects files.')
1619 1640
1620 if mx.get_env('JDT'): 1641 if mx.get_env('JDT'):
1621 with Task('BuildJavaWithEcj', tasks): 1642 with Task('BuildJavaWithEcj', tasks):
1622 build(['-p', '--no-native', '--jdt-warning-as-error']) 1643 if t: build(['-p', '--no-native', '--jdt-warning-as-error'])
1623 _clean('CleanAfterEcjBuild') 1644 _clean('CleanAfterEcjBuild')
1624 1645
1625 with Task('BuildJavaWithJavac', tasks): 1646 with Task('BuildJavaWithJavac', tasks):
1626 build(['-p', '--no-native', '--force-javac']) 1647 if t: build(['-p', '--no-native', '--force-javac'])
1627 1648
1628 with Task('Checkstyle', tasks) as t: 1649 with Task('Checkstyle', tasks) as t:
1629 if mx.checkstyle([]) != 0: 1650 if t and mx.checkstyle([]) != 0:
1630 t.abort('Checkstyle warnings were found') 1651 t.abort('Checkstyle warnings were found')
1631 1652
1632 with Task('Checkheaders', tasks) as t: 1653 with Task('Checkheaders', tasks) as t:
1633 if checkheaders([]) != 0: 1654 if t and checkheaders([]) != 0:
1634 t.abort('Checkheaders warnings were found') 1655 t.abort('Checkheaders warnings were found')
1635 1656
1636 with Task('FindBugs', tasks) as t: 1657 with Task('FindBugs', tasks) as t:
1637 if findbugs([]) != 0: 1658 if t and findbugs([]) != 0:
1638 t.abort('FindBugs warnings were found') 1659 t.abort('FindBugs warnings were found')
1639 1660
1640 if exists('jacoco.exec'): 1661 if exists('jacoco.exec'):
1641 os.unlink('jacoco.exec') 1662 os.unlink('jacoco.exec')
1642 1663
1660 mx.log('Gate task times:') 1681 mx.log('Gate task times:')
1661 for t in tasks: 1682 for t in tasks:
1662 mx.log(' ' + str(t.duration) + '\t' + t.title) 1683 mx.log(' ' + str(t.duration) + '\t' + t.title)
1663 mx.log(' =======') 1684 mx.log(' =======')
1664 mx.log(' ' + str(total.duration)) 1685 mx.log(' ' + str(total.duration))
1686
1687 if args.task_filter:
1688 Task.filters = None
1665 1689
1666 def deoptalot(args): 1690 def deoptalot(args):
1667 """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on 1691 """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on
1668 1692
1669 If the first argument is a number, the process will be repeated 1693 If the first argument is a number, the process will be repeated