Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspotvmconfig.processor/src/jdk/vm/ci/hotspotvmconfig/processor/HotSpotVMConfigProcessor.java @ 23297:4b58c92e939b
remove redundant modifiers
author | Manuel Rigger <rigger.manuel@gmail.com> |
---|---|
date | Tue, 02 Feb 2016 16:19:37 +0100 |
parents | c2687aa5e5ca |
children | a920338dd4d4 |
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 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
23291
diff
changeset
|
57 @SupportedAnnotationTypes({"jdk.vm.ci.hotspotvmconfig.HotSpotVMConstant", "jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag", "jdk.vm.ci.hotspotvmconfig.HotSpotVMField", |
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
23291
diff
changeset
|
58 "jdk.vm.ci.hotspotvmconfig.HotSpotVMType", "jdk.vm.ci.hotspotvmconfig.HotSpotVMValue"}) |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
59 public class HotSpotVMConfigProcessor extends AbstractProcessor { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
60 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
61 public HotSpotVMConfigProcessor() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
62 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
63 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
64 @Override |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
65 public SourceVersion getSupportedSourceVersion() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
66 return SourceVersion.latest(); |
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 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
69 /** |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
70 * 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
|
71 * 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
|
72 * setup. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
73 */ |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
74 private static final boolean DEBUG = false; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
75 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
76 private PrintWriter log; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
77 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
78 /** |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
79 * Logging facility for debugging the annotation processor. |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
80 */ |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
81 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
82 private PrintWriter getLog() { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
83 if (log == null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
84 try { |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
85 // 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
|
86 // /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
|
87 // on the mac. |
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
88 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
|
89 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
|
90 } catch (IOException e) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
91 // Do nothing |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
92 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
93 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
94 return log; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
95 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
96 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
97 private void logMessage(String format, Object... args) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
98 if (!DEBUG) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
99 return; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
100 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
101 PrintWriter bw = getLog(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
102 if (bw != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
103 bw.printf(format, args); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
104 bw.flush(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
105 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
106 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
107 |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
108 private void logException(Throwable t) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
109 if (!DEBUG) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
110 return; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
111 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
112 PrintWriter bw = getLog(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
113 if (bw != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
114 t.printStackTrace(bw); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
115 bw.flush(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
116 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
117 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
118 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
119 /** |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
120 * 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
|
121 * throws as errors. |
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 private void reportExceptionThrow(Element element, Throwable t) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
124 if (element != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
125 logMessage("throw for %s:\n", element); |
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 logException(t); |
16045
a8322288e838
improve error reporting in MatchProcessor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16018
diff
changeset
|
128 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
|
129 } |
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 //@formatter:off |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
132 String[] prologue = new String[]{ |
15844 | 133 "// 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
|
134 "static bool boolAt(char* name, bool* value) {", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
135 " 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
|
136 " if (result == NULL) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
137 " if (!result->is_bool()) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
138 " *value = result->get_bool();", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
139 " return true;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
140 "}", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
141 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
142 "static bool intxAt(char* name, intx* value) {", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
143 " 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
|
144 " if (result == NULL) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
145 " if (!result->is_intx()) return false;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
146 " *value = result->get_intx();", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
147 " return true;", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
148 "}", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
149 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
150 "#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
|
151 "#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
|
152 "#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
|
153 "#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
|
154 "#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
|
155 "#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
|
156 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
157 "#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
|
158 "#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
|
159 "#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
|
160 "", |
15806
240cc9a901fb
don't use JNI natives to interact with VM metadata
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15805
diff
changeset
|
161 "void VMStructs::initHotSpotVMConfig(oop vmconfig_oop) {", |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
162 " InstanceKlass* vmconfig_klass = InstanceKlass::cast(vmconfig_oop->klass());", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
163 "", |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
164 }; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
165 //@formatter:on |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
166 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
167 String outputName = "HotSpotVMConfig.inline.hpp"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
168 String outputDirectory = "hotspot"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
169 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
170 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
|
171 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
172 Filer filer = processingEnv.getFiler(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
173 try (PrintWriter out = createSourceFile(outputDirectory, outputName, filer, element)) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
174 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
175 for (String line : prologue) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
176 out.println(line); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
177 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
178 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
179 Map<String, Integer> expectedValues = new HashMap<>(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
180 for (VMConfigField value : annotations.values()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
181 if (!value.optional) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
182 String key = value.define != null ? value.define : ""; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
183 if (expectedValues.get(key) == null) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
184 expectedValues.put(key, 1); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
185 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
186 expectedValues.put(key, expectedValues.get(key) + 1); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
187 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
188 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
189 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
190 |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
191 out.printf(" int expected = %s;%n", expectedValues.get("")); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
192 for (Entry<String, Integer> entry : expectedValues.entrySet()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
193 if (entry.getKey().equals("")) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
194 continue; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
195 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
196 out.printf("#if %s%n", entry.getKey()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
197 out.printf(" expected += %s;%n", entry.getValue()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
198 out.printf("#endif%n"); |
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.println(" int assigned = 0;"); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
201 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
|
202 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
203 Set<String> fieldTypes = new HashSet<>(); |
15844 | 204 for (VMConfigField key : annotations.values()) { |
205 fieldTypes.add(key.getType()); | |
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 // 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
|
208 // direct compare. In general this reduces each operation to 2 tests plus a string |
15844 | 209 // 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
|
210 for (String type : fieldTypes) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
211 String sigtype = type.equals("boolean") ? "bool" : type; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
212 out.println(" if (fs.signature() == vmSymbols::" + sigtype + "_signature()) {"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
213 Set<Integer> lengths = new HashSet<>(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
214 for (Entry<String, VMConfigField> entry : annotations.entrySet()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
215 if (entry.getValue().getType().equals(type)) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
216 lengths.add(entry.getKey().length()); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
217 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
218 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
219 out.println(" switch (fs.name()->utf8_length()) {"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
220 for (int len : lengths) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
221 out.println(" case " + len + ":"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
222 for (Entry<String, VMConfigField> entry : annotations.entrySet()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
223 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
|
224 out.println(" if (fs.name()->equals(\"" + entry.getKey() + "\")) {"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
225 entry.getValue().emit(out); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
226 out.println(" continue;"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
227 out.println(" }"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
228 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
229 } |
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 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
232 out.println(" } // switch"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
233 out.println(" continue;"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
234 out.println(" } // if"); |
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(" } // for"); |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
237 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
|
238 out.println("}"); |
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 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
241 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
242 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
|
243 try { |
21558
d563baeca9df
changed uses of Graal terminology to JVMCI (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
244 // 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
|
245 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
|
246 logMessage("%s\n", sourceFile); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
247 return new PrintWriter(sourceFile.openWriter()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
248 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
249 @Override |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
250 public void println() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
251 print("\n"); |
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 }; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
254 } catch (IOException e) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
255 throw new RuntimeException(e); |
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 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
259 static class VMConfigField { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
260 final String setter; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
261 final String define; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
262 private boolean optional; |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
263 final VariableElement field; |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
264 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
23291
diff
changeset
|
265 VMConfigField(VariableElement field, HotSpotVMField value) { |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
266 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
267 define = archDefines(value.archs()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
268 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
269 String name = value.name(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
270 int i = name.lastIndexOf("::"); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
271 switch (value.get()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
272 case OFFSET: |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
273 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
|
274 break; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
275 case ADDRESS: |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
276 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
|
277 break; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
278 case VALUE: |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
279 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
|
280 break; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
281 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
|
282 throw new JVMCIError("unexpected type: " + value.get()); |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
283 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
284 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
285 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
23291
diff
changeset
|
286 VMConfigField(VariableElement field, HotSpotVMType value) { |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
287 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
288 define = null; // ((HotSpotVMType) annotation).archs(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
289 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
290 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
|
291 } |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
292 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
23291
diff
changeset
|
293 VMConfigField(VariableElement field, HotSpotVMValue value) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
294 this.field = field; |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
295 String[] defines = value.defines(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
296 int length = defines.length; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
297 if (length != 0) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
298 for (int i = 0; i < length; i++) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
299 defines[i] = "defined(" + defines[i] + ")"; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
300 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
301 define = String.join(" || ", defines); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
302 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
303 define = null; // ((HotSpotVMValue) annotation).archs(); |
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 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
306 if (value.get() == HotSpotVMValue.Type.ADDRESS) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
307 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
|
308 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
309 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
|
310 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
311 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
312 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
23291
diff
changeset
|
313 VMConfigField(VariableElement field, HotSpotVMConstant value) { |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
314 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
315 define = archDefines(value.archs()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
316 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
317 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
|
318 } |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
319 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
23291
diff
changeset
|
320 VMConfigField(VariableElement field, HotSpotVMFlag value) { |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
321 this.field = field; |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
322 define = archDefines(value.archs()); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
323 optional = value.optional(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
324 String type = field.asType().toString(); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
325 if (value.optional()) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
326 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
|
327 } else { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
328 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
|
329 } |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
330 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
331 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
332 public String getType() { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
333 return field.asType().toString(); |
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 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
336 private static String archDefine(String arch) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
337 switch (arch) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
338 case "amd64": |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
339 return "defined(AMD64)"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
340 case "sparcv9": |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
341 return "(defined(SPARC) && defined(_LP64))"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
342 case "sparc": |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
343 return "defined(SPARC)"; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
344 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
|
345 throw new JVMCIError("unexpected arch: " + arch); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
346 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
347 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
348 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
349 private static String archDefines(String[] archs) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
350 if (archs == null || archs.length == 0) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
351 return null; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
352 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
353 if (archs.length == 1) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
354 return archDefine(archs[0]); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
355 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
356 String[] defs = new String[archs.length]; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
357 int i = 0; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
358 for (String arch : archs) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
359 defs[i++] = archDefine(arch); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
360 } |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
361 return String.join(" || ", defs); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
362 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
363 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
364 public void emit(PrintWriter out) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
365 if (define != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
366 out.printf("#if %s\n", define); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
367 } |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
368 out.printf(" %s%n", setter); |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
369 if (!optional) { |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
370 out.printf(" assigned++;%n"); |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
371 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
372 if (define != null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
373 out.printf("#endif\n"); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
374 } |
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 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
377 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
378 |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
379 @SuppressWarnings("unchecked") |
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
380 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
|
381 BiFunction<VariableElement, T, VMConfigField> builder) { |
15805
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
382 for (Element element : roundEnv.getElementsAnnotatedWith(annotationClass)) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
383 Annotation constant = element.getAnnotation(annotationClass); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
384 if (element.getKind() != ElementKind.FIELD) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
385 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
|
386 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
387 if (annotationClass == HotSpotVMValue.class) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
388 HotSpotVMValue value = (HotSpotVMValue) constant; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
389 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
|
390 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
|
391 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
392 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
393 if (currentTypeElement == null) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
394 currentTypeElement = element.getEnclosingElement(); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
395 } else { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
396 if (!currentTypeElement.equals(element.getEnclosingElement())) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
397 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
|
398 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
399 } |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
400 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
|
401 } |
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 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
404 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
|
405 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
|
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 Element currentTypeElement = null; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
409 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
410 @Override |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
411 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
|
412 if (roundEnv.processingOver()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
413 return true; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
414 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
415 logMessage("Starting round %s %s\n", roundEnv, annotations); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
416 try { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
417 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
418 currentTypeElement = null; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
419 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
420 // First collect all the annotations. |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
421 Map<String, VMConfigField> annotationMap = new HashMap<>(); |
16619
2acc00d0322a
Extra sanity checking in initHotSpotVMConfig
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16045
diff
changeset
|
422 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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
428 if (annotationMap.isEmpty()) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
429 return true; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
430 } |
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 logMessage("type element %s\n", currentTypeElement); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
433 createFiles(annotationMap, currentTypeElement); |
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 } catch (Throwable t) { |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
436 reportExceptionThrow(null, t); |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
437 } |
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 return true; |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
440 } |
dffc37fa7157
initialize HotSpotVMConfig fields efficiently from C++
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
441 } |