OpenJDK / graal / graal-jvmci-8
changeset 8137:ae629e3671a0
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 06 Mar 2013 21:59:06 +0100 |
parents | c66aa27ef4da 8d10fc6b4f6c |
children | 1446b04e4148 |
files | |
diffstat | 7 files changed, 154 insertions(+), 229 deletions(-) [+] |
line wrap: on
line diff
--- a/mx/commands.py Wed Mar 06 21:58:58 2013 +0100 +++ b/mx/commands.py Wed Mar 06 21:59:06 2013 +0100 @@ -373,8 +373,20 @@ else: if not exists(jdk): mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx build ' + build + '\'') + + _installGraalJarInJdks(mx.distribution('GRAAL')) + return jdk +def _installGraalJarInJdks(graalDist): + graalJar = graalDist.path + jdks = join(_graal_home, 'jdk' + str(mx.java().version)) + if exists(jdks): + for e in os.listdir(jdks): + jreLibDir = join(jdks, e, 'jre', 'lib') + if exists(jreLibDir): + shutil.copyfile(graalJar, join(jreLibDir, 'graal.jar')) + # run a command in the windows SDK Debug Shell def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo={}): newLine = os.linesep @@ -488,25 +500,6 @@ if not 'Xusage.txt' in line: sys.stderr.write(line + os.linesep) - # Check that the declaration of graal_projects in arguments.cpp is up to date - argumentsCpp = join(_graal_home, 'src', 'share', 'vm', 'runtime', 'arguments.cpp') - assert exists(argumentsCpp), 'File does not exist: ' + argumentsCpp - with open(argumentsCpp) as fp: - source = fp.read(); - decl = 'const char* graal_projects[] = {' - start = source.find(decl) - assert start != -1, 'Could not find "' + decl + '" in ' + fp.name - end = source.find('};', start) - assert end != -1, 'Could not find "' + decl + '" ... "};" in ' + fp.name - actual = frozenset(re.findall(r'"([^"]+)"', source[start + len(decl):end])) - expected = frozenset([p.name for p in mx.project('com.oracle.graal.hotspot.' + _arch()).all_deps([], False)]) - missing = expected - actual - extra = actual - expected - if len(missing) != 0: - mx.abort(fp.name + ':' + str(source[:start].count('\n') + 1) + ': add missing project(s) to declaration:\n ' + '\n '.join(missing)) - if len(extra) != 0: - mx.abort(fp.name + ':' + str(source[:start].count('\n') + 1) + ': remove project(s) from declaration:\n ' + '\n '.join(extra)) - # Check if a build really needs to be done timestampFile = join(vmDir, '.build-timestamp') if opts2.force or not exists(timestampFile): @@ -656,6 +649,7 @@ args = ['-javaagent:' + jacocoagent.get_path(True) + '=' + ','.join([k + '=' + v for k, v in agentOptions.items()])] + args if '-d64' not in args: args = ['-d64'] + args + exe = join(jdk, 'bin', mx.exe_suffix('java')) dbg = _native_dbg.split() if _native_dbg is not None else [] return mx.run(dbg + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) @@ -1173,3 +1167,5 @@ _jacoco = opts.jacoco global _native_dbg _native_dbg = opts.native_dbg + + mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks)
--- a/mx/projects Wed Mar 06 21:58:58 2013 +0100 +++ b/mx/projects Wed Mar 06 21:59:06 2013 +0100 @@ -22,6 +22,9 @@ library@DACAPO_SCALA@path=lib/dacapo-scala-0.1.0-20120216.jar library@DACAPO_SCALA@urls=http://repo.scalabench.org/snapshots/org/scalabench/benchmarks/scala-benchmark-suite/0.1.0-SNAPSHOT/scala-benchmark-suite-0.1.0-20120216.103539-3.jar +distribution@GRAAL@path=graal.jar +distribution@GRAAL@dependencies=com.oracle.graal.hotspot.amd64,com.oracle.graal.hotspot.sparc + # graal.api.runtime project@com.oracle.graal.api.runtime@subDir=graal project@com.oracle.graal.api.runtime@sourceDirs=src
--- a/mxtool/mx.py Wed Mar 06 21:58:58 2013 +0100 +++ b/mxtool/mx.py Wed Mar 06 21:59:06 2013 +0100 @@ -143,12 +143,36 @@ _projects = dict() _libs = dict() +_dists = dict() _suites = dict() _mainSuite = None _opts = None _java = None """ +A distribution is a jar or zip file containing the output from one or more Java projects. +""" +class Distribution: + def __init__(self, suite, name, path, deps): + self.suite = suite + self.name = name + self.path = path.replace('/', os.sep) + if not isabs(self.path): + self.path = join(suite.dir, self.path) + self.deps = deps + self.update_listeners = set() + + def __str__(self): + return self.name + + def add_update_listener(self, listener): + self.update_listeners.add(listener) + + def notify_updated(self): + for l in self.update_listeners: + l(self) + +""" A dependency is a library or project specified in a suite. """ class Dependency: @@ -416,6 +440,7 @@ self.dir = d self.projects = [] self.libs = [] + self.dists = [] self.includes = [] self.commands = None self.primary = primary @@ -427,6 +452,7 @@ def _load_projects(self, mxDir): libsMap = dict() projsMap = dict() + distsMap = dict() projectsFile = join(mxDir, 'projects') if not exists(projectsFile): return @@ -447,8 +473,10 @@ m = projsMap elif kind == 'library': m = libsMap + elif kind == 'distribution': + m = distsMap else: - abort('Property name does not start with "project@" or "library@": ' + key) + abort('Property name does not start with "project@", "library@" or "distribution@": ' + key) attrs = m.get(name) if attrs is None: @@ -494,6 +522,13 @@ l.__dict__.update(attrs) self.libs.append(l) + for name, attrs in distsMap.iteritems(): + path = attrs.pop('path') + deps = pop_list(attrs, 'dependencies') + d = Distribution(self, name, path, deps) + d.__dict__.update(attrs) + self.dists.append(d) + def _load_commands(self, mxDir): commands = join(mxDir, 'commands.py') if exists(commands): @@ -536,8 +571,6 @@ def _post_init(self, opts): mxDir = join(self.dir, 'mx') self._load_projects(mxDir) - if hasattr(self, 'mx_post_parse_cmd_line'): - self.mx_post_parse_cmd_line(opts) for p in self.projects: existing = _projects.get(p.name) if existing is not None: @@ -549,6 +582,13 @@ if existing is not None: abort('cannot redefine library ' + l.name) _libs[l.name] = l + for d in self.dists: + existing = _dists.get(l.name) + if existing is not None: + abort('cannot redefine distribution ' + d.name) + _dists[d.name] = d + if hasattr(self, 'mx_post_parse_cmd_line'): + self.mx_post_parse_cmd_line(opts) class XMLElement(xml.dom.minidom.Element): def writexml(self, writer, indent="", addindent="", newl=""): @@ -653,6 +693,16 @@ """ return _projects.values() +def distribution(name, fatalIfMissing=True): + """ + Get the distribution for a given name. This will abort if the named distribution does + not exist and 'fatalIfMissing' is true. + """ + d = _dists.get(name) + if d is None and fatalIfMissing: + abort('distribution named ' + name + ' not found') + return d + def project(name, fatalIfMissing=True): """ Get the project for a given name. This will abort if the named project does @@ -1477,6 +1527,9 @@ finally: for n in toBeDeleted: os.remove(n) + + for dist in _dists.values(): + archive(['@' + dist.name]) if suppliedParser: return args @@ -1578,7 +1631,7 @@ projects = set() for p in sorted_deps(): - if _needsEclipseJarBuild(p): + if _isAnnotationProcessorDependency(p): projects.add(p) if len(projects) <= 0: @@ -1586,37 +1639,40 @@ pnames = [p.name for p in projects] build(['--projects', ",".join(pnames)]) - jarprojects(pnames) - -def jarprojects(args): - """create jar files for the output of one or more projects""" - parser = ArgumentParser(prog='mx jar'); - parser.add_argument('-d', '--dest', help='single jar file to create') - parser.add_argument('projects', nargs=REMAINDER, metavar='projects...') + archive(pnames) + +def archive(args): + """create jar files for projects and distributions""" + parser = ArgumentParser(prog='mx archive'); + parser.add_argument('names', nargs=REMAINDER, metavar='[<project>|@<distribution>]...') args = parser.parse_args(args) - if not args.projects: - args.projects = [p.name for p in projects()] - - if args.dest is not None: - zf = zipfile.ZipFile(args.dest, 'w') - - for pname in args.projects: - p = project(pname, fatalIfMissing=True) - if args.dest is None: + for name in args.names: + if name.startswith('@'): + dname = name[1:] + d = distribution(dname) + zf = zipfile.ZipFile(d.path, 'w') + for p in sorted_deps(d.deps): + outputDir = p.output_dir() + for root, _, files in os.walk(outputDir): + for f in files: + relpath = root[len(outputDir) + 1:] + arcname = join(relpath, f).replace(os.sep, '/') + zf.write(join(root, f), arcname) + zf.close() + d.notify_updated() + + else: + p = project(name) + outputDir = p.output_dir() jar = join(p.dir, p.name + '.jar') zf = zipfile.ZipFile(jar, 'w') - outputDir = p.output_dir() - for root, _, files in os.walk(outputDir): - for f in files: - relpath = root[len(outputDir) + 1:] - arcname = join(relpath, f).replace(os.sep, '/') - zf.write(join(root, f), arcname) - if args.dest is None: + for root, _, files in os.walk(outputDir): + for f in files: + relpath = root[len(outputDir) + 1:] + arcname = join(relpath, f).replace(os.sep, '/') + zf.write(join(root, f), arcname) zf.close() - - if args.dest is not None: - zf.close() def canonicalizeprojects(args): """process all project files to canonicalize the dependencies @@ -1996,6 +2052,12 @@ if buildProcessorJars: processorjars() + projToDist = dict() + for dist in _dists.values(): + distDeps = sorted_deps(dist.deps) + for p in distDeps: + projToDist[p.name] = (dist, [dep.name for dep in distDeps]) + for p in projects(): if p.native: continue @@ -2110,24 +2172,14 @@ out.element('arguments', data='') out.close('buildCommand') - if (_needsEclipseJarBuild(p)): - targetValues = _genEclipseJarBuild(p); - for value in targetValues: - out.open('buildCommand') - out.element('name', data='org.eclipse.ui.externaltools.ExternalToolBuilder') - out.element('triggers', data='auto,full,incremental,') - out.open('arguments') - out.open('dictionary') - out.element('key', data = 'LaunchConfigHandle') - out.element('value', data = value) - out.close('dictionary') - out.open('dictionary') - out.element('key', data = 'incclean') - out.element('value', data = 'true') - out.close('dictionary') - out.close('arguments') - out.close('buildCommand') - + if _isAnnotationProcessorDependency(p): + _genEclipseBuilder(out, p, 'Jar.launch', 'archive ' + p.name, refresh = False, async = False) + _genEclipseBuilder(out, p, 'Refresh.launch', '', refresh = True, async = True) + + if projToDist.has_key(p.name): + dist, distDeps = projToDist[p.name] + _genEclipseBuilder(out, p, 'Create' + dist.name + 'Dist.launch', 'archive @' + dist.name, refresh=False, async=True) + out.close('buildSpec') out.open('natures') out.element('nature', data='org.eclipse.jdt.core.javanature') @@ -2182,8 +2234,11 @@ make_eclipse_attach('localhost', '8000', deps=projects()) -def _needsEclipseJarBuild(p): - processors = set([]) +def _isAnnotationProcessorDependency(p): + """ + Determines if a given project is part of an annotation processor. + """ + processors = set() for otherProject in projects(): if hasattr(otherProject, 'annotationProcessors') and len(otherProject.annotationProcessors) > 0: @@ -2200,13 +2255,7 @@ return False -def _genEclipseJarBuild(p): - builders = [] - builders.append(_genEclipseLaunch(p, 'Jar.launch', ''.join(['jarprojects ', p.name]), refresh = False, async = False)) - builders.append(_genEclipseLaunch(p, 'Refresh.launch', '', refresh = True, async = True)) - return builders - -def _genEclipseLaunch(p, name, mxCommand, refresh=True, async=False): +def _genEclipseBuilder(dotProjectDoc, p, name, mxCommand, refresh=True, async=False): launchOut = XMLDoc(); launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) if refresh: @@ -2236,9 +2285,21 @@ os.makedirs(externalToolDir) update_file(join(externalToolDir, name), launchOut.xml(indent='\t', newl='\n')) - return ''.join(["<project>/.externalToolBuilders/", name]) - - + dotProjectDoc.open('buildCommand') + dotProjectDoc.element('name', data='org.eclipse.ui.externaltools.ExternalToolBuilder') + dotProjectDoc.element('triggers', data='auto,full,incremental,') + dotProjectDoc.open('arguments') + dotProjectDoc.open('dictionary') + dotProjectDoc.element('key', data = 'LaunchConfigHandle') + dotProjectDoc.element('value', data = '<project>/.externalToolBuilders/' + name) + dotProjectDoc.close('dictionary') + dotProjectDoc.open('dictionary') + dotProjectDoc.element('key', data = 'incclean') + dotProjectDoc.element('value', data = 'true') + dotProjectDoc.close('dictionary') + dotProjectDoc.close('arguments') + dotProjectDoc.close('buildCommand') + def netbeansinit(args, suite=None): """(re)generate NetBeans project configurations""" @@ -2956,7 +3017,7 @@ 'help': [help_, '[command]'], 'ideclean': [ideclean, ''], 'ideinit': [ideinit, ''], - 'jarprojects': [jarprojects, '[options]'], + 'archive': [archive, '[options]'], 'projectgraph': [projectgraph, ''], 'javap': [javap, ''], 'javadoc': [javadoc, '[options]'],
--- a/src/share/vm/classfile/classLoader.cpp Wed Mar 06 21:58:58 2013 +0100 +++ b/src/share/vm/classfile/classLoader.cpp Wed Mar 06 21:59:06 2013 +0100 @@ -442,20 +442,11 @@ void ClassLoader::setup_bootstrap_search_path() { assert(_first_entry == NULL, "should not setup bootstrap class search path twice"); char* sys_class_path = os::strdup(Arguments::get_sysclasspath()); -#ifdef GRAAL - char* compiler_class_path = os::strdup(Arguments::get_compilerclasspath()); -#endif if (TraceClassLoading && Verbose) { tty->print_cr("[Bootstrap loader class path=%s]", sys_class_path); -#ifdef GRAAL - tty->print_cr("[Compiler loader class path=%s]", compiler_class_path); -#endif } setup_bootstrap_search_path(sys_class_path); -#ifdef GRAAL - setup_bootstrap_search_path(compiler_class_path); -#endif } void ClassLoader::setup_bootstrap_search_path(char* sys_class_path) {
--- a/src/share/vm/graal/graalGlobals.hpp Wed Mar 06 21:58:58 2013 +0100 +++ b/src/share/vm/graal/graalGlobals.hpp Wed Mar 06 21:59:06 2013 +0100 @@ -52,9 +52,6 @@ product(bool, BootstrapGraal, GRAALVM_ONLY(true) NOT_GRAALVM(false), \ "Bootstrap Graal before running Java main method") \ \ - product(ccstr, GraalClassPath, NULL, \ - "Use this path, zip, or jar, to locate Graal-specific classes") \ - \ product(intx, TraceGraal, 0, \ "Trace level for Graal") \ \
--- a/src/share/vm/runtime/arguments.cpp Wed Mar 06 21:58:58 2013 +0100 +++ b/src/share/vm/runtime/arguments.cpp Wed Mar 06 21:59:06 2013 +0100 @@ -105,9 +105,6 @@ SystemProperty *Arguments::_java_home = NULL; SystemProperty *Arguments::_java_class_path = NULL; SystemProperty *Arguments::_sun_boot_class_path = NULL; -#ifdef GRAAL -SystemProperty *Arguments::_compiler_class_path = NULL; -#endif char* Arguments::_meta_index_path = NULL; char* Arguments::_meta_index_dir = NULL; @@ -169,9 +166,6 @@ _java_library_path = new SystemProperty("java.library.path", NULL, true); _java_home = new SystemProperty("java.home", NULL, true); _sun_boot_class_path = new SystemProperty("sun.boot.class.path", NULL, true); -#ifdef GRAAL - _compiler_class_path = new SystemProperty("compiler.class.path", NULL, true); -#endif _java_class_path = new SystemProperty("java.class.path", "", true); @@ -183,9 +177,6 @@ PropertyList_add(&_system_properties, _java_home); PropertyList_add(&_system_properties, _java_class_path); PropertyList_add(&_system_properties, _sun_boot_class_path); -#ifdef GRAAL - PropertyList_add(&_system_properties, _compiler_class_path); -#endif // Set OS specific system properties values os::init_system_properties_values(); @@ -2189,59 +2180,6 @@ } // Parse JavaVMInitArgs structure -#ifdef GRAAL -static void prepend_to_graal_classpath(SysClassPath &cp, const char* path) { - cp.add_prefix(path); -} - -static void prepend_to_graal_classpath(SysClassPath &cp, const char* graal_dir, const char* project) { - const int BUFFER_SIZE = 1024; - char path[BUFFER_SIZE]; - - const char fileSep = *os::file_separator(); - sprintf(path, "%s%c%s%cbin", graal_dir, fileSep, project, fileSep); - - DIR* dir = os::opendir(path); - if (dir == NULL) { - jio_fprintf(defaultStream::output_stream(), "Error while starting Graal VM: The Graal class directory %s could not be opened.\n", path); - vm_exit(1); - } - os::closedir(dir); - prepend_to_graal_classpath(cp, path); -} - -// Walk up the directory hierarchy starting from JAVA_HOME looking -// for a directory named "graal". If found, then the full path to -// this directory is returned in graal_dir. -static bool find_graal_dir(char* graal_dir) { - strcpy(graal_dir, Arguments::get_java_home()); - char* end = graal_dir + strlen(graal_dir); - const char fileSep = *os::file_separator(); - while (end != graal_dir) { - if (fileSep == '/') - strcat(graal_dir, "/graal"); - else { - assert(fileSep == '\\', "unexpected separator char"); - strcat(graal_dir, "\\graal"); - } - DIR* dir = os::opendir(graal_dir); - if (dir != NULL) { - os::closedir(dir); - return true; - } - *end = 0; - while (end != graal_dir) { - if (*end == fileSep) { - *end = 0; - break; - } - end--; - } - } - return false; -} -#endif - jint Arguments::parse_vm_init_args(const JavaVMInitArgs* args) { // For components of the system classpath. SysClassPath scp(Arguments::get_sysclasspath()); @@ -2268,72 +2206,6 @@ return result; } -#ifdef GRAAL - if (PrintVMOptions) { - tty->print_cr("Running Graal VM... "); - } - - SysClassPath scp_compiler(""); - - if (GraalClassPath != NULL) { - prepend_to_graal_classpath(scp_compiler, GraalClassPath); - } else { - const int BUFFER_SIZE = 1024; - char graal_dir[BUFFER_SIZE]; - if (!os::getenv("GRAAL", graal_dir, sizeof(graal_dir))) { - if (find_graal_dir(graal_dir) == false) { - jio_fprintf(defaultStream::output_stream(), "Error while starting Graal VM: The GRAAL environment variable needs to point to the directory containing the Graal projects.\n"); - vm_exit(0); - } - } - if (PrintVMOptions) tty->print_cr("GRAAL=%s", graal_dir); - - // this declaration is checked for correctness by 'mx build' - only - // modify its entries, not its name or shape - const char* graal_projects[] = { - #ifdef AMD64 - "com.oracle.graal.amd64", - "com.oracle.graal.asm.amd64", - "com.oracle.graal.lir.amd64", - "com.oracle.graal.compiler.amd64", - "com.oracle.graal.hotspot.amd64", - #endif - "com.oracle.graal.api.runtime", - "com.oracle.graal.api.meta", - "com.oracle.graal.api.code", - "com.oracle.graal.hotspot", - "com.oracle.graal.asm", - "com.oracle.graal.alloc", - "com.oracle.graal.word", - "com.oracle.graal.snippets", - "com.oracle.graal.compiler", - "com.oracle.graal.loop", - "com.oracle.graal.phases", - "com.oracle.graal.phases.common", - "com.oracle.graal.virtual", - "com.oracle.graal.nodes", - "com.oracle.graal.printer", - "com.oracle.graal.debug", - "com.oracle.graal.graph", - "com.oracle.graal.lir", - "com.oracle.graal.bytecode", - "com.oracle.graal.java" - }; - - const int len = sizeof(graal_projects) / sizeof(char*); - for (int i = 0; i < len; i++) { - if (PrintVMOptions) { - tty->print_cr("Adding project directory %s to bootclasspath", graal_projects[i]); - } - prepend_to_graal_classpath(scp_compiler, graal_dir, graal_projects[i]); - } - } - - scp_compiler.expand_endorsed(); - Arguments::set_compilerclasspath(scp_compiler.combined_path()); - -#endif - if (AggressiveOpts) { // Insert alt-rt.jar between user-specified bootclasspath // prefix and the default bootclasspath. os::set_boot_path() @@ -2349,6 +2221,20 @@ FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal); } +#ifdef GRAAL + { + // Append graal.jar to bootclasspath if enabled + const char* jar_file = "graal.jar"; + const size_t path_len = strlen(get_meta_index_dir()) + 1 + strlen(jar_file); + char* path = NEW_C_HEAP_ARRAY(char, path_len, mtInternal); + strcpy(path, get_meta_index_dir()); + strcat(path, jar_file); + scp.add_suffix(path); + scp_assembly_required = true; + FREE_C_HEAP_ARRAY(char, path, mtInternal); + } +#endif + // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM) result = parse_java_options_environment_variable(&scp, &scp_assembly_required); if (result != JNI_OK) {
--- a/src/share/vm/runtime/arguments.hpp Wed Mar 06 21:58:58 2013 +0100 +++ b/src/share/vm/runtime/arguments.hpp Wed Mar 06 21:59:06 2013 +0100 @@ -247,9 +247,6 @@ static SystemProperty *_java_home; static SystemProperty *_java_class_path; static SystemProperty *_sun_boot_class_path; -#ifdef GRAAL - static SystemProperty *_compiler_class_path; -#endif // Meta-index for knowing what packages are in the boot class path static char* _meta_index_path; @@ -537,9 +534,6 @@ static void set_ext_dirs(char *value) { _java_ext_dirs->set_value(value); } static void set_endorsed_dirs(char *value) { _java_endorsed_dirs->set_value(value); } static void set_sysclasspath(char *value) { _sun_boot_class_path->set_value(value); } -#ifdef GRAAL - static void set_compilerclasspath(char *value) { _compiler_class_path->set_value(value); } -#endif static void append_sysclasspath(const char *value) { _sun_boot_class_path->append_value(value); } static void set_meta_index_path(char* meta_index_path, char* meta_index_dir) { _meta_index_path = meta_index_path; @@ -550,9 +544,6 @@ static char *get_dll_dir() { return _sun_boot_library_path->value(); } static char *get_endorsed_dir() { return _java_endorsed_dirs->value(); } static char *get_sysclasspath() { return _sun_boot_class_path->value(); } -#ifdef GRAAL - static char *get_compilerclasspath() { return _compiler_class_path->value(); } -#endif static char* get_meta_index_path() { return _meta_index_path; } static char* get_meta_index_dir() { return _meta_index_dir; }