comparison mx.jvmci/mx_jvmci.py @ 22716:f536aaa5a5d5

Use mx.ensure_dir_exists rather than os.makedirs to avoid races
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Fri, 30 Oct 2015 12:28:17 +0100
parents 829a9e1ccf23
children 9860aa60385f
comparison
equal deleted inserted replaced
22715:3c0753fbb592 22716:f536aaa5a5d5
604 if exists(toDelete): 604 if exists(toDelete):
605 os.unlink(toDelete) 605 os.unlink(toDelete)
606 606
607 def copyToJdk(src, dst, permissions=JDK_UNIX_PERMISSIONS_FILE): 607 def copyToJdk(src, dst, permissions=JDK_UNIX_PERMISSIONS_FILE):
608 name = os.path.basename(src) 608 name = os.path.basename(src)
609 if not exists(dst): 609 mx.ensure_dir_exists(dst)
610 os.makedirs(dst)
611 dstLib = join(dst, name) 610 dstLib = join(dst, name)
612 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true': 611 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true':
613 # Using symlinks is much faster than copying but may 612 # Using symlinks is much faster than copying but may
614 # cause issues if the lib is being updated while 613 # cause issues if the lib is being updated while
615 # the VM is running. 614 # the VM is running.
625 shutil.move(tmp, dstLib) 624 shutil.move(tmp, dstLib)
626 os.chmod(dstLib, permissions) 625 os.chmod(dstLib, permissions)
627 626
628 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, obsoleteCheck): 627 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, obsoleteCheck):
629 628
630 oldServices = os.listdir(servicesDir) if exists(servicesDir) else os.makedirs(servicesDir) 629 oldServices = os.listdir(servicesDir) if exists(servicesDir) else mx.ensure_dir_exists(servicesDir)
631 630
632 jvmciServices = {} 631 jvmciServices = {}
633 for jar in jvmciJars: 632 for jar in jvmciJars:
634 if os.path.isfile(jar): 633 if os.path.isfile(jar):
635 with zipfile.ZipFile(jar) as zf: 634 with zipfile.ZipFile(jar) as zf:
1487 vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs 1486 vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs
1488 1487
1489 benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')] 1488 benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')]
1490 jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')] 1489 jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')]
1491 jmhOutDir = join(_suite.mxDir, 'jmh') 1490 jmhOutDir = join(_suite.mxDir, 'jmh')
1492 if not exists(jmhOutDir): 1491 mx.ensure_dir_exists(jmhOutDir)
1493 os.makedirs(jmhOutDir)
1494 jmhOut = join(jmhOutDir, 'jmh.out') 1492 jmhOut = join(jmhOutDir, 'jmh.out')
1495 jmhArgs = {'-rff' : jmhOut, '-v' : 'EXTRA' if mx._opts.verbose else 'NORMAL'} 1493 jmhArgs = {'-rff' : jmhOut, '-v' : 'EXTRA' if mx._opts.verbose else 'NORMAL'}
1496 1494
1497 # e.g. '{"-wi" : 20}' 1495 # e.g. '{"-wi" : 20}'
1498 for j in jmhArgJsons: 1496 for j in jmhArgJsons: