Mercurial > hg > graal-compiler
annotate src/share/vm/runtime/javaCalls.hpp @ 2182:9569fdf936ff
Made merge compile.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Wed, 16 Feb 2011 14:21:52 +0100 |
parents | d25d4ca69222 |
children | 0cd39a385a72 |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1506
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_RUNTIME_JAVACALLS_HPP |
26 #define SHARE_VM_RUNTIME_JAVACALLS_HPP | |
27 | |
28 #include "memory/allocation.hpp" | |
29 #include "oops/methodOop.hpp" | |
30 #include "runtime/handles.hpp" | |
31 #include "runtime/javaFrameAnchor.hpp" | |
32 #include "runtime/vmThread.hpp" | |
33 #ifdef TARGET_ARCH_x86 | |
34 # include "jniTypes_x86.hpp" | |
35 #endif | |
36 #ifdef TARGET_ARCH_sparc | |
37 # include "jniTypes_sparc.hpp" | |
38 #endif | |
39 #ifdef TARGET_ARCH_zero | |
40 # include "jniTypes_zero.hpp" | |
41 #endif | |
42 #ifdef TARGET_OS_FAMILY_linux | |
43 # include "thread_linux.inline.hpp" | |
44 #endif | |
45 #ifdef TARGET_OS_FAMILY_solaris | |
46 # include "thread_solaris.inline.hpp" | |
47 #endif | |
48 #ifdef TARGET_OS_FAMILY_windows | |
49 # include "thread_windows.inline.hpp" | |
50 #endif | |
51 | |
0 | 52 // A JavaCallWrapper is constructed before each JavaCall and destructed after the call. |
53 // Its purpose is to allocate/deallocate a new handle block and to save/restore the last | |
54 // Java fp/sp. A pointer to the JavaCallWrapper is stored on the stack. | |
55 | |
56 class JavaCallWrapper: StackObj { | |
57 friend class VMStructs; | |
58 private: | |
59 JavaThread* _thread; // the thread to which this call belongs | |
60 JNIHandleBlock* _handles; // the saved handle block | |
61 methodOop _callee_method; // to be able to collect arguments if entry frame is top frame | |
62 oop _receiver; // the receiver of the call (if a non-static call) | |
63 | |
64 JavaFrameAnchor _anchor; // last thread anchor state that we must restore | |
65 | |
66 JavaValue* _result; // result value | |
67 | |
68 public: | |
69 // Construction/destruction | |
70 JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS); | |
71 ~JavaCallWrapper(); | |
72 | |
73 // Accessors | |
74 JavaThread* thread() const { return _thread; } | |
75 JNIHandleBlock* handles() const { return _handles; } | |
76 | |
77 JavaFrameAnchor* anchor(void) { return &_anchor; } | |
78 | |
79 JavaValue* result() const { return _result; } | |
80 // GC support | |
81 methodOop callee_method() { return _callee_method; } | |
82 oop receiver() { return _receiver; } | |
83 void oops_do(OopClosure* f); | |
84 | |
85 }; | |
86 | |
87 | |
88 // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args) | |
89 class JavaCallArguments : public StackObj { | |
90 private: | |
91 enum Constants { | |
92 _default_size = 8 // Must be at least # of arguments in JavaCalls methods | |
93 }; | |
94 | |
95 intptr_t _value_buffer [_default_size + 1]; | |
96 bool _is_oop_buffer[_default_size + 1]; | |
97 | |
98 intptr_t* _value; | |
99 bool* _is_oop; | |
100 int _size; | |
101 int _max_size; | |
102 bool _start_at_zero; // Support late setting of receiver | |
103 | |
104 void initialize() { | |
105 // Starts at first element to support set_receiver. | |
106 _value = &_value_buffer[1]; | |
107 _is_oop = &_is_oop_buffer[1]; | |
108 | |
109 _max_size = _default_size; | |
110 _size = 0; | |
111 _start_at_zero = false; | |
112 } | |
113 | |
114 public: | |
115 JavaCallArguments() { initialize(); } | |
116 | |
117 JavaCallArguments(Handle receiver) { | |
118 initialize(); | |
119 push_oop(receiver); | |
120 } | |
121 | |
122 JavaCallArguments(int max_size) { | |
123 if (max_size > _default_size) { | |
124 _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1); | |
125 _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1); | |
1506 | 126 |
0 | 127 // Reserve room for potential receiver in value and is_oop |
128 _value++; _is_oop++; | |
1506 | 129 |
0 | 130 _max_size = max_size; |
131 _size = 0; | |
132 _start_at_zero = false; | |
133 } else { | |
134 initialize(); | |
135 } | |
136 } | |
137 | |
138 inline void push_oop(Handle h) { _is_oop[_size] = true; | |
139 JNITypes::put_obj((oop)h.raw_value(), _value, _size); } | |
140 | |
141 inline void push_int(int i) { _is_oop[_size] = false; | |
142 JNITypes::put_int(i, _value, _size); } | |
143 | |
144 inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false; | |
145 JNITypes::put_double(d, _value, _size); } | |
146 | |
147 inline void push_long(jlong l) { _is_oop[_size] = false; _is_oop[_size + 1] = false; | |
148 JNITypes::put_long(l, _value, _size); } | |
149 | |
150 inline void push_float(float f) { _is_oop[_size] = false; | |
151 JNITypes::put_float(f, _value, _size); } | |
152 | |
153 // receiver | |
154 Handle receiver() { | |
155 assert(_size > 0, "must at least be one argument"); | |
156 assert(_is_oop[0], "first argument must be an oop"); | |
157 assert(_value[0] != 0, "receiver must be not-null"); | |
158 return Handle((oop*)_value[0], false); | |
159 } | |
160 | |
161 void set_receiver(Handle h) { | |
162 assert(_start_at_zero == false, "can only be called once"); | |
163 _start_at_zero = true; | |
164 _is_oop--; | |
165 _value--; | |
166 _size++; | |
167 _is_oop[0] = true; | |
168 _value[0] = (intptr_t)h.raw_value(); | |
169 } | |
170 | |
171 // Converts all Handles to oops, and returns a reference to parameter vector | |
172 intptr_t* parameters() ; | |
173 int size_of_parameters() const { return _size; } | |
174 | |
175 // Verify that pushed arguments fits a given method | |
465
dc16daa0329d
6739363: Xcheck jni doesn't check native function arguments
poonam
parents:
0
diff
changeset
|
176 void verify(methodHandle method, BasicType return_type, Thread *thread); |
0 | 177 }; |
178 | |
179 // All calls to Java have to go via JavaCalls. Sets up the stack frame | |
180 // and makes sure that the last_Java_frame pointers are chained correctly. | |
181 // | |
182 | |
183 class JavaCalls: AllStatic { | |
184 static void call_helper(JavaValue* result, methodHandle* method, JavaCallArguments* args, TRAPS); | |
185 public: | |
186 // Optimized Constuctor call | |
187 static void call_default_constructor(JavaThread* thread, methodHandle method, Handle receiver, TRAPS); | |
188 | |
189 // call_special | |
190 // ------------ | |
191 // The receiver must be first oop in argument list | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
192 static void call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
0 | 193 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
194 static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); // No args |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
195 static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
196 static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
0 | 197 |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
470
diff
changeset
|
198 // interface call |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
470
diff
changeset
|
199 // ------------ |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
470
diff
changeset
|
200 |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
470
diff
changeset
|
201 // The receiver must be first oop in argument list |
2182
9569fdf936ff
Made merge compile.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
2181
diff
changeset
|
202 static void call_interface(JavaValue* result, KlassHandle spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
1421
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
470
diff
changeset
|
203 |
0 | 204 // virtual call |
205 // ------------ | |
206 | |
207 // The receiver must be first oop in argument list | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
208 static void call_virtual(JavaValue* result, KlassHandle spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
0 | 209 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
210 static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, TRAPS); // No args |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
211 static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
212 static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
0 | 213 |
214 // Static call | |
215 // ----------- | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
216 static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
0 | 217 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
218 static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
219 static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
220 static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
0 | 221 |
222 // Low-level interface | |
223 static void call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS); | |
224 }; | |
1972 | 225 |
226 #endif // SHARE_VM_RUNTIME_JAVACALLS_HPP |