Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/ForeignCallDescriptor.java @ 21594:cc9e15bbbd3c
SSAMoveResolver: add support for non-virtual stack slots.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Fri, 29 May 2015 12:08:54 +0200 |
parents | 48c1ebd24120 |
children |
rev | line source |
---|---|
9736
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
15040
diff
changeset
|
23 package com.oracle.jvmci.meta; |
9736
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 /** |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 * The name and signature of a foreign call. A foreign call differs from a normal compiled Java call |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 * in at least one of these aspects: |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 * <ul> |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 * <li>The call is to C/C++/assembler code.</li> |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 * <li>The call uses different conventions for passing parameters or returning values.</li> |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 * <li>The callee has different register saving semantics. For example, the callee may save all |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 * registers (apart from some specified temporaries) in which case the register allocator doesn't |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 * not need to spill all live registers around the call site.</li> |
9777
05b719a4ae09
expanded documentation for ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9737
diff
changeset
|
36 * <li>The call does not occur at an INVOKE* bytecode. Such a call could be transformed into a |
05b719a4ae09
expanded documentation for ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9737
diff
changeset
|
37 * standard Java call if the foreign routine is a normal Java method and the runtime supports |
05b719a4ae09
expanded documentation for ForeignCallDescriptor
Doug Simon <doug.simon@oracle.com>
parents:
9737
diff
changeset
|
38 * linking Java calls at arbitrary bytecodes.</li> |
9736
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 * </ul> |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 */ |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 public class ForeignCallDescriptor { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 private final String name; |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
9777
diff
changeset
|
44 private final Class<?> resultType; |
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
9777
diff
changeset
|
45 private final Class<?>[] argumentTypes; |
9736
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
9777
diff
changeset
|
47 public ForeignCallDescriptor(String name, Class<?> resultType, Class<?>... argumentTypes) { |
9736
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 this.name = name; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 this.resultType = resultType; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 this.argumentTypes = argumentTypes; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 /** |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 * Gets the name of this foreign call. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 */ |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 public String getName() { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 return name; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 /** |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 * Gets the return type of this foreign call. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 */ |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 public Class<?> getResultType() { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 return resultType; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 /** |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 * Gets the argument types of this foreign call. |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 */ |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 public Class<?>[] getArgumentTypes() { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 return argumentTypes.clone(); |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 @Override |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 public int hashCode() { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 return name.hashCode(); |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 @Override |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 public boolean equals(Object obj) { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 if (obj instanceof ForeignCallDescriptor) { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 ForeignCallDescriptor other = (ForeignCallDescriptor) obj; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 return other.name.equals(name) && other.resultType.equals(resultType) && Arrays.equals(other.argumentTypes, argumentTypes); |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 return false; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 @Override |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 public String toString() { |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 StringBuilder sb = new StringBuilder(name).append('('); |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 String sep = ""; |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
9777
diff
changeset
|
92 for (Class<?> arg : argumentTypes) { |
9736
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 sb.append(sep).append(arg.getSimpleName()); |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 sep = ","; |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 return sb.append(')').append(resultType.getSimpleName()).toString(); |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 } |
951d5ebf3c49
refactored ForeignCallDescriptor into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 } |