Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethod.java @ 23703:9ac04c6047c8
sync with jdk9 changes for JDK-8159613
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Jun 2016 09:48:02 +0200 |
parents | 1bbd4a7c274b |
children | 1b8892b4ce9c |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
22598
ed53e370f04c
Make implementation classes package private.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@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:
22299
diff
changeset
|
25 import static java.util.FormattableFlags.ALTERNATE; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22299
diff
changeset
|
26 import static java.util.FormattableFlags.LEFT_JUSTIFY; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22299
diff
changeset
|
27 import static java.util.FormattableFlags.UPPERCASE; |
10000
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
28 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22299
diff
changeset
|
29 import java.util.Formattable; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22299
diff
changeset
|
30 import java.util.Formatter; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22299
diff
changeset
|
31 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
32 import jdk.vm.ci.meta.JavaMethod; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
33 import jdk.vm.ci.meta.ResolvedJavaMethod; |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
34 |
22598
ed53e370f04c
Make implementation classes package private.
Roland Schatz <roland.schatz@oracle.com>
parents:
22569
diff
changeset
|
35 abstract class HotSpotMethod implements JavaMethod, Formattable { |
22299
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
36 |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
37 public static String applyFormattingFlagsAndWidth(String s, int flags, int width) { |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
38 if (flags == 0 && width < 0) { |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
39 return s; |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
40 } |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
41 StringBuilder sb = new StringBuilder(s); |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
42 |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
43 // apply width and justification |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
44 int len = sb.length(); |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
45 if (len < width) { |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
46 for (int i = 0; i < width - len; i++) { |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
47 if ((flags & LEFT_JUSTIFY) == LEFT_JUSTIFY) { |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
48 sb.append(' '); |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
49 } else { |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
50 sb.insert(0, ' '); |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
51 } |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
52 } |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
53 } |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
54 |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
55 String res = sb.toString(); |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
56 if ((flags & UPPERCASE) == UPPERCASE) { |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
57 res = res.toUpperCase(); |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
58 } |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
59 return res; |
7b4a47fcc4c0
Move most of jdk.internal.jvmci.debug back into com.oracle.graal.debug
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
60 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
62 protected String name; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
10000
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
64 /** |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
65 * Controls whether {@link #toString()} includes the qualified or simple name of the class in |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
66 * which the method is declared. |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
67 */ |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
68 public static final boolean FULLY_QUALIFIED_METHOD_NAME = false; |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
69 |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
10000
diff
changeset
|
70 protected HotSpotMethod(String name) { |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
10000
diff
changeset
|
71 this.name = name; |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
10000
diff
changeset
|
72 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
10000
diff
changeset
|
73 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5548
diff
changeset
|
75 public final String getName() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 return name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 } |
10000
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
78 |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
79 @Override |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
80 public final String toString() { |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
81 char h = FULLY_QUALIFIED_METHOD_NAME ? 'H' : 'h'; |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
82 String suffix = this instanceof ResolvedJavaMethod ? "" : ", unresolved"; |
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
83 String fmt = String.format("HotSpotMethod<%%%c.%%n(%%p)%s>", h, suffix); |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
14616
diff
changeset
|
84 return format(fmt); |
10000
d9c14b1828fc
unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
85 } |
14616
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
13259
diff
changeset
|
86 |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
13259
diff
changeset
|
87 public void formatTo(Formatter formatter, int flags, int width, int precision) { |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
13259
diff
changeset
|
88 String base = (flags & ALTERNATE) == ALTERNATE ? getName() : toString(); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
13259
diff
changeset
|
89 formatter.format(applyFormattingFlagsAndWidth(base, flags & ~ALTERNATE, width)); |
aa7bcf1fa423
expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents:
13259
diff
changeset
|
90 } |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21565
diff
changeset
|
91 |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21565
diff
changeset
|
92 public JavaMethod asJavaMethod() { |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21565
diff
changeset
|
93 return this; |
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21565
diff
changeset
|
94 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 } |