annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java @ 13938:aa8fb1cb16d1

Make graph builder more extensible
author Christian Wimmer <christian.wimmer@oracle.com>
date Wed, 12 Feb 2014 10:23:41 -0800
parents af7fb87fc62e
children 9fa900dd3f96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.stubs;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
11839
0e2cceed1caf Temporarily move encodeDeoptActionAndReason to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11348
diff changeset
25 import static com.oracle.graal.api.meta.DeoptimizationAction.*;
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*;
11274
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 import static com.oracle.graal.hotspot.nodes.CStringNode.*;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import static com.oracle.graal.word.Word.*;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import java.lang.reflect.*;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import java.util.*;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34
9736
951d5ebf3c49 refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents: 9735
diff changeset
35 import com.oracle.graal.api.meta.*;
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.graph.Node.ConstantNodeParameter;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.graph.Node.NodeIntrinsic;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.hotspot.nodes.*;
11337
39e83065426e Add anchors for loadHubs in verifyObject and monitor enter.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11274
diff changeset
39 import com.oracle.graal.nodes.*;
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.replacements.*;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.replacements.Snippet.Fold;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.word.*;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 //JaCoCo Exclude
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 * A collection of methods used in {@link Stub}s.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 public class StubUtil {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50
9737
34c892fdfb6d moved responsibility for determining if a foreign call has a side effect to the runtime
Doug Simon <doug.simon@oracle.com>
parents: 9736
diff changeset
51 public static final ForeignCallDescriptor VM_MESSAGE_C = descriptorFor(StubUtil.class, "vmMessageC");
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 /**
9872
4391fd907278 use StubForeignCallNode within stubs, instead of ForeignCallNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 9746
diff changeset
54 * Looks for a {@link StubForeignCallNode} node intrinsic named {@code name} in
4391fd907278 use StubForeignCallNode within stubs, instead of ForeignCallNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 9746
diff changeset
55 * {@code stubClass} and returns a {@link ForeignCallDescriptor} based on its signature and the
4391fd907278 use StubForeignCallNode within stubs, instead of ForeignCallNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 9746
diff changeset
56 * value of {@code hasSideEffect}.
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 */
9737
34c892fdfb6d moved responsibility for determining if a foreign call has a side effect to the runtime
Doug Simon <doug.simon@oracle.com>
parents: 9736
diff changeset
58 public static ForeignCallDescriptor descriptorFor(Class<?> stubClass, String name) {
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 Method found = null;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 for (Method method : stubClass.getDeclaredMethods()) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 if (Modifier.isStatic(method.getModifiers()) && method.getAnnotation(NodeIntrinsic.class) != null && method.getName().equals(name)) {
9872
4391fd907278 use StubForeignCallNode within stubs, instead of ForeignCallNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 9746
diff changeset
62 if (method.getAnnotation(NodeIntrinsic.class).value() == StubForeignCallNode.class) {
9746
82e3c8d5c77f removed CRuntimeCall and replaced its usages with ForeignCallNode
Doug Simon <doug.simon@oracle.com>
parents: 9737
diff changeset
63 assert found == null : "found more than one foreign call named " + name + " in " + stubClass;
82e3c8d5c77f removed CRuntimeCall and replaced its usages with ForeignCallNode
Doug Simon <doug.simon@oracle.com>
parents: 9737
diff changeset
64 assert method.getParameterTypes().length != 0 && method.getParameterTypes()[0] == ForeignCallDescriptor.class : "first parameter of foreign call '" + name + "' in " + stubClass +
9735
2e4f035186cf rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
65 " must be of type " + ForeignCallDescriptor.class.getSimpleName();
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 found = method;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 }
9746
82e3c8d5c77f removed CRuntimeCall and replaced its usages with ForeignCallNode
Doug Simon <doug.simon@oracle.com>
parents: 9737
diff changeset
70 assert found != null : "could not find foreign call named " + name + " in " + stubClass;
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 List<Class<?>> paramList = Arrays.asList(found.getParameterTypes());
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72 Class[] cCallTypes = paramList.subList(1, paramList.size()).toArray(new Class[paramList.size() - 1]);
9737
34c892fdfb6d moved responsibility for determining if a foreign call has a side effect to the runtime
Doug Simon <doug.simon@oracle.com>
parents: 9736
diff changeset
73 return new ForeignCallDescriptor(name, found.getReturnType(), cCallTypes);
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75
12793
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
76 public static void handlePendingException(Word thread, boolean isObjectResult) {
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
77 if (clearPendingException(thread)) {
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 if (isObjectResult) {
12793
af7fb87fc62e pass thread register into all stubs instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
79 getAndClearObjectResult(thread);
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84
11274
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
85 /**
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
86 * Determines if this is a HotSpot build where the ASSERT mechanism is enabled.
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
87 */
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
88 @Fold
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
89 public static boolean cAssertionsEnabled() {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 11839
diff changeset
90 return runtime().getConfig().cAssertions;
11274
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
91 }
3209552fdb4e disabled check for thread local holding the exception PC being cleared in PRODUCT builds (clearing only happens in DEBUG builds)
Doug Simon <doug.simon@oracle.com>
parents: 10736
diff changeset
92
9872
4391fd907278 use StubForeignCallNode within stubs, instead of ForeignCallNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 9746
diff changeset
93 @NodeIntrinsic(StubForeignCallNode.class)
9735
2e4f035186cf rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
94 private static native void vmMessageC(@ConstantNodeParameter ForeignCallDescriptor stubPrintfC, boolean vmError, Word format, long v1, long v2, long v3);
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 * Prints a message to the log stream.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 * constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 * @param message a message string
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 public static void printf(String message) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
105 vmMessageC(VM_MESSAGE_C, false, cstring(message), 0L, 0L, 0L);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
107
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109 * Prints a message to the log stream.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
110 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
111 * <b>Stubs must use this instead of {@link Log#printf(String, long)} to avoid an object
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112 * constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 * @param format a C style printf format value
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115 * @param value the value associated with the first conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
116 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
117 public static void printf(String format, long value) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
118 vmMessageC(VM_MESSAGE_C, false, cstring(format), value, 0L, 0L);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
120
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
121 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122 * Prints a message to the log stream.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
123 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 * <b>Stubs must use this instead of {@link Log#printf(String, long, long)} to avoid an object
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 * constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127 * @param format a C style printf format value
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 * @param v1 the value associated with the first conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 * @param v2 the value associated with the second conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
130 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 public static void printf(String format, long v1, long v2) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 vmMessageC(VM_MESSAGE_C, false, cstring(format), v1, v2, 0L);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 * Prints a message to the log stream.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
138 * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 * object constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 * @param format a C style printf format value
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 * @param v1 the value associated with the first conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 * @param v2 the value associated with the second conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144 * @param v3 the value associated with the third conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
146 public static void printf(String format, long v1, long v2, long v3) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147 vmMessageC(VM_MESSAGE_C, false, cstring(format), v1, v2, v3);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 * Analyzes a given value and prints information about it to the log stream.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 public static void decipher(long value) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 vmMessageC(VM_MESSAGE_C, false, Word.zero(), value, 0L, 0L);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 * Exits the VM with a given error message.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 * <b>Stubs must use this instead of {@link VMErrorNode#vmError(String, long)} to avoid an
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 * object constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 * @param message an error message
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165 public static void fatal(String message) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166 vmMessageC(VM_MESSAGE_C, true, cstring(message), 0L, 0L, 0L);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170 * Exits the VM with a given error message.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
171 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172 * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 * object constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 * @param format a C style printf format value
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176 * @param value the value associated with the first conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
178 public static void fatal(String format, long value) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 vmMessageC(VM_MESSAGE_C, true, cstring(format), value, 0L, 0L);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183 * Exits the VM with a given error message.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
185 * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
186 * object constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
187 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188 * @param format a C style printf format value
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 * @param v1 the value associated with the first conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190 * @param v2 the value associated with the second conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
191 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
192 public static void fatal(String format, long v1, long v2) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
193 vmMessageC(VM_MESSAGE_C, true, cstring(format), v1, v2, 0L);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
197 * Exits the VM with a given error message.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
198 * <p>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 * <b>Stubs must use this instead of {@link Log#printf(String, long, long, long)} to avoid an
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
200 * object constant in a RuntimeStub.</b>
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 *
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202 * @param format a C style printf format value
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 * @param v1 the value associated with the first conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 * @param v2 the value associated with the second conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
205 * @param v3 the value associated with the third conversion specifier in {@code format}
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
206 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 public static void fatal(String format, long v1, long v2, long v3) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208 vmMessageC(VM_MESSAGE_C, true, cstring(format), v1, v2, v3);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
209 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
210
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
211 /**
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
212 * Verifies that a given object value is well formed if {@code -XX:+VerifyOops} is enabled.
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
213 */
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
214 public static Object verifyObject(Object object) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
215 if (verifyOops()) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
216 Word verifyOopCounter = Word.unsigned(verifyOopCounterAddress());
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
217 verifyOopCounter.writeInt(0, verifyOopCounter.readInt(0) + 1);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
218
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 Pointer oop = Word.fromObject(object);
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
220 if (object != null) {
11348
d46159285f97 removed Stamp parameter of BeginNode.anchor node intrinsic
Doug Simon <doug.simon@oracle.com>
parents: 11337
diff changeset
221 BeginNode anchorNode = BeginNode.anchor();
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
222 // make sure object is 'reasonable'
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
223 if (!oop.and(unsigned(verifyOopMask())).equal(unsigned(verifyOopBits()))) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
224 fatal("oop not in heap: %p", oop.rawValue());
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
225 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
226
11337
39e83065426e Add anchors for loadHubs in verifyObject and monitor enter.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11274
diff changeset
227 Word klass = loadHubIntrinsic(object, getWordKind(), anchorNode);
9618
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
228 if (klass.equal(Word.zero())) {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
229 fatal("klass for oop %p is null", oop.rawValue());
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
230 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
231 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
232 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
233 return object;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
234 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
235
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
236 @Fold
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
237 private static long verifyOopCounterAddress() {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
238 return config().verifyOopCounterAddress;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
239 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
240
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
241 @Fold
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
242 private static long verifyOopMask() {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
243 return config().verifyOopMask;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
244 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
245
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
246 @Fold
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
247 private static long verifyOopBits() {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
248 return config().verifyOopBits;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
249 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
250
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
251 @Fold
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
252 private static int hubOffset() {
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
253 return config().hubOffset;
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
254 }
bd4a7d657dcc moved static methods out of Stub into StubUtil
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
255 }