Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/RuntimeCallStub.java @ 9735:2e4f035186cf
rename: Descriptor -> ForeignCallDescriptor
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 16 May 2013 16:01:40 +0200 |
parents | f7bd4594cbbf |
children | 951d5ebf3c49 |
rev | line source |
---|---|
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.stubs; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
9693
d04944441454
cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
25 import static com.oracle.graal.api.code.CallingConvention.Type.*; |
9659
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
26 import static com.oracle.graal.api.meta.MetaUtil.*; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
9693
d04944441454
cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
28 import static com.oracle.graal.hotspot.HotSpotRuntimeCallTarget.RegisterEffect.*; |
9731
f7bd4594cbbf
added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents:
9694
diff
changeset
|
29 import static com.oracle.graal.hotspot.HotSpotRuntimeCallTarget.Transition.*; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
31 import java.lang.reflect.*; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.api.code.*; |
9735
2e4f035186cf
rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9731
diff
changeset
|
34 import com.oracle.graal.api.code.RuntimeCallTarget.ForeignCallDescriptor; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.api.meta.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.debug.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.hotspot.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.hotspot.meta.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.graal.hotspot.nodes.*; |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
40 import com.oracle.graal.hotspot.replacements.*; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 import com.oracle.graal.nodes.*; |
9690
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
42 import com.oracle.graal.nodes.calc.*; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 import com.oracle.graal.nodes.java.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 import com.oracle.graal.nodes.spi.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 import com.oracle.graal.nodes.type.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 import com.oracle.graal.phases.common.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 import com.oracle.graal.replacements.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 import com.oracle.graal.replacements.nodes.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 import com.oracle.graal.word.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 import com.oracle.graal.word.phases.*; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 /** |
9675
a54720257b76
replaced MonitorEnterStub and MonitorExitStub with use of RuntimeCallStub
Doug Simon <doug.simon@oracle.com>
parents:
9673
diff
changeset
|
54 * A stub that calls into a HotSpot C/C++ runtime function using the native |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 * {@link CallingConvention}. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 */ |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 public class RuntimeCallStub extends Stub { |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 /** |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 * The target of the call. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 */ |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 private final HotSpotRuntimeCallTarget target; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 /** |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 * Specifies if the JavaThread value for the current thread is to be prepended to the arguments |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 * for the call to {@link #target}. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 */ |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 protected final boolean prependThread; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 /** |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 * Creates a stub for a call to code at a given address. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 * |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 * @param address the address of the code to call |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 * @param sig the signature of the call to this stub |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 * @param prependThread true if the JavaThread value for the current thread is to be prepended |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 * to the arguments for the call to {@code address} |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 */ |
9735
2e4f035186cf
rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9731
diff
changeset
|
78 public RuntimeCallStub(long address, ForeignCallDescriptor sig, boolean prependThread, HotSpotRuntime runtime, Replacements replacements) { |
9731
f7bd4594cbbf
added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents:
9694
diff
changeset
|
79 super(runtime, replacements, HotSpotRuntimeCallTarget.create(sig, 0L, PRESERVES_REGISTERS, JavaCallee, NOT_LEAF)); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 this.prependThread = prependThread; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 Class[] targetParameterTypes = createTargetParameters(sig); |
9735
2e4f035186cf
rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9731
diff
changeset
|
82 ForeignCallDescriptor targetSig = new ForeignCallDescriptor(sig.getName() + ":C", sig.hasSideEffect(), sig.getResultType(), targetParameterTypes); |
9731
f7bd4594cbbf
added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents:
9694
diff
changeset
|
83 target = HotSpotRuntimeCallTarget.create(targetSig, address, DESTROYS_REGISTERS, NativeCall, NOT_LEAF); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 /** |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 * Gets the linkage information for the runtime call. |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 */ |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 public HotSpotRuntimeCallTarget getTargetLinkage() { |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 return target; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 |
9735
2e4f035186cf
rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9731
diff
changeset
|
93 private Class[] createTargetParameters(ForeignCallDescriptor sig) { |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 Class[] parameters = sig.getArgumentTypes(); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 if (prependThread) { |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 Class[] newParameters = new Class[parameters.length + 1]; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 System.arraycopy(parameters, 0, newParameters, 1, parameters.length); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 newParameters[0] = Word.class; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 return newParameters; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 return parameters; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 @Override |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 protected ResolvedJavaMethod getInstalledCodeOwner() { |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 return null; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 @Override |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 protected Object debugScopeContext() { |
9659
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
111 return new JavaMethod() { |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
112 |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
113 public Signature getSignature() { |
9735
2e4f035186cf
rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9731
diff
changeset
|
114 ForeignCallDescriptor d = linkage.getDescriptor(); |
9659
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
115 Class<?>[] arguments = d.getArgumentTypes(); |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
116 JavaType[] parameters = new JavaType[arguments.length]; |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
117 for (int i = 0; i < arguments.length; i++) { |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
118 parameters[i] = runtime.lookupJavaType(arguments[i]); |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
119 } |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
120 return new HotSpotSignature(runtime.lookupJavaType(d.getResultType()), parameters); |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
121 } |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
122 |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
123 public String getName() { |
9693
d04944441454
cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
124 return linkage.getDescriptor().getName(); |
9659
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
125 } |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
126 |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
127 public JavaType getDeclaringClass() { |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
128 return runtime.lookupJavaType(RuntimeCallStub.class); |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
129 } |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
130 |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
131 @Override |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
132 public String toString() { |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
133 return format("HotSpotStub<%n(%p)>", this); |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
134 } |
c5b1b4dcc094
create fake JavaMethod for non-snippet stubs so that -G:MethodFilter can be applied to them
Doug Simon <doug.simon@oracle.com>
parents:
9655
diff
changeset
|
135 }; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
138 static class GraphBuilder { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
139 |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
140 public GraphBuilder(Stub stub) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
141 this.graph = new StructuredGraph(stub.toString(), null); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
142 graph.replaceFixed(graph.start(), graph.add(new StubStartNode(stub))); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
143 this.lastFixedNode = graph.start(); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
144 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
145 |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
146 final StructuredGraph graph; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
147 private FixedWithNextNode lastFixedNode; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
148 |
9690
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
149 <T extends FloatingNode> T add(T node) { |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
150 return graph.unique(node); |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
151 } |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
152 |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
153 <T extends FixedNode> T append(T node) { |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
154 T result = graph.add(node); |
9690
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
155 assert lastFixedNode != null; |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
156 assert result.predecessor() == null; |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
157 graph.addAfterFixed(lastFixedNode, result); |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
158 if (result instanceof FixedWithNextNode) { |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
159 lastFixedNode = (FixedWithNextNode) result; |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
160 } else { |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
161 lastFixedNode = null; |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
162 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
163 return result; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
164 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
165 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
166 |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 @Override |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 protected StructuredGraph getGraph() { |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 Class<?>[] args = linkage.getDescriptor().getArgumentTypes(); |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
170 boolean isObjectResult = linkage.getCallingConvention().getReturn().getKind() == Kind.Object; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
171 GraphBuilder builder = new GraphBuilder(this); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
172 LocalNode[] locals = createLocals(builder, args); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
173 |
9690
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
174 ReadRegisterNode thread = prependThread || isObjectResult ? builder.append(new ReadRegisterNode(runtime.threadRegister(), true, false)) : null; |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
175 ValueNode result = createTargetCall(builder, locals, thread); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
176 createInvoke(builder, StubUtil.class, "handlePendingException", ConstantNode.forBoolean(isObjectResult, builder.graph)); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
177 if (isObjectResult) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
178 InvokeNode object = createInvoke(builder, HotSpotReplacementsUtil.class, "getAndClearObjectResult", thread); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
179 result = createInvoke(builder, StubUtil.class, "verifyObject", object); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
180 } |
9694 | 181 builder.append(new ReturnNode(linkage.getDescriptor().getResultType() == void.class ? null : result)); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
182 |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
183 if (Debug.isDumpEnabled()) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
184 Debug.dump(builder.graph, "Initial stub graph"); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
185 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
186 |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
187 for (InvokeNode invoke : builder.graph.getNodes(InvokeNode.class).snapshot()) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
188 inline(invoke); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
189 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
190 assert builder.graph.getNodes(InvokeNode.class).isEmpty(); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
191 |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
192 if (Debug.isDumpEnabled()) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
193 Debug.dump(builder.graph, "Stub graph before compilation"); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
194 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
195 |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
196 return builder.graph; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
197 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
198 |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
199 private LocalNode[] createLocals(GraphBuilder builder, Class<?>[] args) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
200 LocalNode[] locals = new LocalNode[args.length]; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 ResolvedJavaType accessingClass = runtime.lookupJavaType(getClass()); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 for (int i = 0; i < args.length; i++) { |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
203 ResolvedJavaType type = runtime.lookupJavaType(args[i]).resolve(accessingClass); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 Kind kind = type.getKind().getStackKind(); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 Stamp stamp; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
206 if (kind == Kind.Object) { |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
207 stamp = StampFactory.declared(type); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
208 } else { |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 stamp = StampFactory.forKind(kind); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
210 } |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
211 LocalNode local = builder.add(new LocalNode(i, stamp)); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
212 locals[i] = local; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 } |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
214 return locals; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
216 |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
217 private InvokeNode createInvoke(GraphBuilder builder, Class<?> declaringClass, String name, ValueNode... hpeArgs) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
218 ResolvedJavaMethod method = null; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
219 for (Method m : declaringClass.getDeclaredMethods()) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
220 if (Modifier.isStatic(m.getModifiers()) && m.getName().equals(name)) { |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
221 assert method == null : "found more than one method in " + declaringClass + " named " + name; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
222 method = runtime.lookupJavaMethod(m); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
223 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
224 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
225 assert method != null : "did not find method in " + declaringClass + " named " + name; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
226 JavaType returnType = method.getSignature().getReturnType(null); |
9690
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
227 MethodCallTargetNode callTarget = builder.graph.add(new MethodCallTargetNode(InvokeKind.Static, method, hpeArgs, returnType)); |
a7f10828c4ff
distinguish floating and fixed nodes when building a stub graph
Doug Simon <doug.simon@oracle.com>
parents:
9675
diff
changeset
|
228 InvokeNode invoke = builder.append(new InvokeNode(callTarget, FrameState.UNKNOWN_BCI)); |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
229 return invoke; |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
230 } |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
231 |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
232 private CRuntimeCall createTargetCall(GraphBuilder builder, LocalNode[] locals, ReadRegisterNode thread) { |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
233 if (prependThread) { |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
234 ValueNode[] targetArguments = new ValueNode[1 + locals.length]; |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
235 targetArguments[0] = thread; |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
236 System.arraycopy(locals, 0, targetArguments, 1, locals.length); |
9694 | 237 return builder.append(new CRuntimeCall(target.getDescriptor(), targetArguments)); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 } else { |
9694 | 239 return builder.append(new CRuntimeCall(target.getDescriptor(), locals)); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
240 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
241 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
242 |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
243 private void inline(InvokeNode invoke) { |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
244 StructuredGraph graph = invoke.graph(); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
245 ResolvedJavaMethod method = ((MethodCallTargetNode) invoke.callTarget()).targetMethod(); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
246 ReplacementsImpl repl = new ReplacementsImpl(runtime, new Assumptions(false), runtime.getTarget()); |
9673
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
247 StructuredGraph calleeGraph = repl.makeGraph(method, null, null); |
37ec49e1d7e2
extended RuntimeCallStub to support calls returning an Object
Doug Simon <doug.simon@oracle.com>
parents:
9659
diff
changeset
|
248 InliningUtil.inline(invoke, calleeGraph, false); |
9655
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
249 new NodeIntrinsificationPhase(runtime).apply(graph); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
250 new WordTypeRewriterPhase(runtime, wordKind()).apply(graph); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
251 new DeadCodeEliminationPhase().apply(graph); |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
252 } |
0a771345825b
added RuntimeCallStub for runtime calls that require no extra/special logic in the stub itself
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
253 } |