comparison mx/mx_graal.py @ 16395:ad431bf0de07

added support to load classes from graal.jar with a separate class loader
author Doug Simon <doug.simon@oracle.com>
date Thu, 03 Jul 2014 16:30:28 +0200
parents 0dd27c6472d7
children 9fe3cb463079
comparison
equal deleted inserted replaced
16394:0dd27c6472d7 16395:ad431bf0de07
457 mx.log("The selected JDK directory does not (yet) exist: " + jdk) 457 mx.log("The selected JDK directory does not (yet) exist: " + jdk)
458 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') 458 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal')
459 459
460 if installGraalJar: 460 if installGraalJar:
461 _installGraalJarInJdks(mx.distribution('GRAAL')) 461 _installGraalJarInJdks(mx.distribution('GRAAL'))
462 _installGraalJarInJdks(mx.distribution('GRAAL_LOADER'))
462 463
463 if vmToCheck is not None: 464 if vmToCheck is not None:
464 jvmCfg = _vmCfgInJdk(jdk) 465 jvmCfg = _vmCfgInJdk(jdk)
465 found = False 466 found = False
466 with open(jvmCfg) as f: 467 with open(jvmCfg) as f:
495 mx.run_java(['-cp', '{}{}{}'.format(graalJar, os.pathsep, p.output_dir()), mainClass], out=tmp.write) 496 mx.run_java(['-cp', '{}{}{}'.format(graalJar, os.pathsep, p.output_dir()), mainClass], out=tmp.write)
496 mx.update_file(join(hsSrcGenDir, 'graalRuntime.inline.hpp'), tmp.getvalue()) 497 mx.update_file(join(hsSrcGenDir, 'graalRuntime.inline.hpp'), tmp.getvalue())
497 498
498 def _installGraalJarInJdks(graalDist): 499 def _installGraalJarInJdks(graalDist):
499 graalJar = graalDist.path 500 graalJar = graalDist.path
500 _update_graalRuntime_inline_hpp(graalJar) 501 if graalJar.endswith('graal.jar'):
502 _update_graalRuntime_inline_hpp(graalJar)
501 jdks = _jdksDir() 503 jdks = _jdksDir()
502 504
503 if exists(jdks): 505 if exists(jdks):
504 for e in os.listdir(jdks): 506 for e in os.listdir(jdks):
505 jreLibDir = join(jdks, e, 'jre', 'lib') 507 jreLibDir = join(jdks, e, 'jre', 'lib')
647 os.makedirs(opts2.export_dir) 649 os.makedirs(opts2.export_dir)
648 else: 650 else:
649 assert os.path.isdir(opts2.export_dir), '{} is not a directory'.format(opts2.export_dir) 651 assert os.path.isdir(opts2.export_dir), '{} is not a directory'.format(opts2.export_dir)
650 652
651 shutil.copy(mx.distribution('GRAAL').path, opts2.export_dir) 653 shutil.copy(mx.distribution('GRAAL').path, opts2.export_dir)
654 shutil.copy(mx.distribution('GRAAL_LOADER').path, opts2.export_dir)
652 graalOptions = join(_graal_home, 'graal.options') 655 graalOptions = join(_graal_home, 'graal.options')
653 if exists(graalOptions): 656 if exists(graalOptions):
654 shutil.copy(graalOptions, opts2.export_dir) 657 shutil.copy(graalOptions, opts2.export_dir)
655 658
656 if not _vmSourcesAvailable or not opts2.native: 659 if not _vmSourcesAvailable or not opts2.native:
1048 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea'] 1051 prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea']
1049 if gc_after_test: 1052 if gc_after_test:
1050 prefixArgs.append('-XX:-DisableExplicitGC') 1053 prefixArgs.append('-XX:-DisableExplicitGC')
1051 with open(testfile) as fp: 1054 with open(testfile) as fp:
1052 testclasses = [l.rstrip() for l in fp.readlines()] 1055 testclasses = [l.rstrip() for l in fp.readlines()]
1053 1056
1054 # Remove entries from class path that are in graal.jar 1057 # Remove entries from class path that are in graal.jar and
1058 # run the VM in a mode where application/test classes can
1059 # access core Graal classes.
1055 cp = prefixCp + coreCp + os.pathsep + projectsCp 1060 cp = prefixCp + coreCp + os.pathsep + projectsCp
1056 if isGraalEnabled(_get_vm()): 1061 if isGraalEnabled(_get_vm()):
1057 graalDist = mx.distribution('GRAAL') 1062 graalDist = mx.distribution('GRAAL')
1058 graalJarCp = set([d.output_dir() for d in graalDist.sorted_deps()]) 1063 graalJarCp = set([d.output_dir() for d in graalDist.sorted_deps()])
1059 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in graalJarCp]) 1064 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in graalJarCp])
1060 1065 vmArgs = vmArgs + ['-XX:-UseGraalClassLoader']
1066
1061 if len(testclasses) == 1: 1067 if len(testclasses) == 1:
1062 # Execute Junit directly when one test is being run. This simplifies 1068 # Execute Junit directly when one test is being run. This simplifies
1063 # replaying the VM execution in a native debugger (e.g., gdb). 1069 # replaying the VM execution in a native debugger (e.g., gdb).
1064 vm(prefixArgs + vmArgs + ['-cp', cp, 'com.oracle.graal.test.GraalJUnitCore'] + coreArgs + testclasses) 1070 vm(prefixArgs + vmArgs + ['-cp', cp, 'com.oracle.graal.test.GraalJUnitCore'] + coreArgs + testclasses)
1065 else: 1071 else:
2183 _installed_jdks = opts.installed_jdks 2189 _installed_jdks = opts.installed_jdks
2184 global _vm_prefix 2190 global _vm_prefix
2185 _vm_prefix = opts.vm_prefix 2191 _vm_prefix = opts.vm_prefix
2186 2192
2187 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) 2193 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks)
2194 mx.distribution('GRAAL_LOADER').add_update_listener(_installGraalJarInJdks)