annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethod.java @ 16480:10c12d09a8d2

moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
author Doug Simon <doug.simon@oracle.com>
date Thu, 10 Jul 2014 22:44:38 +0200
parents aa7bcf1fa423
children 082417ac43e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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 */
5548
8872bc0eebdf Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
23 package com.oracle.graal.hotspot.meta;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
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
25 import static com.oracle.graal.debug.Debug.*;
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
26 import static java.util.FormattableFlags.*;
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
27
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
28 import java.util.*;
10000
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
29
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5321
diff changeset
30 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
31 import com.oracle.graal.hotspot.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32
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
33 public abstract class HotSpotMethod extends CompilerObject implements JavaMethod, Formattable {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
35 private static final long serialVersionUID = 7167491397941960839L;
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
36 protected String name;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37
10000
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
38 /**
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
39 * 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
40 * which the method is declared.
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
41 */
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
42 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
43
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
44 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
45 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
46 }
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
47
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 @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
49 public final String getName() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 return name;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 }
10000
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
52
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
53 @Override
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
54 public final String toString() {
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
55 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
56 String suffix = this instanceof ResolvedJavaMethod ? "" : ", unresolved";
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
57 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
58 return format(fmt);
10000
d9c14b1828fc unified toString() for HotSpot implementations of JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
59 }
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
60
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
61 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
62 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
63 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
64 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 }