Mercurial > hg > graal-compiler
comparison graal/GraalCompiler/src/com/sun/c1x/lir/LIRCall.java @ 2509:16b9a8b5ad39
Renamings Runtime=>GraalRuntime and Compiler=>GraalCompiler
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:50:44 +0200 |
parents | graal/Compiler/src/com/sun/c1x/lir/LIRCall.java@9ec15d6914ca |
children | a2f62de90c76 |
comparison
equal
deleted
inserted
replaced
2508:fea94949e0a2 | 2509:16b9a8b5ad39 |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.sun.c1x.lir; | |
24 | |
25 import java.util.*; | |
26 | |
27 import com.sun.cri.ci.*; | |
28 import com.sun.cri.ci.CiTargetMethod.Mark; | |
29 import com.sun.cri.ri.*; | |
30 import com.sun.cri.xir.CiXirAssembler.XirMark; | |
31 | |
32 /** | |
33 * This class represents a call instruction; either to a {@linkplain CiRuntimeCall runtime method}, | |
34 * a {@linkplain RiMethod Java method}, a native function or a global stub. | |
35 * | |
36 * @author Marcelo Cintra | |
37 */ | |
38 public class LIRCall extends LIRInstruction { | |
39 | |
40 /** | |
41 * The target of the call. This will be a {@link CiRuntimeCall}, {@link RiMethod} or {@link CiValue} | |
42 * object denoting a call to the runtime, a Java method or a native function respectively. | |
43 */ | |
44 public final Object target; | |
45 /** | |
46 * The call site needs to be marked if this is non-null. | |
47 */ | |
48 public final Map<XirMark, Mark> marks; | |
49 | |
50 private final int targetAddressIndex; | |
51 | |
52 public final List<CiValue> pointerSlots; | |
53 | |
54 | |
55 private static CiValue[] toArray(List<CiValue> arguments) { | |
56 return arguments.toArray(new CiValue[arguments.size()]); | |
57 } | |
58 | |
59 public LIRCall(LIROpcode opcode, | |
60 Object target, | |
61 CiValue result, | |
62 List<CiValue> arguments, | |
63 LIRDebugInfo info, | |
64 Map<XirMark, Mark> marks, | |
65 boolean calleeSaved, | |
66 List<CiValue> pointerSlots) { | |
67 super(opcode, result, info, !calleeSaved, 0, 0, toArray(arguments)); | |
68 this.marks = marks; | |
69 this.pointerSlots = pointerSlots; | |
70 if (opcode == LIROpcode.DirectCall) { | |
71 this.targetAddressIndex = -1; | |
72 } else { | |
73 // The last argument is the operand holding the address for the indirect call | |
74 this.targetAddressIndex = arguments.size() - 1; | |
75 } | |
76 this.target = target; | |
77 } | |
78 | |
79 /** | |
80 * Emits target assembly code for this instruction. | |
81 * | |
82 * @param masm the target assembler | |
83 */ | |
84 @Override | |
85 public void emitCode(LIRAssembler masm) { | |
86 masm.emitCall(this); | |
87 } | |
88 | |
89 /** | |
90 * Returns the receiver for this method call. | |
91 * @return the receiver | |
92 */ | |
93 public CiValue receiver() { | |
94 return operand(0); | |
95 } | |
96 | |
97 public RiMethod method() { | |
98 return (RiMethod) target; | |
99 } | |
100 | |
101 public CiRuntimeCall runtimeCall() { | |
102 return (CiRuntimeCall) target; | |
103 } | |
104 | |
105 public CiValue targetAddress() { | |
106 if (targetAddressIndex >= 0) { | |
107 return operand(targetAddressIndex); | |
108 } | |
109 return null; | |
110 } | |
111 | |
112 @Override | |
113 public String operationString(OperandFormatter operandFmt) { | |
114 StringBuilder buf = new StringBuilder(); | |
115 if (result().isLegal()) { | |
116 buf.append(operandFmt.format(result())).append(" = "); | |
117 } | |
118 String targetAddress = null; | |
119 if (code == LIROpcode.RuntimeCall) { | |
120 buf.append(target); | |
121 } else if (code != LIROpcode.DirectCall && code != LIROpcode.ConstDirectCall) { | |
122 if (targetAddressIndex >= 0) { | |
123 targetAddress = operandFmt.format(targetAddress()); | |
124 buf.append(targetAddress); | |
125 } | |
126 } | |
127 buf.append('('); | |
128 boolean first = true; | |
129 for (LIROperand operandSlot : operands) { | |
130 String operand = operandFmt.format(operandSlot.value(this)); | |
131 if (!operand.isEmpty() && !operand.equals(targetAddress)) { | |
132 if (!first) { | |
133 buf.append(", "); | |
134 } else { | |
135 first = false; | |
136 } | |
137 buf.append(operand); | |
138 } | |
139 } | |
140 buf.append(')'); | |
141 return buf.toString(); | |
142 } | |
143 } |