Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/TailcallNode.java @ 4323:df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
author | Christian Wimmer <Christian.Wimmer@Oracle.com> |
---|---|
date | Wed, 25 Jan 2012 14:34:53 -0800 |
parents | 3c21eee8ab4d |
children | b197bbb58d2f |
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, 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 */ |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
23 package com.oracle.max.graal.hotspot.nodes; |
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 java.lang.reflect.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
26 import java.util.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
27 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
28 import com.oracle.max.cri.ci.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
29 import com.oracle.max.cri.ri.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
30 import com.oracle.max.graal.compiler.gen.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
31 import com.oracle.max.graal.hotspot.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
32 import com.oracle.max.graal.hotspot.target.amd64.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
33 import com.oracle.max.graal.nodes.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
34 import com.oracle.max.graal.nodes.spi.*; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
35 import com.oracle.max.graal.nodes.type.*; |
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 /** |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
38 * Performs a tail call to the specified target compiled method, with the parameter taken from the supplied FrameState. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
39 */ |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
40 public class TailcallNode extends FixedWithNextNode implements LIRLowerable { |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
41 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
42 @Input private final FrameState frameState; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
43 @Input private final ValueNode target; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
44 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
45 /** |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
46 * Creates a TailcallNode. |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
47 * @param target points to the start of an nmethod |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
48 * @param frameState the parameters will be taken from this FrameState |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
49 */ |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
50 public TailcallNode(ValueNode target, FrameState frameState) { |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
51 super(StampFactory.illegal()); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
52 this.target = target; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
53 this.frameState = frameState; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
54 } |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
55 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
56 @Override |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
57 public void generate(LIRGeneratorTool generator) { |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
58 LIRGenerator gen = (LIRGenerator) generator; |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
59 HotSpotVMConfig config = CompilerImpl.getInstance().getConfig(); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
60 RiResolvedMethod method = frameState.method(); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
61 boolean isStatic = Modifier.isStatic(method.accessFlags()); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
62 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
63 CiKind[] signature = CiUtil.signatureToKinds(method.signature(), isStatic ? null : method.holder().kind(true)); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
64 CiCallingConvention cc = gen.frameMap().registerConfig.getCallingConvention(CiCallingConvention.Type.JavaCall, signature, gen.target(), false); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
65 gen.frameMap().callsMethod(cc, CiCallingConvention.Type.JavaCall); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
66 List<ValueNode> parameters = new ArrayList<>(); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
67 for (int i = 0; i < cc.locations.length; i++) { |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
68 parameters.add(frameState.localAt(i)); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
69 } |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
70 List<CiValue> argList = gen.visitInvokeArguments(cc, parameters, null); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
71 |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
72 CiValue entry = gen.emitLoad(new CiAddress(CiKind.Long, gen.operand(target), config.nmethodEntryOffset), false); |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
73 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4319
diff
changeset
|
74 gen.append(new AMD64TailcallOp(argList, entry, cc.locations)); |
4319
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
75 } |
3c21eee8ab4d
Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
76 } |