Mercurial > hg > graal-compiler
annotate graal/com.oracle.max.graal.hotspot/src/com/oracle/graal/hotspot/target/amd64/AMD64TailcallOp.java @ 5060:4ed4295ce15f
Update import statements.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 08 Mar 2012 19:11:12 +0100 |
parents | ed559a528128 |
children |
rev | line source |
---|---|
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
1 /* |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
4 * |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
8 * |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
14 * |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
18 * |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
21 * questions. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.hotspot.target.amd64; |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
24 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
25 import static com.oracle.max.cri.ci.CiValueUtil.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
26 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
27 import java.util.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
28 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
29 import com.oracle.max.asm.target.amd64.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
30 import com.oracle.max.cri.ci.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.lir.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.lir.amd64.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.lir.asm.*; |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
35 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
36 /** |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
37 * Performs a hard-coded tail call to the specified target, which normally should be an RiCompiledCode instance. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
38 */ |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
39 public class AMD64TailcallOp extends AMD64LIRInstruction { |
4408
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
40 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
41 public AMD64TailcallOp(List<CiValue> parameters, CiValue target, CiValue[] callingConvention) { |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
42 super("TAILCALL", LIRInstruction.NO_OPERANDS, null, toArray(parameters, target), LIRInstruction.NO_OPERANDS, callingConvention.clone()); |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
43 assert inputs.length == temps.length + 1; |
4408
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
44 |
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
45 for (int i = 0; i < temps.length; i++) { |
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
46 assert isRegister(temps[i]) : "too many parameters for tail call"; |
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
47 assert sameRegister(temps[i], inputs[i]) : "inputs do not match calling convention"; |
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
48 } |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
49 } |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
50 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
51 private static CiValue[] toArray(List<CiValue> parameters, CiValue target) { |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
52 CiValue[] result = new CiValue[parameters.size() + 1]; |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
53 parameters.toArray(result); |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
54 result[parameters.size()] = target; |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
55 return result; |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
56 } |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
57 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
58 @Override |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
59 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
60 // destroy the current frame (now the return address is the top of stack) |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
61 masm.leave(); |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
62 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
63 // jump to the target method |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
64 masm.jmp(asRegister(inputs[inputs.length - 1])); |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
65 masm.ensureUniquePC(); |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
66 } |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
67 |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
68 @Override |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
69 protected EnumSet<OperandFlag> flagsFor(OperandMode mode, int index) { |
4408
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
70 if (mode == OperandMode.Input) { |
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
71 return EnumSet.of(OperandFlag.Register); |
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
72 } else if (mode == OperandMode.Temp) { |
b197bbb58d2f
Fix and improve tail call.
Andreas Woess <andreas.woess@jku.at>
parents:
4323
diff
changeset
|
73 return EnumSet.of(OperandFlag.Register); |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
74 } |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4408
diff
changeset
|
75 throw GraalInternalError.shouldNotReachHere(); |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
76 } |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
77 } |