annotate graal/GraalCompiler/src/com/sun/c1x/ir/Invoke.java @ 2828:d6f3dbb4e3b5

merge
author Lukas Stadler <lukas.stadler@jku.at>
date Mon, 30 May 2011 18:47:33 +0200
parents bd17ac598c6e 9ba6a8abe894
children 27c00b180416
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1 /*
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
4 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
7 * published by the Free Software Foundation.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
8 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
13 * accompanied this code).
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
14 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
18 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
21 * questions.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
22 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
23 package com.sun.c1x.ir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
24
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
25 import com.oracle.graal.graph.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
26 import com.sun.c1x.debug.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
27 import com.sun.c1x.util.*;
2538
e1ba5a93e997 Clean up on Value class and LIRGenerator/LIRItem-related things.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2509
diff changeset
28 import com.sun.cri.bytecode.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
30 import com.sun.cri.ri.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
31
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
32 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
33 * The {@code Invoke} instruction represents all kinds of method calls.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
34 */
2715
3ac3dd97d8df Added ExceptionEdgeInstruction interface.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2707
diff changeset
35 public final class Invoke extends StateSplit implements ExceptionEdgeInstruction {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
36
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
37 private final int argumentCount;
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
38
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
39 private static final int SUCCESSOR_COUNT = 1;
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
40 private static final int SUCCESSOR_EXCEPTION_EDGE = 0;
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
41
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
42 @Override
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
43 protected int inputCount() {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
44 return super.inputCount() + argumentCount;
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
45 }
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
46
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
47 @Override
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
48 protected int successorCount() {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
49 return super.successorCount() + SUCCESSOR_COUNT;
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
50 }
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
51
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
52 /**
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
53 * The list of instructions that produce input for this instruction.
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
54 */
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
55 public Value argument(int index) {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
56 assert index >= 0 && index < argumentCount;
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
57 return (Value) inputs().get(super.inputCount() + index);
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
58 }
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
59
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
60 public Value setArgument(int index, Value n) {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
61 assert index >= 0 && index < argumentCount;
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
62 return (Value) inputs().set(super.inputCount() + index, n);
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
63 }
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
64
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
65 public int argumentCount() {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
66 return argumentCount;
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
67 }
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
68
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
69 /**
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
70 * The entry to the exception dispatch chain for this invoke.
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
71 */
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
72 @Override
2783
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2755
diff changeset
73 public Instruction exceptionEdge() {
9bc0c2eb00d6 Made graph builder removal of BlockBegin work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2755
diff changeset
74 return (Instruction) successors().get(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE);
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
75 }
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
76
2755
80b024e75b29 small fix for dead blocks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2715
diff changeset
77 public Instruction setExceptionEdge(Instruction n) {
80b024e75b29 small fix for dead blocks
Lukas Stadler <lukas.stadler@jku.at>
parents: 2715
diff changeset
78 return (Instruction) successors().set(super.successorCount() + SUCCESSOR_EXCEPTION_EDGE, n);
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
79 }
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2628
diff changeset
80
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
81 public final int opcode;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
82 public final RiMethod target;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
83 public final RiType returnType;
2825
9ba6a8abe894 Fix Invoke bci problem
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2783
diff changeset
84 public final int bci; // XXX needed because we can not compute the bci from the sateBefore bci of this Invoke was optimized from INVOKEINTERFACE to INVOKESPECIAL
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
85
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
86 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
87 * Constructs a new Invoke instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
88 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
89 * @param opcode the opcode of the invoke
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
90 * @param result the result type
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
91 * @param args the list of instructions producing arguments to the invocation, including the receiver object
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
92 * @param isStatic {@code true} if this call is static (no receiver object)
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
93 * @param target the target method being called
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
94 * @param stateBefore the state before executing the invocation
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
95 */
2825
9ba6a8abe894 Fix Invoke bci problem
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2783
diff changeset
96 public Invoke(int opcode, CiKind result, Value[] args, RiMethod target, RiType returnType, Graph graph, int bci) {
2628
569228710be8 More FrameState work
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2622
diff changeset
97 super(result, args.length, SUCCESSOR_COUNT, graph);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
98 this.opcode = opcode;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
99 this.target = target;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
100 this.returnType = returnType;
2825
9ba6a8abe894 Fix Invoke bci problem
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2783
diff changeset
101 this.bci = bci;
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
102
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
103 this.argumentCount = args.length;
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
104 for (int i = 0; i < args.length; i++) {
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
105 setArgument(i, args[i]);
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
106 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
108
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
109 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
110 * Gets the opcode of this invoke instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
111 * @return the opcode
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
112 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
113 public int opcode() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
114 return opcode;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
115 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
116
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
117 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
118 * Checks whether this is an invocation of a static method.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
119 * @return {@code true} if the invocation is a static invocation
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
120 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
121 public boolean isStatic() {
2538
e1ba5a93e997 Clean up on Value class and LIRGenerator/LIRItem-related things.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2509
diff changeset
122 return opcode == Bytecodes.INVOKESTATIC;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
123 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
124
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
125 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
126 public RiType declaredType() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
127 return returnType;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
128 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
129
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
130 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
131 * Gets the instruction that produces the receiver object for this invocation, if any.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
132 * @return the instruction that produces the receiver object for this invocation if any, {@code null} if this
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
133 * invocation does not take a receiver object
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
134 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
135 public Value receiver() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
136 assert !isStatic();
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
137 return argument(0);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
138 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
139
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
140 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
141 * Gets the target method for this invocation instruction.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
142 * @return the target method
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
143 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
144 public RiMethod target() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
145 return target;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
146 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
147
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
148 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
149 * Checks whether this invocation has a receiver object.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
150 * @return {@code true} if this invocation has a receiver object; {@code false} otherwise, if this is a
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
151 * static call
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
152 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
153 public boolean hasReceiver() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
154 return !isStatic();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
155 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
156
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
157 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
158 public void accept(ValueVisitor v) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
159 v.visitInvoke(this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
160 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
161
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
162 public CiKind[] signature() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
163 CiKind receiver = isStatic() ? null : target.holder().kind();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
164 return Util.signatureToKinds(target.signature(), receiver);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
165 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
166
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
167 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
168 public void print(LogStream out) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
169 int argStart = 0;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
170 if (hasReceiver()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
171 out.print(receiver()).print('.');
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
172 argStart = 1;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
173 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
174
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
175 RiMethod target = target();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
176 out.print(target.name()).print('(');
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
177 for (int i = argStart; i < argumentCount; i++) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
178 if (i > argStart) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
179 out.print(", ");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
180 }
2596
1c36b17f7ee0 new node layout: AccessMonitor, Invoke
Lukas Stadler <lukas.stadler@jku.at>
parents: 2543
diff changeset
181 out.print(argument(i));
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
182 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
183 out.print(CiUtil.format(") [method: %H.%n(%p):%r]", target, false));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
184 }
2827
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2783
diff changeset
185
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2783
diff changeset
186 @Override
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2783
diff changeset
187 public Node copy(Graph into) {
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2783
diff changeset
188 Invoke x = new Invoke(opcode, kind, new Value[argumentCount], target, returnType, into);
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2783
diff changeset
189 x.setNonNull(isNonNull());
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2783
diff changeset
190 return x;
bd17ac598c6e Graph cloning, initial version (not completely working)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2783
diff changeset
191 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
192 }