Mercurial > hg > truffle
annotate src/share/vm/runtime/javaCalls.hpp @ 14714:b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 20 Mar 2014 17:15:36 +0100 |
parents | d8041d695d19 |
children | 3e9a960f0da1 |
rev | line source |
---|---|
0 | 1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
11146
diff
changeset
|
2 * Copyright (c) 1997, 2013, 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" | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
29 #include "oops/method.hpp" |
1972 | 30 #include "runtime/handles.hpp" |
31 #include "runtime/javaFrameAnchor.hpp" | |
7180
f34d701e952e
8003935: Simplify the needed includes for using Thread::current()
stefank
parents:
6725
diff
changeset
|
32 #include "runtime/thread.inline.hpp" |
1972 | 33 #include "runtime/vmThread.hpp" |
34 #ifdef TARGET_ARCH_x86 | |
35 # include "jniTypes_x86.hpp" | |
36 #endif | |
37 #ifdef TARGET_ARCH_sparc | |
38 # include "jniTypes_sparc.hpp" | |
39 #endif | |
40 #ifdef TARGET_ARCH_zero | |
41 # include "jniTypes_zero.hpp" | |
42 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
43 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
44 # include "jniTypes_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
45 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
46 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
47 # include "jniTypes_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
48 #endif |
1972 | 49 |
0 | 50 // A JavaCallWrapper is constructed before each JavaCall and destructed after the call. |
51 // Its purpose is to allocate/deallocate a new handle block and to save/restore the last | |
52 // Java fp/sp. A pointer to the JavaCallWrapper is stored on the stack. | |
53 | |
54 class JavaCallWrapper: StackObj { | |
55 friend class VMStructs; | |
56 private: | |
57 JavaThread* _thread; // the thread to which this call belongs | |
58 JNIHandleBlock* _handles; // the saved handle block | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
59 Method* _callee_method; // to be able to collect arguments if entry frame is top frame |
0 | 60 oop _receiver; // the receiver of the call (if a non-static call) |
61 | |
62 JavaFrameAnchor _anchor; // last thread anchor state that we must restore | |
63 | |
64 JavaValue* _result; // result value | |
65 | |
66 public: | |
67 // Construction/destruction | |
68 JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS); | |
69 ~JavaCallWrapper(); | |
70 | |
71 // Accessors | |
72 JavaThread* thread() const { return _thread; } | |
73 JNIHandleBlock* handles() const { return _handles; } | |
74 | |
75 JavaFrameAnchor* anchor(void) { return &_anchor; } | |
76 | |
77 JavaValue* result() const { return _result; } | |
78 // GC support | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
3960
diff
changeset
|
79 Method* callee_method() { return _callee_method; } |
0 | 80 oop receiver() { return _receiver; } |
81 void oops_do(OopClosure* f); | |
82 | |
11146
e619a2766bcc
8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents:
7180
diff
changeset
|
83 bool is_first_frame() const { return _anchor.last_Java_sp() == NULL; } |
e619a2766bcc
8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents:
7180
diff
changeset
|
84 |
0 | 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 | |
8151
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
103 #ifdef GRAAL |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
104 nmethod* _alternative_target; // Nmethod that should be called instead of normal target |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
105 #endif |
0 | 106 |
107 void initialize() { | |
108 // Starts at first element to support set_receiver. | |
109 _value = &_value_buffer[1]; | |
110 _is_oop = &_is_oop_buffer[1]; | |
111 | |
112 _max_size = _default_size; | |
113 _size = 0; | |
114 _start_at_zero = false; | |
8151
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
115 GRAAL_ONLY(_alternative_target = NULL;) |
0 | 116 } |
117 | |
118 public: | |
119 JavaCallArguments() { initialize(); } | |
120 | |
121 JavaCallArguments(Handle receiver) { | |
122 initialize(); | |
123 push_oop(receiver); | |
124 } | |
125 | |
126 JavaCallArguments(int max_size) { | |
127 if (max_size > _default_size) { | |
128 _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1); | |
129 _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1); | |
1506 | 130 |
0 | 131 // Reserve room for potential receiver in value and is_oop |
132 _value++; _is_oop++; | |
1506 | 133 |
0 | 134 _max_size = max_size; |
135 _size = 0; | |
136 _start_at_zero = false; | |
8157
2156359ee519
Fix JavaCallArguments initialization.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8151
diff
changeset
|
137 GRAAL_ONLY(_alternative_target = NULL;) |
0 | 138 } else { |
139 initialize(); | |
140 } | |
141 } | |
142 | |
8151
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
143 #ifdef GRAAL |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
144 void set_alternative_target(nmethod* target) { |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
145 _alternative_target = target; |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
146 } |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
147 |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
148 nmethod* alternative_target() { |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
149 return _alternative_target; |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
150 } |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
151 #endif |
b8f261ba79c6
Minimize diff to plain HotSpot version.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7212
diff
changeset
|
152 |
0 | 153 inline void push_oop(Handle h) { _is_oop[_size] = true; |
154 JNITypes::put_obj((oop)h.raw_value(), _value, _size); } | |
155 | |
156 inline void push_int(int i) { _is_oop[_size] = false; | |
157 JNITypes::put_int(i, _value, _size); } | |
158 | |
159 inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false; | |
160 JNITypes::put_double(d, _value, _size); } | |
161 | |
162 inline void push_long(jlong l) { _is_oop[_size] = false; _is_oop[_size + 1] = false; | |
163 JNITypes::put_long(l, _value, _size); } | |
164 | |
165 inline void push_float(float f) { _is_oop[_size] = false; | |
166 JNITypes::put_float(f, _value, _size); } | |
167 | |
168 // receiver | |
169 Handle receiver() { | |
170 assert(_size > 0, "must at least be one argument"); | |
171 assert(_is_oop[0], "first argument must be an oop"); | |
172 assert(_value[0] != 0, "receiver must be not-null"); | |
173 return Handle((oop*)_value[0], false); | |
174 } | |
175 | |
176 void set_receiver(Handle h) { | |
177 assert(_start_at_zero == false, "can only be called once"); | |
178 _start_at_zero = true; | |
179 _is_oop--; | |
180 _value--; | |
181 _size++; | |
182 _is_oop[0] = true; | |
183 _value[0] = (intptr_t)h.raw_value(); | |
184 } | |
185 | |
186 // Converts all Handles to oops, and returns a reference to parameter vector | |
187 intptr_t* parameters() ; | |
188 int size_of_parameters() const { return _size; } | |
189 | |
190 // Verify that pushed arguments fits a given method | |
465
dc16daa0329d
6739363: Xcheck jni doesn't check native function arguments
poonam
parents:
0
diff
changeset
|
191 void verify(methodHandle method, BasicType return_type, Thread *thread); |
0 | 192 }; |
193 | |
194 // All calls to Java have to go via JavaCalls. Sets up the stack frame | |
195 // and makes sure that the last_Java_frame pointers are chained correctly. | |
196 // | |
197 | |
198 class JavaCalls: AllStatic { | |
199 static void call_helper(JavaValue* result, methodHandle* method, JavaCallArguments* args, TRAPS); | |
200 public: | |
201 // Optimized Constuctor call | |
202 static void call_default_constructor(JavaThread* thread, methodHandle method, Handle receiver, TRAPS); | |
203 | |
204 // call_special | |
205 // ------------ | |
206 // 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
|
207 static void call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
0 | 208 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
209 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
|
210 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
|
211 static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
0 | 212 |
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
|
213 // 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
|
214 // ------------ |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
470
diff
changeset
|
215 |
6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
470
diff
changeset
|
216 // The receiver must be first oop in argument list |
2182
9569fdf936ff
Made merge compile.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
2181
diff
changeset
|
217 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
|
218 |
0 | 219 // virtual call |
220 // ------------ | |
221 | |
222 // 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
|
223 static void call_virtual(JavaValue* result, KlassHandle spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
0 | 224 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
225 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
|
226 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
|
227 static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
0 | 228 |
229 // Static call | |
230 // ----------- | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
231 static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
0 | 232 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
233 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
|
234 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
|
235 static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
0 | 236 |
237 // Low-level interface | |
238 static void call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS); | |
239 }; | |
1972 | 240 |
241 #endif // SHARE_VM_RUNTIME_JAVACALLS_HPP |