Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspotvmconfig.processor/src/jdk/vm/ci/hotspotvmconfig/processor/HotSpotVMConfigProcessor.java @ 23291:c2687aa5e5ca
Fix formatting error that the gate complained about
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Mon, 25 Jan 2016 14:56:57 -0800 |
parents | 1bbd4a7c274b |
children | 4b58c92e939b |
rev | line source |
---|---|
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
1 /* |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
4 * |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
8 * |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
14 * |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
18 * |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
21 * questions. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
23 package jdk.vm.ci.hotspotvmconfig.processor; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
24 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
25 import java.io.FileWriter; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
26 import java.io.IOException; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
27 import java.io.PrintWriter; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
28 import java.lang.annotation.Annotation; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
29 import java.util.Arrays; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
30 import java.util.HashMap; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
31 import java.util.HashSet; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
32 import java.util.Map; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
33 import java.util.Map.Entry; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
34 import java.util.Set; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
35 import java.util.function.BiFunction; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
36 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
37 import javax.annotation.processing.AbstractProcessor; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
38 import javax.annotation.processing.Filer; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
39 import javax.annotation.processing.RoundEnvironment; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
40 import javax.annotation.processing.SupportedAnnotationTypes; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
41 import javax.lang.model.SourceVersion; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
42 import javax.lang.model.element.Element; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
43 import javax.lang.model.element.ElementKind; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
44 import javax.lang.model.element.TypeElement; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
45 import javax.lang.model.element.VariableElement; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
46 import javax.tools.Diagnostic.Kind; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
47 import javax.tools.FileObject; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
48 import javax.tools.StandardLocation; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
49 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
50 import jdk.vm.ci.common.JVMCIError; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
51 import jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
52 import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
53 import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
54 import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
55 import jdk.vm.ci.hotspotvmconfig.HotSpotVMValue; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
56 |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21543
diff
changeset
|
57 @SupportedAnnotationTypes({ |
23291
c2687aa5e5ca
Fix formatting error that the gate complained about
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
58 "jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant", |
c2687aa5e5ca
Fix formatting error that the gate complained about
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
59 "jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag", |
c2687aa5e5ca
Fix formatting error that the gate complained about
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
60 "jdk.vm.ci.hotspotvmconfig.HotSpotVMField", |
c2687aa5e5ca
Fix formatting error that the gate complained about
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
61 "jdk.vm.ci.hotspotvmconfig.HotSpotVMType", |
c2687aa5e5ca
Fix formatting error that the gate complained about
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22672
diff
changeset
|
62 "jdk.vm.ci.hotspotvmconfig.HotSpotVMValue"}) |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
63 public class HotSpotVMConfigProcessor extends AbstractProcessor { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
64 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
65 public HotSpotVMConfigProcessor() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
66 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
67 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
68 @Override |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
69 public SourceVersion getSupportedSourceVersion() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
70 return SourceVersion.latest(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
71 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
72 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
73 /** |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
74 * Set to true to enable logging to a local file during annotation processing. There's no normal |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
75 * channel for any debug messages and debugging annotation processors requires some special |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
76 * setup. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
77 */ |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
78 private static final boolean DEBUG = false; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
79 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
80 private PrintWriter log; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
81 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
82 /** |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
83 * Logging facility for debugging the annotation processor. |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
84 */ |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
85 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
86 private PrintWriter getLog() { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
87 if (log == null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
88 try { |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
89 // Create the log file within the generated source directory so it's easy to find. |
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
90 // /tmp isn't platform independent and java.io.tmpdir can map anywhere, particularly |
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
91 // on the mac. |
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
92 FileObject file = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", getClass().getSimpleName() + "log"); |
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
93 log = new PrintWriter(new FileWriter(file.toUri().getPath(), true)); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
94 } catch (IOException e) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
95 // Do nothing |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
96 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
97 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
98 return log; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
99 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
100 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
101 private void logMessage(String format, Object... args) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
102 if (!DEBUG) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
103 return; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
104 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
105 PrintWriter bw = getLog(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
106 if (bw != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
107 bw.printf(format, args); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
108 bw.flush(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
109 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
110 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
111 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
112 private void logException(Throwable t) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
113 if (!DEBUG) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
114 return; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
115 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
116 PrintWriter bw = getLog(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
117 if (bw != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
118 t.printStackTrace(bw); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
119 bw.flush(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
120 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
121 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
122 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
123 /** |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
124 * Bugs in an annotation processor can cause silent failure so try to report any exception |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
125 * throws as errors. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
126 */ |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
127 private void reportExceptionThrow(Element element, Throwable t) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
128 if (element != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
129 logMessage("throw for %s:\n", element); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
130 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
131 logException(t); |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
132 errorMessage(element, "Exception throw during processing: %s %s", t, Arrays.toString(Arrays.copyOf(t.getStackTrace(), 4))); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
133 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
134 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
135 //@formatter:off |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
136 String[] prologue = new String[]{ |
15844 | 137 "// The normal wrappers CommandLineFlags::boolAt and CommandLineFlags::intxAt skip constant flags", |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
138 "static bool boolAt(char* name, bool* value) {", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
139 " Flag* result = Flag::find_flag(name, strlen(name), true, true);", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
140 " if (result == NULL) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
141 " if (!result->is_bool()) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
142 " *value = result->get_bool();", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
143 " return true;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
144 "}", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
145 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
146 "static bool intxAt(char* name, intx* value) {", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
147 " Flag* result = Flag::find_flag(name, strlen(name), true, true);", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
148 " if (result == NULL) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
149 " if (!result->is_intx()) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
150 " *value = result->get_intx();", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
151 " return true;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
152 "}", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
153 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
154 "#define set_boolean(name, value) vmconfig_oop->bool_field_put(fs.offset(), value)", |
20809
61b22e817c80
HS VM config processor: make sure casts are applied to the whole expression
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
16619
diff
changeset
|
155 "#define set_byte(name, value) vmconfig_oop->byte_field_put(fs.offset(), (jbyte)(value))", |
61b22e817c80
HS VM config processor: make sure casts are applied to the whole expression
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
16619
diff
changeset
|
156 "#define set_short(name, value) vmconfig_oop->short_field_put(fs.offset(), (jshort)(value))", |
61b22e817c80
HS VM config processor: make sure casts are applied to the whole expression
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
16619
diff
changeset
|
157 "#define set_int(name, value) vmconfig_oop->int_field_put(fs.offset(), (int)(value))", |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
158 "#define set_long(name, value) vmconfig_oop->long_field_put(fs.offset(), value)", |
20809
61b22e817c80
HS VM config processor: make sure casts are applied to the whole expression
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
16619
diff
changeset
|
159 "#define set_address(name, value) do { set_long(name, (jlong)(value)); } while (0)", |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
160 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
161 "#define set_optional_boolean_flag(varName, flagName) do { bool flagValue; if (boolAt((char*) flagName, &flagValue)) { set_boolean(varName, flagValue); } } while (0)", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
162 "#define set_optional_int_flag(varName, flagName) do { intx flagValue; if (intxAt((char*) flagName, &flagValue)) { set_int(varName, flagValue); } } while (0)", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
163 "#define set_optional_long_flag(varName, flagName) do { intx flagValue; if (intxAt((char*) flagName, &flagValue)) { set_long(varName, flagValue); } } while (0)", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
164 "", |
15806
240cc9a901fb
don't use JNI natives to interact with VM metadata
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15805
diff
changeset
|
165 "void VMStructs::initHotSpotVMConfig(oop vmconfig_oop) {", |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
166 " InstanceKlass* vmconfig_klass = InstanceKlass::cast(vmconfig_oop->klass());", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
167 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
168 }; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
169 //@formatter:on |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
170 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
171 String outputName = "HotSpotVMConfig.inline.hpp"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
172 String outputDirectory = "hotspot"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
173 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
174 private void createFiles(Map<String, VMConfigField> annotations, Element element) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
175 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
176 Filer filer = processingEnv.getFiler(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
177 try (PrintWriter out = createSourceFile(outputDirectory, outputName, filer, element)) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
178 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
179 for (String line : prologue) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
180 out.println(line); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
181 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
182 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
183 Map<String, Integer> expectedValues = new HashMap<>(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
184 for (VMConfigField value : annotations.values()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
185 if (!value.optional) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
186 String key = value.define != null ? value.define : ""; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
187 if (expectedValues.get(key) == null) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
188 expectedValues.put(key, 1); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
189 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
190 expectedValues.put(key, expectedValues.get(key) + 1); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
191 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
192 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
193 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
194 |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
195 out.printf(" int expected = %s;%n", expectedValues.get("")); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
196 for (Entry<String, Integer> entry : expectedValues.entrySet()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
197 if (entry.getKey().equals("")) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
198 continue; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
199 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
200 out.printf("#if %s%n", entry.getKey()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
201 out.printf(" expected += %s;%n", entry.getValue()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
202 out.printf("#endif%n"); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
203 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
204 out.println(" int assigned = 0;"); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
205 out.println(" for (JavaFieldStream fs(vmconfig_klass); !fs.done(); fs.next()) {"); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
206 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
207 Set<String> fieldTypes = new HashSet<>(); |
15844 | 208 for (VMConfigField key : annotations.values()) { |
209 fieldTypes.add(key.getType()); | |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
210 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
211 // For each type of field, generate a switch on the length of the symbol and then do a |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
212 // direct compare. In general this reduces each operation to 2 tests plus a string |
15844 | 213 // compare. Being more perfect than that is probably not worth it. |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
214 for (String type : fieldTypes) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
215 String sigtype = type.equals("boolean") ? "bool" : type; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
216 out.println(" if (fs.signature() == vmSymbols::" + sigtype + "_signature()) {"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
217 Set<Integer> lengths = new HashSet<>(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
218 for (Entry<String, VMConfigField> entry : annotations.entrySet()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
219 if (entry.getValue().getType().equals(type)) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
220 lengths.add(entry.getKey().length()); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
221 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
222 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
223 out.println(" switch (fs.name()->utf8_length()) {"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
224 for (int len : lengths) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
225 out.println(" case " + len + ":"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
226 for (Entry<String, VMConfigField> entry : annotations.entrySet()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
227 if (entry.getValue().getType().equals(type) && entry.getKey().length() == len) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
228 out.println(" if (fs.name()->equals(\"" + entry.getKey() + "\")) {"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
229 entry.getValue().emit(out); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
230 out.println(" continue;"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
231 out.println(" }"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
232 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
233 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
234 out.println(" continue;"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
235 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
236 out.println(" } // switch"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
237 out.println(" continue;"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
238 out.println(" } // if"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
239 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
240 out.println(" } // for"); |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
241 out.println(" guarantee(assigned == expected, \"Didn't find all fields during init of HotSpotVMConfig. Maybe recompile?\");"); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
242 out.println("}"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
243 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
244 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
245 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
246 protected PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
247 try { |
21558
d563baeca9df
changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
248 // Ensure Unix line endings to comply with code style guide checked by Checkstyle |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
249 FileObject sourceFile = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg, relativeName, originatingElements); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
250 logMessage("%s\n", sourceFile); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
251 return new PrintWriter(sourceFile.openWriter()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
252 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
253 @Override |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
254 public void println() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
255 print("\n"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
256 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
257 }; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
258 } catch (IOException e) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
259 throw new RuntimeException(e); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
260 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
261 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
262 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
263 static class VMConfigField { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
264 final String setter; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
265 final String define; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
266 private boolean optional; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
267 final VariableElement field; |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
268 |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
269 public VMConfigField(VariableElement field, HotSpotVMField value) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
270 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
271 define = archDefines(value.archs()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
272 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
273 String name = value.name(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
274 int i = name.lastIndexOf("::"); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
275 switch (value.get()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
276 case OFFSET: |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
277 setter = String.format("set_%s(\"%s\", offset_of(%s, %s));", type, field.getSimpleName(), name.substring(0, i), name.substring(i + 2)); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
278 break; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
279 case ADDRESS: |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
280 setter = String.format("set_address(\"%s\", &%s);", field.getSimpleName(), name); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
281 break; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
282 case VALUE: |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
283 setter = String.format("set_%s(\"%s\", (%s) (intptr_t) %s);", type, field.getSimpleName(), type, name); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
284 break; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
285 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21097
diff
changeset
|
286 throw new JVMCIError("unexpected type: " + value.get()); |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
287 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
288 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
289 |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
290 public VMConfigField(VariableElement field, HotSpotVMType value) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
291 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
292 define = null; // ((HotSpotVMType) annotation).archs(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
293 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
294 setter = String.format("set_%s(\"%s\", sizeof(%s));", type, field.getSimpleName(), value.name()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
295 } |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
296 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
297 public VMConfigField(VariableElement field, HotSpotVMValue value) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
298 this.field = field; |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
299 String[] defines = value.defines(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
300 int length = defines.length; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
301 if (length != 0) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
302 for (int i = 0; i < length; i++) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
303 defines[i] = "defined(" + defines[i] + ")"; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
304 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
305 define = String.join(" || ", defines); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
306 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
307 define = null; // ((HotSpotVMValue) annotation).archs(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
308 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
309 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
310 if (value.get() == HotSpotVMValue.Type.ADDRESS) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
311 setter = String.format("set_address(\"%s\", %s);", field.getSimpleName(), value.expression()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
312 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
313 setter = String.format("set_%s(\"%s\", %s);", type, field.getSimpleName(), value.expression()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
314 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
315 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
316 |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
317 public VMConfigField(VariableElement field, HotSpotVMConstant value) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
318 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
319 define = archDefines(value.archs()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
320 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
321 setter = String.format("set_%s(\"%s\", %s);", type, field.getSimpleName(), value.name()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
322 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
323 |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
324 public VMConfigField(VariableElement field, HotSpotVMFlag value) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
325 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
326 define = archDefines(value.archs()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
327 optional = value.optional(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
328 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
329 if (value.optional()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
330 setter = String.format("set_optional_%s_flag(\"%s\", \"%s\");", type, field.getSimpleName(), value.name()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
331 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
332 setter = String.format("set_%s(\"%s\", %s);", type, field.getSimpleName(), value.name()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
333 } |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
334 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
335 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
336 public String getType() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
337 return field.asType().toString(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
338 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
339 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
340 private static String archDefine(String arch) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
341 switch (arch) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
342 case "amd64": |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
343 return "defined(AMD64)"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
344 case "sparcv9": |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
345 return "(defined(SPARC) && defined(_LP64))"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
346 case "sparc": |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
347 return "defined(SPARC)"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
348 default: |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21097
diff
changeset
|
349 throw new JVMCIError("unexpected arch: " + arch); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
350 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
351 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
352 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
353 private static String archDefines(String[] archs) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
354 if (archs == null || archs.length == 0) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
355 return null; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
356 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
357 if (archs.length == 1) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
358 return archDefine(archs[0]); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
359 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
360 String[] defs = new String[archs.length]; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
361 int i = 0; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
362 for (String arch : archs) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
363 defs[i++] = archDefine(arch); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
364 } |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
365 return String.join(" || ", defs); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
366 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
367 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
368 public void emit(PrintWriter out) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
369 if (define != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
370 out.printf("#if %s\n", define); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
371 } |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
372 out.printf(" %s%n", setter); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
373 if (!optional) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
374 out.printf(" assigned++;%n"); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
375 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
376 if (define != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
377 out.printf("#endif\n"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
378 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
379 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
380 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
381 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
382 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
383 @SuppressWarnings("unchecked") |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
384 private <T extends Annotation> void collectAnnotations(RoundEnvironment roundEnv, Map<String, VMConfigField> annotationMap, Class<T> annotationClass, |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
385 BiFunction<VariableElement, T, VMConfigField> builder) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
386 for (Element element : roundEnv.getElementsAnnotatedWith(annotationClass)) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
387 Annotation constant = element.getAnnotation(annotationClass); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
388 if (element.getKind() != ElementKind.FIELD) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
389 errorMessage(element, "%s annotations may only be on fields", annotationClass.getSimpleName()); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
390 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
391 if (annotationClass == HotSpotVMValue.class) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
392 HotSpotVMValue value = (HotSpotVMValue) constant; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
393 if (value.get() == HotSpotVMValue.Type.ADDRESS && !element.asType().toString().equals("long")) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
394 errorMessage(element, "HotSpotVMValue with get == ADDRESS must be of type long, but found %s", element.asType()); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
395 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
396 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
397 if (currentTypeElement == null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
398 currentTypeElement = element.getEnclosingElement(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
399 } else { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
400 if (!currentTypeElement.equals(element.getEnclosingElement())) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
401 errorMessage(element, "Multiple types encountered. Only HotSpotVMConfig is supported"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
402 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
403 } |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
404 annotationMap.put(element.getSimpleName().toString(), builder.apply((VariableElement) element, (T) constant)); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
405 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
406 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
407 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
408 private void errorMessage(Element element, String format, Object... args) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
409 processingEnv.getMessager().printMessage(Kind.ERROR, String.format(format, args), element); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
410 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
411 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
412 Element currentTypeElement = null; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
413 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
414 @Override |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
415 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
416 if (roundEnv.processingOver()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
417 return true; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
418 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
419 logMessage("Starting round %s %s\n", roundEnv, annotations); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
420 try { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
421 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
422 currentTypeElement = null; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
423 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
424 // First collect all the annotations. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
425 Map<String, VMConfigField> annotationMap = new HashMap<>(); |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
426 collectAnnotations(roundEnv, annotationMap, HotSpotVMConstant.class, (e, v) -> new VMConfigField(e, v)); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
427 collectAnnotations(roundEnv, annotationMap, HotSpotVMFlag.class, (e, v) -> new VMConfigField(e, v)); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
428 collectAnnotations(roundEnv, annotationMap, HotSpotVMField.class, (e, v) -> new VMConfigField(e, v)); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
429 collectAnnotations(roundEnv, annotationMap, HotSpotVMType.class, (e, v) -> new VMConfigField(e, v)); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
430 collectAnnotations(roundEnv, annotationMap, HotSpotVMValue.class, (e, v) -> new VMConfigField(e, v)); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
431 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
432 if (annotationMap.isEmpty()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
433 return true; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
434 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
435 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
436 logMessage("type element %s\n", currentTypeElement); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
437 createFiles(annotationMap, currentTypeElement); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
438 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
439 } catch (Throwable t) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
440 reportExceptionThrow(null, t); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
441 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
442 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
443 return true; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
444 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
445 } |