Mercurial > hg > graal-compiler
annotate mx.graal/mx_graal_9.py @ 23257:926fafcb44b8
only print stack traces from CompileTheWorld in verbose mode
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 05 Jan 2016 12:06:37 +0100 |
parents | 77feea4fe00c |
children | f0e34c710768 |
rev | line source |
---|---|
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 # |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 # ---------------------------------------------------------------------------------------------------- |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 # |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 # Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 # |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 # This code is free software; you can redistribute it and/or modify it |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 # under the terms of the GNU General Public License version 2 only, as |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 # published by the Free Software Foundation. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 # |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 # This code is distributed in the hope that it will be useful, but WITHOUT |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 # version 2 for more details (a copy is included in the LICENSE file that |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 # accompanied this code). |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 # |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU General Public License version |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 # 2 along with this work; if not, write to the Free Software Foundation, |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 # |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 # or visit www.oracle.com if you need additional information or have any |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 # questions. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 # |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 # ---------------------------------------------------------------------------------------------------- |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import os |
23255
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
28 from os.path import join, exists, abspath |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 from argparse import ArgumentParser |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import sanitycheck |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import re |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import mx |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 from mx_gate import Task |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 from sanitycheck import _noneAsEmptyList |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 from mx_unittest import unittest |
22952
1ba34f16d176
Factor out benchmarks from mx_graal_n.py and add specjbb2015
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22951
diff
changeset
|
38 from mx_graal_bench import dacapo |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 import mx_gate |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 import mx_unittest |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 _suite = mx.suite('graal') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 |
22951
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
44 _jdk = mx.get_jdk(tag='default') |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 assert _jdk.javaCompliance >= "1.9" |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 def isJVMCIEnabled(vm): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 return True |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 _jvmciModes = { |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 'hosted' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI'], |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 'jit' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCICompiler'], |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 'disabled' : [] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 } |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 def get_vm(): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 """ |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 Gets the name of the currently selected JVM variant. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 """ |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 return 'server' |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 class JVMCIMode: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 """ |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 A context manager for setting the current JVMCI mode. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 """ |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 def __init__(self, jvmciMode=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 self.update(jvmciMode) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 def update(self, jvmciMode=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 assert jvmciMode is None or jvmciMode in _jvmciModes, jvmciMode |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 self.jvmciMode = jvmciMode or _vm.jvmciMode |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 def __enter__(self): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 global _vm |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 self.previousVm = _vm |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 _vm = self |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 def __exit__(self, exc_type, exc_value, traceback): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 global _vm |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 _vm = self.previousVm |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 _vm = JVMCIMode(jvmciMode='hosted') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 |
22887
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
84 class BootClasspathDist(object): |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
85 """ |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
86 Extra info for a Distribution that must be put onto the boot class path. |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
87 """ |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
88 def __init__(self, name): |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
89 self._name = name |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
90 |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
91 def dist(self): |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
92 return mx.distribution(self._name) |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
93 |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
94 def get_classpath_repr(self): |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
95 return self.dist().classpath_repr() |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
96 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 _compilers = ['graal-economy', 'graal'] |
22887
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
98 _bootClasspathDists = [ |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
99 BootClasspathDist('GRAAL'), |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 ] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 def add_compiler(compilerName): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 _compilers.append(compilerName) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 |
22887
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
105 def add_boot_classpath_dist(dist): |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
106 _bootClasspathDists.append(dist) |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 mx_gate.add_jacoco_includes(['com.oracle.graal.*']) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 mx_gate.add_jacoco_excluded_annotations(['@Snippet', '@ClassSubstitution']) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 # This is different than the 'jmh' commmand in that it |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 # looks for internal JMH benchmarks (i.e. those that |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 # depend on the JMH library). |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 def microbench(args): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 """run JMH microbenchmark projects""" |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 parser = ArgumentParser(prog='mx microbench', description=microbench.__doc__, |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 usage="%(prog)s [command options|VM options] [-- [JMH options]]") |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 parser.add_argument('--jar', help='Explicitly specify micro-benchmark location') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 known_args, args = parser.parse_known_args(args) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 vmArgs, jmhArgs = mx.extract_VM_args(args, useDoubleDash=True) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 # look for -f in JMH arguments |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 forking = True |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 for i in range(len(jmhArgs)): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 arg = jmhArgs[i] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 if arg.startswith('-f'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 if arg == '-f' and (i+1) < len(jmhArgs): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 arg += jmhArgs[i+1] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 try: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 if int(arg[2:]) == 0: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 forking = False |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 except ValueError: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 pass |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 if known_args.jar: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 # use the specified jar |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 args = ['-jar', known_args.jar] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 if not forking: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 args += vmArgs |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 else: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 # find all projects with a direct JMH dependency |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 jmhProjects = [] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 for p in mx.projects_opt_limit_to_suites(): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 if 'JMH' in [x.name for x in p.deps]: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 jmhProjects.append(p.name) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 cp = mx.classpath(jmhProjects) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 # execute JMH runner |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 args = ['-cp', cp] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 if not forking: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 args += vmArgs |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 args += ['org.openjdk.jmh.Main'] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 if forking: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 jvm = get_vm() |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 def quoteSpace(s): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 if " " in s: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 return '"' + s + '"' |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 return s |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 forkedVmArgs = map(quoteSpace, _parseVmArgs(_jdk, vmArgs)) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 args += ['--jvmArgsPrepend', ' '.join(['-' + jvm] + forkedVmArgs)] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 run_vm(args + jmhArgs) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 def ctw(args, extraVMarguments=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 """run CompileTheWorld""" |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 defaultCtwopts = '-Inline' |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 parser = ArgumentParser(prog='mx ctw') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 parser.add_argument('--ctwopts', action='store', help='space separated JVMCI options used for CTW compilations (default: --ctwopts="' + defaultCtwopts + '")', default=defaultCtwopts, metavar='<options>') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 parser.add_argument('--cp', '--jar', action='store', help='jar or class path denoting classes to compile', metavar='<path>') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 args, vmargs = parser.parse_known_args(args) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 if args.ctwopts: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
178 # Replace spaces with '#' since -G: options cannot contain spaces |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 vmargs.append('-G:CompileTheWorldConfig=' + re.sub(r'\s+', '#', args.ctwopts)) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 if args.cp: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 cp = os.path.abspath(args.cp) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 else: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 cp = join(_jdk.home, 'lib', 'modules', 'bootmodules.jimage') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 vmargs.append('-G:CompileTheWorldExcludeMethodFilter=sun.awt.X11.*.*') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 # suppress menubar and dock when running on Mac; exclude x11 classes as they may cause vm crashes (on Solaris) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 vmargs = ['-Djava.awt.headless=true'] + vmargs |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
189 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
190 if _vm.jvmciMode == 'disabled': |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 vmargs += ['-XX:+CompileTheWorld', '-Xbootclasspath/p:' + cp] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
192 else: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
193 if _vm.jvmciMode == 'jit': |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
194 vmargs += ['-XX:+BootstrapJVMCI'] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
195 vmargs += ['-G:CompileTheWorldClasspath=' + cp, 'com.oracle.graal.hotspot.CompileTheWorld'] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
196 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 run_vm(vmargs + _noneAsEmptyList(extraVMarguments)) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
198 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
199 class UnitTestRun: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 def __init__(self, name, args): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 self.name = name |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 self.args = args |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 def run(self, suites, tasks, extraVMarguments=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 for suite in suites: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
206 with Task(self.name + ': hosted-product ' + suite, tasks) as t: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 if t: unittest(['--suite', suite, '--enable-timing', '--verbose', '--fail-fast'] + self.args + _noneAsEmptyList(extraVMarguments)) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 class BootstrapTest: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 def __init__(self, name, vmbuild, args, suppress=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 self.name = name |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
212 self.args = args |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 self.suppress = suppress |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
214 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 def run(self, tasks, extraVMarguments=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 with JVMCIMode('jit'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 with Task(self.name, tasks) as t: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
218 if t: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
219 if self.suppress: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
220 out = mx.DuplicateSuppressingStream(self.suppress).write |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
221 else: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
222 out = None |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
223 run_vm(self.args + _noneAsEmptyList(extraVMarguments) + ['-XX:-TieredCompilation', '-XX:+BootstrapJVMCI', '-version'], out=out) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
224 |
23095
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
225 class MicrobenchRun: |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
226 def __init__(self, name, args): |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
227 self.name = name |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
228 self.args = args |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
229 |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
230 def run(self, tasks, extraVMarguments=None): |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
231 with Task(self.name + ': hosted-product ', tasks) as t: |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
232 if t: microbench(_noneAsEmptyList(extraVMarguments) + ['--'] + self.args) |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
233 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
234 def compiler_gate_runner(suites, unit_test_runs, bootstrap_tests, tasks, extraVMarguments=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
235 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
236 # Run unit tests in hosted mode |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
237 with JVMCIMode('hosted'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 for r in unit_test_runs: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
239 r.run(suites, tasks, extraVMarguments) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 |
23095
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
241 # Run microbench in hosted mode (only for testing the JMH setup) |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
242 with JVMCIMode('hosted'): |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
243 for r in [MicrobenchRun('Microbench', ['TestJMH'])]: |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
244 r.run(tasks, extraVMarguments) |
cfb4dae8d566
gate: add check for verifying the jmh-runner setup.
Josef Eisl <josef.eisl@jku.at>
parents:
23074
diff
changeset
|
245 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
246 # Run ctw against rt.jar on server-hosted-jvmci |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
247 with JVMCIMode('hosted'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
248 with Task('CTW:hosted', tasks) as t: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
249 if t: ctw(['--ctwopts', '-Inline +ExitVMOnException', '-esa', '-G:+CompileTheWorldMultiThreaded', '-G:-InlineDuringParsing', '-G:-CompileTheWorldVerbose', '-XX:ReservedCodeCacheSize=300m'], _noneAsEmptyList(extraVMarguments)) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
250 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
251 # bootstrap tests |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
252 for b in bootstrap_tests: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
253 b.run(tasks, extraVMarguments) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
254 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
255 # run dacapo sanitychecks |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
256 for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel='release', extraVmArguments=extraVMarguments) \ |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel='release', extraVmArguments=extraVMarguments): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
258 with Task(str(test) + ':' + 'release', tasks) as t: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
259 if t and not test.test('jvmci'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
260 t.abort(test.name + ' Failed') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
261 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
262 # ensure -Xbatch still works |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
263 with JVMCIMode('jit'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
264 with Task('DaCapo_pmd:BatchMode', tasks) as t: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
265 if t: dacapo(_noneAsEmptyList(extraVMarguments) + ['-Xbatch', 'pmd']) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
266 |
23157
274037591da2
gate: test benchmark counters.
Josef Eisl <josef.eisl@jku.at>
parents:
23108
diff
changeset
|
267 # ensure benchmark counters still work |
274037591da2
gate: test benchmark counters.
Josef Eisl <josef.eisl@jku.at>
parents:
23108
diff
changeset
|
268 with JVMCIMode('jit'): |
274037591da2
gate: test benchmark counters.
Josef Eisl <josef.eisl@jku.at>
parents:
23108
diff
changeset
|
269 with Task('DaCapo_pmd:BenchmarkCounters:product', tasks) as t: |
274037591da2
gate: test benchmark counters.
Josef Eisl <josef.eisl@jku.at>
parents:
23108
diff
changeset
|
270 if t: dacapo(_noneAsEmptyList(extraVMarguments) + ['-G:+LIRProfileMoves', '-G:+GenericDynamicCounters', '-XX:JVMCICounterSize=10', 'pmd']) |
274037591da2
gate: test benchmark counters.
Josef Eisl <josef.eisl@jku.at>
parents:
23108
diff
changeset
|
271 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
272 # ensure -Xcomp still works |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
273 with JVMCIMode('jit'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
274 with Task('XCompMode:product', tasks) as t: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
275 if t: run_vm(_noneAsEmptyList(extraVMarguments) + ['-Xcomp', '-version']) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
276 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
277 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
278 graal_unit_test_runs = [ |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
279 UnitTestRun('UnitTests', []), |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
280 ] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
281 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
282 _registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if mx.get_arch() == 'sparcv9' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14' |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
283 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
284 graal_bootstrap_tests = [ |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
285 BootstrapTest('BootstrapWithSystemAssertions', 'fastdebug', ['-esa']), |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
286 BootstrapTest('BootstrapWithSystemAssertionsNoCoop', 'fastdebug', ['-esa', '-XX:-UseCompressedOops', '-G:+ExitVMOnException']), |
23108 | 287 BootstrapTest('BootstrapWithGCVerification', 'product', ['-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-G:+ExitVMOnException'], suppress=['VerifyAfterGC:', 'VerifyBeforeGC:']), |
288 BootstrapTest('BootstrapWithG1GCVerification', 'product', ['-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-G:+ExitVMOnException'], suppress=['VerifyAfterGC:', 'VerifyBeforeGC:']), | |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
289 BootstrapTest('BootstrapEconomyWithSystemAssertions', 'fastdebug', ['-esa', '-Djvmci.compiler=graal-economy', '-G:+ExitVMOnException']), |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
290 BootstrapTest('BootstrapWithExceptionEdges', 'fastdebug', ['-esa', '-G:+StressInvokeWithExceptionNode', '-G:+ExitVMOnException']), |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
291 BootstrapTest('BootstrapWithRegisterPressure', 'product', ['-esa', '-G:RegisterPressure=' + _registers, '-G:+ExitVMOnException']), |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
292 BootstrapTest('BootstrapTraceRAWithRegisterPressure', 'product', ['-esa', '-G:+TraceRA', '-G:RegisterPressure=' + _registers, '-G:+ExitVMOnException']), |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
293 BootstrapTest('BootstrapWithImmutableCode', 'product', ['-esa', '-G:+ImmutableCode', '-G:+VerifyPhases', '-G:+ExitVMOnException']), |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
294 ] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
295 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
296 def _graal_gate_runner(args, tasks): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
297 compiler_gate_runner(['graal'], graal_unit_test_runs, graal_bootstrap_tests, tasks, args.extra_vm_argument) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
298 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
299 mx_gate.add_gate_runner(_suite, _graal_gate_runner) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
300 mx_gate.add_gate_argument('--extra-vm-argument', action='append', help='add extra vm argument to gate tasks if applicable (multiple occurrences allowed)') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
301 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
302 def _unittest_vm_launcher(vmArgs, mainClass, mainClassArgs): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
303 run_vm(vmArgs + [mainClass] + mainClassArgs) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
304 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
305 mx_unittest.set_vm_launcher('JDK9 VM launcher', _unittest_vm_launcher) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
306 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
307 def _parseVmArgs(jdk, args, addDefaultArgs=True): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
308 args = mx.expand_project_in_args(args, insitu=False) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
309 jacocoArgs = mx_gate.get_jacoco_agent_args() |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
310 if jacocoArgs: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
311 args = jacocoArgs + args |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
312 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
313 # Support for -G: options |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
314 def translateGOption(arg): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
315 if arg.startswith('-G:+'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
316 if '=' in arg: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
317 mx.abort('Mixing + and = in -G: option specification: ' + arg) |
23209
f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents:
23157
diff
changeset
|
318 arg = '-Dgraal.option.' + arg[len('-G:+'):] + '=true' |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
319 elif arg.startswith('-G:-'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
320 if '=' in arg: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
321 mx.abort('Mixing - and = in -G: option specification: ' + arg) |
23209
f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents:
23157
diff
changeset
|
322 arg = '-Dgraal.option.' + arg[len('-G:+'):] + '=false' |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
323 elif arg.startswith('-G:'): |
23209
f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents:
23157
diff
changeset
|
324 arg = '-Dgraal.option.' + arg[len('-G:'):] |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
325 return arg |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
326 args = map(translateGOption, args) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
327 |
23209
f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents:
23157
diff
changeset
|
328 if '-G:+PrintFlags' in args and '-Xcomp' not in args: |
f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents:
23157
diff
changeset
|
329 mx.warn('Using -G:+PrintFlags may have no effect without -Xcomp as Graal initialization is lazy') |
f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents:
23157
diff
changeset
|
330 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
331 bcp = [mx.distribution('truffle:TRUFFLE_API').classpath_repr()] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
332 if _jvmciModes[_vm.jvmciMode]: |
22887
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
333 bcp.extend([d.get_classpath_repr() for d in _bootClasspathDists]) |
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
334 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
335 args = ['-Xbootclasspath/p:' + os.pathsep.join(bcp)] + args |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
336 |
23255
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
337 # Remove JVMCI from class path. It's only there to support compilation. |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
338 cpIndex, cp = mx.find_classpath_arg(args) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
339 if cp: |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
340 jvmciLib = mx.library('JVMCI').path |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
341 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e != jvmciLib]) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
342 args[cpIndex] = cp |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
343 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
344 # Set the default JVMCI compiler |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
345 jvmciCompiler = _compilers[-1] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
346 args = ['-Djvmci.compiler=' + jvmciCompiler] + args |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
347 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
348 if '-version' in args: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
349 ignoredArgs = args[args.index('-version') + 1:] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
350 if len(ignoredArgs) > 0: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
351 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
352 return jdk.processArgs(args, addDefaultArgs=addDefaultArgs) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
353 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
354 def run_java(jdk, args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, env=None, addDefaultArgs=True): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
355 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
356 args = _parseVmArgs(jdk, args, addDefaultArgs=addDefaultArgs) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
357 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
358 jvmciModeArgs = _jvmciModes[_vm.jvmciMode] |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
359 cmd = [jdk.java] + ['-' + get_vm()] + jvmciModeArgs + args |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
360 return mx.run(cmd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
361 |
22951
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
362 _GRAAL_JVMCI_TAG = 'graal' |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
363 |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
364 class GraalJVMCI9JDKConfig(mx.JDKConfig): |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
365 def __init__(self, original): |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
366 self._original = original |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
367 mx.JDKConfig.__init__(self, original.home, tag=_GRAAL_JVMCI_TAG) |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
368 |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
369 def run_java(self, args, **kwArgs): |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
370 run_java(self._original, args, **kwArgs) |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
371 |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
372 class GraalJDKFactory(mx.JDKFactory): |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
373 def getJDKConfig(self): |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
374 return GraalJVMCI9JDKConfig(_jdk) |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
375 |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
376 def description(self): |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
377 return "JVMCI JDK with Graal" |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
378 |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
379 mx.addJDKFactory(_GRAAL_JVMCI_TAG, mx.JavaCompliance('9'), GraalJDKFactory()) |
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
380 |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
381 def run_vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, debugLevel=None, vmbuild=None): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
382 """run a Java program by executing the java executable in a JVMCI JDK""" |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
383 |
22951
d74202a599fe
Support running Truffle using Graal on a JVMCI-enabled JDK9 image.
Roland Schatz <roland.schatz@oracle.com>
parents:
22887
diff
changeset
|
384 return run_java(_jdk, args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
385 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
386 class GraalArchiveParticipant: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
387 def __init__(self, dist): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
388 self.dist = dist |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
389 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
390 def __opened__(self, arc, srcArc, services): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
391 self.services = services |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
392 self.arc = arc |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
393 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
394 def __add__(self, arcname, contents): |
23222
56359eb3abfa
moved @ServiceProvider mechanism from JVMCI to Graal (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents:
23218
diff
changeset
|
395 if arcname.startswith('META-INF/providers/'): |
56359eb3abfa
moved @ServiceProvider mechanism from JVMCI to Graal (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents:
23218
diff
changeset
|
396 provider = arcname[len('META-INF/providers/'):] |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
397 for service in contents.strip().split(os.linesep): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
398 assert service |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
399 self.services.setdefault(service, []).append(provider) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
400 return True |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
401 elif arcname.endswith('_OptionDescriptors.class'): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
402 # Need to create service files for the providers of the |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
403 # jdk.vm.ci.options.Options service created by |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
404 # jdk.vm.ci.options.processor.OptionProcessor. |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
405 provider = arcname[:-len('.class'):].replace('/', '.') |
23209
f35e653aa876
moved @Option mechanism from JVMCI to Graal (GRAAL-1371)
Doug Simon <doug.simon@oracle.com>
parents:
23157
diff
changeset
|
406 self.services.setdefault('com.oracle.graal.options.OptionDescriptors', []).append(provider) |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
407 return False |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
408 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
409 def __addsrc__(self, arcname, contents): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
410 return False |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
411 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
412 def __closing__(self): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
413 pass |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
414 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
415 mx.update_commands(_suite, { |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
416 'vm': [run_vm, '[-options] class [args...]'], |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
417 'ctw': [ctw, '[-vmoptions|noinline|nocomplex|full]'], |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
418 'microbench' : [microbench, '[VM options] [-- [JMH options]]'], |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
419 }) |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
420 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
421 mx.add_argument('-M', '--jvmci-mode', action='store', choices=sorted(_jvmciModes.viewkeys()), help='the JVM variant type to build/run (default: ' + _vm.jvmciMode + ')') |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
422 |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
423 def mx_post_parse_cmd_line(opts): |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
424 if opts.jvmci_mode is not None: |
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
425 _vm.update(opts.jvmci_mode) |
22887
a9b332b34123
mx: added BootClasspathDist
Doug Simon <doug.simon@oracle.com>
parents:
22882
diff
changeset
|
426 for dist in [d.dist() for d in _bootClasspathDists]: |
22882
9fed99d7f32d
made Graal work on a JDK9 image without needing the jvmci mx suite or extensions
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
427 dist.set_archiveparticipant(GraalArchiveParticipant(dist)) |
23255
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
428 |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
429 def _update_JVMCI_library(): |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
430 """ |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
431 Updates the "path" and "sha1" attributes of the "JVMCI" library to |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
432 refer to a jvmci.jar created from the JVMCI classes in JDK9. |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
433 """ |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
434 suiteDict = _suite.suiteDict |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
435 jvmciLib = suiteDict['libraries']['JVMCI'] |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
436 d = join(_suite.get_output_root(), abspath(_jdk.home)[1:]) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
437 path = join(d, 'jvmci.jar') |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
438 if not exists(path): |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
439 explodedModule = join(_jdk.home, 'modules', 'jdk.vm.ci') |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
440 if exists(explodedModule): |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
441 with mx.Archiver(path, kind='zip') as arc: |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
442 for root, _, files in os.walk(explodedModule): |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
443 relpath = root[len(explodedModule) + 1:] |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
444 for f in files: |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
445 arcname = join(relpath, f).replace(os.sep, '/') |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
446 with open(join(root, f), 'rb') as fp: |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
447 contents = fp.read() |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
448 arc.zf.writestr(arcname, contents) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
449 else: |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
450 # Use the jdk.internal.jimage utility since it's the only way |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
451 # (currently) to read .jimage files and unfortunately the |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
452 # JDK9 jimage tool does not support partial extraction. |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
453 bootmodules = join(_jdk.home, 'lib', 'modules', 'bootmodules.jimage') |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
454 if not exists(bootmodules): |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
455 mx.abort('Could not find JVMCI classes at ' + bootmodules + ' or ' + explodedModule) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
456 mx.ensure_dir_exists(d) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
457 javaSource = join(d, 'ExtractJVMCI.java') |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
458 with open(javaSource, 'w') as fp: |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
459 print >> fp, """import java.io.FileOutputStream; |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
460 import java.util.jar.JarEntry; |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
461 import java.util.jar.JarOutputStream; |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
462 import jdk.internal.jimage.BasicImageReader; |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
463 |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
464 public class ExtractJVMCI { |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
465 public static void main(String[] args) throws Exception { |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
466 BasicImageReader image = BasicImageReader.open(args[0]); |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
467 String[] names = image.getEntryNames(); |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
468 if (names.length == 0) { |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
469 return; |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
470 } |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
471 try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(args[1]))) { |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
472 for (String name : names) { |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
473 if (name.startsWith("/jdk.vm.ci/")) { |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
474 String ename = name.substring("/jdk.vm.ci/".length()); |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
475 JarEntry je = new JarEntry(ename); |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
476 jos.putNextEntry(je); |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
477 jos.write(image.getResource(name)); |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
478 jos.closeEntry(); |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
479 } |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
480 } |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
481 } |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
482 } |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
483 } |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
484 """ |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
485 mx.run([_jdk.javac, '-d', d, javaSource]) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
486 mx.run([_jdk.java, '-cp', d, 'ExtractJVMCI', bootmodules, path]) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
487 if not exists(path): |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
488 mx.abort('Could not find the JVMCI classes in ' + bootmodules) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
489 |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
490 jvmciLib['path'] = path |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
491 jvmciLib['sha1'] = mx.sha1OfFile(path) |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
492 |
77feea4fe00c
re-added JVMCI library and generate it JVMCI classes in JDK9
Doug Simon <doug.simon@oracle.com>
parents:
23222
diff
changeset
|
493 _update_JVMCI_library() |