comparison mx/mx_graal.py @ 21560:a9fba0dfb155

added lower runtime overhead mechanism for setting "graal.version" system property
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 May 2015 16:39:41 +0200
parents be896a1983c0
children 47bebae7454f
comparison
equal deleted inserted replaced
21559:be896a1983c0 21560:a9fba0dfb155
705 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci') 705 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci')
706 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if (e.startswith('jvmci') or e.startswith('graal')) and e.endswith('.jar')] 706 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if (e.startswith('jvmci') or e.startswith('graal')) and e.endswith('.jar')]
707 jreJVMCIServicesDir = join(jreJVMCIDir, 'services') 707 jreJVMCIServicesDir = join(jreJVMCIDir, 'services')
708 _extractJVMCIServiceFiles(jvmciJars, jreJVMCIServicesDir) 708 _extractJVMCIServiceFiles(jvmciJars, jreJVMCIServicesDir)
709 709
710 710 def _patchGraalVersionConstant(dist):
711 """
712 Patches the constant "@@graal.version@@" in the constant pool of Graal.class
713 with the computed Graal version string.
714 """
715 zfOutFd, zfOutPath = tempfile.mkstemp(suffix='', prefix=basename(dist.path) + '.', dir=dirname(dist.path))
716 zfOut = zipfile.ZipFile(zfOutPath, 'w')
717 zf = zipfile.ZipFile(dist.path, 'r')
718 for zi in zf.infolist():
719 data = zf.read(zi)
720 if zi.filename == 'com/oracle/graal/api/runtime/Graal.class':
721 versionSpec = '{:' + str(len('@@graal.version@@')) + '}'
722 versionStr = versionSpec.format(graal_version())
723 assert '@@graal.version@@' in data, 'could not find "@@graal.version@@" constant in ' + dist.path + '!' + zi.filename
724 data = data.replace('@@graal.version@@', versionStr)
725 zfOut.writestr(zi, data)
726 zfOut.close()
727 os.close(zfOutFd)
728 zf.close()
729 shutil.move(zfOutPath, dist.path)
711 730
712 def _installDistInJdks(deployableDist): 731 def _installDistInJdks(deployableDist):
713 """ 732 """
714 Installs the jar(s) for a given Distribution into all existing JVMCI JDKs 733 Installs the jar(s) for a given Distribution into all existing JVMCI JDKs
715 """ 734 """
716 735
717 dist = mx.distribution(deployableDist.name) 736 dist = mx.distribution(deployableDist.name)
718 737
719 if dist.name == 'GRAAL': 738 if dist.name == 'GRAAL':
720 zf = zipfile.ZipFile(dist.path, 'a') 739 _patchGraalVersionConstant(dist)
721 zf.writestr('com/oracle/graal/api/runtime/graal.version', graal_version()) 740
722 zf.close()
723 elif dist.name == 'GRAAL_TRUFFLE': 741 elif dist.name == 'GRAAL_TRUFFLE':
724 # The content in graalRuntime.inline.hpp is generated from Graal 742 # The content in graalRuntime.inline.hpp is generated from Graal
725 # classes that contain com.oracle.jvmci.options.Option annotated fields. 743 # classes that contain com.oracle.jvmci.options.Option annotated fields.
726 # Since GRAAL_TRUFFLE is the leaf most distribution containing 744 # Since GRAAL_TRUFFLE is the leaf most distribution containing
727 # such classes, the generation is triggered when GRAAL_TRUFFLE 745 # such classes, the generation is triggered when GRAAL_TRUFFLE