comparison mx/mx_graal.py @ 15870:fe608a56e3f7

made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
author Doug Simon <doug.simon@oracle.com>
date Fri, 23 May 2014 19:36:34 +0200
parents 283c8d31c560
children 6dcf8ab4ad86
comparison
equal deleted inserted replaced
15869:387b15da0f68 15870:fe608a56e3f7
152 152
153 if opts.native: 153 if opts.native:
154 def handleRemoveReadonly(func, path, exc): 154 def handleRemoveReadonly(func, path, exc):
155 excvalue = exc[1] 155 excvalue = exc[1]
156 if mx.get_os() == 'windows' and func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES: 156 if mx.get_os() == 'windows' and func in (os.rmdir, os.remove) and excvalue.errno == errno.EACCES:
157 os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777 157 os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777
158 func(path) 158 func(path)
159 else: 159 else:
160 raise 160 raise
161 161
162 def rmIfExists(name): 162 def rmIfExists(name):
210 210
211 211
212 def _genFileName(archivtype, middle): 212 def _genFileName(archivtype, middle):
213 idPrefix = infos['revision'] + '_' 213 idPrefix = infos['revision'] + '_'
214 idSuffix = '.tar.gz' 214 idSuffix = '.tar.gz'
215 return join(_graal_home, "graalvm_" + archivtype + "_" + idPrefix + middle + idSuffix) 215 return join(_graal_home, "graalvm_" + archivtype + "_" + idPrefix + middle + idSuffix)
216 216
217 def _genFileArchPlatformName(archivtype, middle): 217 def _genFileArchPlatformName(archivtype, middle):
218 return _genFileName(archivtype, infos['platform'] + '_' + infos['architecture'] + '_' + middle) 218 return _genFileName(archivtype, infos['platform'] + '_' + infos['architecture'] + '_' + middle)
219 219
220 220
482 else: 482 else:
483 toDelete = join(jreLibDir, 'graal.options') 483 toDelete = join(jreLibDir, 'graal.options')
484 if exists(toDelete): 484 if exists(toDelete):
485 os.unlink(toDelete) 485 os.unlink(toDelete)
486 486
487 def _update_HotSpotOptions_inline_hpp(graalJar):
488 p = mx.project('com.oracle.graal.hotspot')
489 mainClass = 'com.oracle.graal.hotspot.HotSpotOptionsLoader'
490 assert exists(join(p.source_dirs()[0], mainClass.replace('.', os.sep) + '.java'))
491 hsSrcGenDir = join(p.source_gen_dir(), 'hotspot')
492 if not exists(hsSrcGenDir):
493 os.makedirs(hsSrcGenDir)
494 path = join(hsSrcGenDir, 'HotSpotOptions.inline.hpp')
495 fd, tmp = tempfile.mkstemp(suffix='', prefix='HotSpotOptions.inline.hpp', dir=hsSrcGenDir)
496 os.close(fd)
497 try:
498 retcode = mx.run_java(['-cp', graalJar, mainClass, tmp], nonZeroIsFatal=False)
499 if retcode != 0:
500 # Suppress the error if it's because the utility class isn't compiled yet
501 with zipfile.ZipFile(graalJar, 'r') as zf:
502 mainClassFile = mainClass.replace('.', '/') + '.class'
503 if mainClassFile not in zf.namelist():
504 return
505 mx.abort(retcode)
506 with open(tmp) as fp:
507 content = fp.read()
508 mx.update_file(path, content)
509 finally:
510 os.remove(tmp)
511
487 def _installGraalJarInJdks(graalDist): 512 def _installGraalJarInJdks(graalDist):
488 graalJar = graalDist.path 513 graalJar = graalDist.path
514 _update_HotSpotOptions_inline_hpp(graalJar)
489 jdks = _jdksDir() 515 jdks = _jdksDir()
490 516
491 if exists(jdks): 517 if exists(jdks):
492 for e in os.listdir(jdks): 518 for e in os.listdir(jdks):
493 jreLibDir = join(jdks, e, 'jre', 'lib') 519 jreLibDir = join(jdks, e, 'jre', 'lib')