comparison graal/Compiler/src/com/sun/c1x/ir/TemplateCall.java @ 2507:9ec15d6914ca

Pull over of compiler from maxine repository.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 11:43:22 +0200
parents
children
comparison
equal deleted inserted replaced
2506:4a3bf8a5bf41 2507:9ec15d6914ca
1 /*
2 * Copyright (c) 2010, 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.ir;
24
25 import com.sun.c1x.debug.*;
26 import com.sun.cri.bytecode.*;
27 import com.sun.cri.ci.*;
28
29 /**
30 * Represents a {@linkplain Bytecodes#TEMPLATE_CALL template call}.
31 *
32 * @author Doug Simon
33 */
34 public final class TemplateCall extends Instruction {
35
36 /**
37 * The address to call (null implies a direct call that will be patched).
38 */
39 private Value address;
40
41 private Value receiver;
42
43 public TemplateCall(CiKind returnKind, Value address, Value receiver) {
44 super(returnKind.stackKind());
45 this.address = address;
46 this.receiver = receiver;
47 setFlag(Flag.LiveSideEffect); // ensure this instruction is not eliminated
48 }
49
50 @Override
51 public boolean canTrap() {
52 return true;
53 }
54
55 public Value address() {
56 return address;
57 }
58
59 public Value receiver() {
60 return receiver;
61 }
62
63 @Override
64 public void inputValuesDo(ValueClosure closure) {
65 if (address != null) {
66 address = closure.apply(address);
67 }
68 if (receiver != null) {
69 receiver = closure.apply(receiver);
70 }
71 }
72
73 @Override
74 public void accept(ValueVisitor v) {
75 v.visitTemplateCall(this);
76 }
77
78 @Override
79 public void print(LogStream out) {
80 out.print("template_call").print('(');
81 if (address != null) {
82 out.print(address);
83 if (receiver != null) {
84 out.print(", ").print(receiver);
85 }
86 } else if (receiver != null) {
87 out.print(receiver);
88 out.print(')');
89 }
90 }
91 }