annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.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 4cd4926ec683
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot;
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
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: 9617
diff changeset
25 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
26 import static com.oracle.graal.hotspot.HotSpotRuntimeCallTarget.RegisterEffect.*;
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
27
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
28 import java.util.*;
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
29
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.api.code.*;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
31 import com.oracle.graal.api.code.CallingConvention.Type;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
32 import com.oracle.graal.api.meta.*;
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 7814
diff changeset
33 import com.oracle.graal.compiler.target.*;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
34 import com.oracle.graal.hotspot.meta.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
35 import com.oracle.graal.hotspot.stubs.*;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
36 import com.oracle.graal.word.*;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 /**
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 * The details required to link a HotSpot runtime or stub call.
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 */
7814
bab2a51f8dbe Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7144
diff changeset
41 public class HotSpotRuntimeCallTarget implements RuntimeCallTarget, InvokeTarget {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 /**
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
44 * Constants for specifying whether a call destroys or preserves registers. A call will always
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
45 * destroy {@link HotSpotRuntimeCallTarget#getCallingConvention() its}
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
46 * {@linkplain CallingConvention#getTemporaries() temporary} registers.
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
47 */
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
48 public enum RegisterEffect {
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
49 DESTROYS_REGISTERS, PRESERVES_REGISTERS
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
50 }
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
51
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
52 /**
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
53 * Constants for specifying whether a call is a leaf or not. A leaf function does not lock, GC
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
54 * or throw exceptions. That is, the thread's execution state during the call is never inspected
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
55 * by another thread.
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
56 */
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
57 public enum Transition {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
58 LEAF, NOT_LEAF;
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
59 }
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
60
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
61 /**
9562
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9491
diff changeset
62 * Sentinel marker for a computed jump address.
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9491
diff changeset
63 */
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9491
diff changeset
64 public static final long JUMP_ADDRESS = 0xDEADDEADBEEFBEEFL;
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9491
diff changeset
65
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9491
diff changeset
66 /**
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
67 * The descriptor of the call.
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 */
9735
2e4f035186cf rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents: 9731
diff changeset
69 private final ForeignCallDescriptor descriptor;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 /**
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
72 * The entry point address of this call's target.
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73 */
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
74 private long address;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
75
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
76 /**
9352
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9296
diff changeset
77 * Non-null (eventually) iff this is a call to a compiled {@linkplain Stub stub}.
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
78 */
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
79 private Stub stub;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 /**
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
82 * The calling convention for this call.
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 */
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
84 private CallingConvention cc;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
86 private final RegisterEffect effect;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
88 private final Transition transition;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
89
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
90 /**
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
91 * Creates a {@link HotSpotRuntimeCallTarget}.
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
92 *
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
93 * @param descriptor the descriptor of the call
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
94 * @param address the address of the code to call
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
95 * @param effect specifies if the call destroys or preserves all registers (apart from
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
96 * temporaries which are always destroyed)
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
97 * @param ccType calling convention type
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
98 * @param transition specifies if this is a {@linkplain #isLeaf() leaf} call
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
99 */
9735
2e4f035186cf rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents: 9731
diff changeset
100 public static HotSpotRuntimeCallTarget create(ForeignCallDescriptor descriptor, long address, RegisterEffect effect, Type ccType, Transition transition) {
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
101 CallingConvention targetCc = createCallingConvention(descriptor, ccType);
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
102 return new HotSpotRuntimeCallTarget(descriptor, address, effect, transition, targetCc);
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
103 }
9418
8d3a7fb9eb5f moved binding of parameter locations to runtime call descriptors from platform specific code to shared code for stubs that are now compiled stubs
Doug Simon <doug.simon@oracle.com>
parents: 9355
diff changeset
104
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
105 /**
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
106 * Gets a calling convention for a given descriptor and call type.
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
107 */
9735
2e4f035186cf rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents: 9731
diff changeset
108 public static CallingConvention createCallingConvention(ForeignCallDescriptor descriptor, Type ccType) {
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
109 HotSpotRuntime runtime = graalRuntime().getRuntime();
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
110 Class<?>[] argumentTypes = descriptor.getArgumentTypes();
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
111 JavaType[] parameterTypes = new JavaType[argumentTypes.length];
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
112 for (int i = 0; i < parameterTypes.length; ++i) {
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
113 parameterTypes[i] = asJavaType(argumentTypes[i], runtime);
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
114 }
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
115 TargetDescription target = graalRuntime().getTarget();
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
116 JavaType returnType = asJavaType(descriptor.getResultType(), runtime);
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
117 return runtime.lookupRegisterConfig().getCallingConvention(ccType, returnType, parameterTypes, target, false);
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
118 }
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
119
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
120 private static JavaType asJavaType(Class type, HotSpotRuntime runtime) {
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
121 if (WordBase.class.isAssignableFrom(type)) {
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
122 return runtime.lookupJavaType(wordKind().toJavaClass());
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
123 } else {
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
124 return runtime.lookupJavaType(type);
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
125 }
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
126 }
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
127
9735
2e4f035186cf rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents: 9731
diff changeset
128 public HotSpotRuntimeCallTarget(ForeignCallDescriptor descriptor, long address, RegisterEffect effect, Transition transition, CallingConvention cc) {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 this.address = address;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
130 this.effect = effect;
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
131 this.transition = transition;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132 this.descriptor = descriptor;
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
133 this.cc = cc;
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 }
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 @Override
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 public String toString() {
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9562
diff changeset
138 return (stub == null ? descriptor.toString() : stub) + "@0x" + Long.toHexString(address) + ":" + cc;
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
139 }
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
140
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
141 public CallingConvention getCallingConvention() {
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 return cc;
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 }
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
144
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
145 public long getMaxCallTargetOffset() {
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
146 return graalRuntime().getCompilerToVM().getMaxCallTargetOffset(address);
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
147 }
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148
9735
2e4f035186cf rename: Descriptor -> ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents: 9731
diff changeset
149 public ForeignCallDescriptor getDescriptor() {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 return descriptor;
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
151 }
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
152
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
153 public void setCompiledStub(Stub stub) {
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 7814
diff changeset
154 assert address == 0L : "cannot set stub for linkage that already has an address: " + this;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
155 this.stub = stub;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
156 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
157
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
158 /**
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
159 * Determines if this is a call to a compiled {@linkplain Stub stub}.
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
160 */
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
161 public boolean isCompiledStub() {
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
162 return address == 0L || stub != null;
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
163 }
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
164
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 7814
diff changeset
165 public void finalizeAddress(Backend backend) {
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 7814
diff changeset
166 if (address == 0) {
9418
8d3a7fb9eb5f moved binding of parameter locations to runtime call descriptors from platform specific code to shared code for stubs that are now compiled stubs
Doug Simon <doug.simon@oracle.com>
parents: 9355
diff changeset
167 assert stub != null : "linkage without an address must be a stub - forgot to register a Stub associated with " + descriptor + "?";
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
168 InstalledCode code = stub.getCode(backend);
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
169
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9454
diff changeset
170 Set<Register> destroyedRegisters = stub.getDestroyedRegisters();
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9454
diff changeset
171 AllocatableValue[] temporaryLocations = new AllocatableValue[destroyedRegisters.size()];
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
172 int i = 0;
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9454
diff changeset
173 for (Register reg : destroyedRegisters) {
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
174 temporaryLocations[i++] = reg.asValue();
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
175 }
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
176 // Update calling convention with temporaries
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
177 cc = new CallingConvention(temporaryLocations, cc.getStackSize(), cc.getReturn(), cc.getArguments());
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 8969
diff changeset
178 address = code.getStart();
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 7814
diff changeset
179 }
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents: 6534
diff changeset
180 }
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8627
diff changeset
181
9452
c1ba734c1ea0 more extensive checking of compiled stub invariants
Doug Simon <doug.simon@oracle.com>
parents: 9418
diff changeset
182 public long getAddress() {
c1ba734c1ea0 more extensive checking of compiled stub invariants
Doug Simon <doug.simon@oracle.com>
parents: 9418
diff changeset
183 assert address != 0L : "address not yet finalized: " + this;
c1ba734c1ea0 more extensive checking of compiled stub invariants
Doug Simon <doug.simon@oracle.com>
parents: 9418
diff changeset
184 return address;
c1ba734c1ea0 more extensive checking of compiled stub invariants
Doug Simon <doug.simon@oracle.com>
parents: 9418
diff changeset
185 }
c1ba734c1ea0 more extensive checking of compiled stub invariants
Doug Simon <doug.simon@oracle.com>
parents: 9418
diff changeset
186
8969
1fa6536416db Runtime calls that do not destroy the caller's registers need no spilling at the call site.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8627
diff changeset
187 @Override
9454
85a836bcd796 renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
Doug Simon <doug.simon@oracle.com>
parents: 9452
diff changeset
188 public boolean destroysRegisters() {
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9617
diff changeset
189 return effect == DESTROYS_REGISTERS;
9352
d4684b468e93 made NewInstanceStub a RuntimeStub that directly calls the C runtime (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9296
diff changeset
190 }
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
191
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
192 /**
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
193 * Determines if this is call to a function that does not lock, GC or throw exceptions. That is,
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
194 * the thread's execution state during the call is never inspected by another thread.
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
195 */
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
196 public boolean isLeaf() {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
197 return transition == Transition.LEAF;
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
198 }
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 }