comparison graal/GraalCompiler/src/com/sun/c1x/ir/NativeCall.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/ir/NativeCall.java@9ec15d6914ca
children
comparison
equal deleted inserted replaced
2508:fea94949e0a2 2509:16b9a8b5ad39
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.c1x.value.*;
27 import com.sun.cri.ri.*;
28
29 /**
30 * Represents a call to a native function from within a native method stub.
31 *
32 * @author Doug Simon
33 */
34 public final class NativeCall extends StateSplit {
35
36 /**
37 * The instruction that produces the native function address for this native call.
38 */
39 private Value address;
40
41 /**
42 * The native method for this native call.
43 */
44 public final RiMethod nativeMethod;
45
46 /**
47 * The signature of the call which is derived from {@link #nativeMethod} but is not
48 * the same as its {@linkplain RiMethod#signature() signature}.
49 */
50 public final RiSignature signature;
51
52 /**
53 * The list of instructions that produce the arguments for this native call.
54 */
55 public final Value[] arguments;
56
57 /**
58 * Constructs a new NativeCall instruction.
59 *
60 * @param nativeMethod TODO
61 * @param signature TODO
62 * @param address TODO
63 * @param args the list of instructions producing arguments to the invocation
64 * @param stateBefore the state before executing the invocation
65 */
66 public NativeCall(RiMethod nativeMethod, RiSignature signature, Value address, Value[] args, FrameState stateBefore) {
67 super(signature.returnKind().stackKind(), stateBefore);
68 this.address = address;
69 this.nativeMethod = nativeMethod;
70 this.arguments = args;
71 this.signature = signature;
72 assert nativeMethod.jniSymbol() != null;
73 }
74
75 /**
76 * The native function may call back into the VM which may call method that can trap.
77 */
78 @Override
79 public boolean canTrap() {
80 return true;
81 }
82
83 /**
84 * Gets the instruction that produces the native function address for this native call.
85 * @return the instruction
86 */
87 public Value address() {
88 return address;
89 }
90
91 @Override
92 public void inputValuesDo(ValueClosure closure) {
93 for (int i = 0; i < arguments.length; i++) {
94 Value arg = arguments[i];
95 if (arg != null) {
96 arguments[i] = closure.apply(arg);
97 assert arguments[i] != null;
98 }
99 }
100 address = closure.apply(address);
101 }
102
103 @Override
104 public void accept(ValueVisitor v) {
105 v.visitNativeCall(this);
106 }
107
108 @Override
109 public void print(LogStream out) {
110 out.print(nativeMethod.jniSymbol()).print('(');
111 for (int i = 0; i < arguments.length; i++) {
112 if (i > 0) {
113 out.print(", ");
114 }
115 out.print(arguments[i]);
116 }
117 out.print(')');
118 }
119 }