Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/javaCalls.hpp @ 3979:4dfb2df418f2
6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp
author | johnc |
---|---|
date | Thu, 22 Sep 2011 10:57:37 -0700 |
parents | 1d1603768966 |
children | 0654ee04b214 f08d439fab8c |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2192
diff
changeset
|
2 * Copyright (c) 1997, 2011, 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 | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
42 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
43 # include "jniTypes_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
44 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
45 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
46 # include "jniTypes_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
47 #endif |
1972 | 48 #ifdef TARGET_OS_FAMILY_linux |
49 # include "thread_linux.inline.hpp" | |
50 #endif | |
51 #ifdef TARGET_OS_FAMILY_solaris | |
52 # include "thread_solaris.inline.hpp" | |
53 #endif | |
54 #ifdef TARGET_OS_FAMILY_windows | |
55 # include "thread_windows.inline.hpp" | |
56 #endif | |
57 | |
0 | 58 // A JavaCallWrapper is constructed before each JavaCall and destructed after the call. |
59 // Its purpose is to allocate/deallocate a new handle block and to save/restore the last | |
60 // Java fp/sp. A pointer to the JavaCallWrapper is stored on the stack. | |
61 | |
62 class JavaCallWrapper: StackObj { | |
63 friend class VMStructs; | |
64 private: | |
65 JavaThread* _thread; // the thread to which this call belongs | |
66 JNIHandleBlock* _handles; // the saved handle block | |
67 methodOop _callee_method; // to be able to collect arguments if entry frame is top frame | |
68 oop _receiver; // the receiver of the call (if a non-static call) | |
69 | |
70 JavaFrameAnchor _anchor; // last thread anchor state that we must restore | |
71 | |
72 JavaValue* _result; // result value | |
73 | |
74 public: | |
75 // Construction/destruction | |
76 JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS); | |
77 ~JavaCallWrapper(); | |
78 | |
79 // Accessors | |
80 JavaThread* thread() const { return _thread; } | |
81 JNIHandleBlock* handles() const { return _handles; } | |
82 | |
83 JavaFrameAnchor* anchor(void) { return &_anchor; } | |
84 | |
85 JavaValue* result() const { return _result; } | |
86 // GC support | |
87 methodOop callee_method() { return _callee_method; } | |
88 oop receiver() { return _receiver; } | |
89 void oops_do(OopClosure* f); | |
90 | |
91 }; | |
92 | |
93 | |
94 // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args) | |
95 class JavaCallArguments : public StackObj { | |
96 private: | |
97 enum Constants { | |
98 _default_size = 8 // Must be at least # of arguments in JavaCalls methods | |
99 }; | |
100 | |
101 intptr_t _value_buffer [_default_size + 1]; | |
102 bool _is_oop_buffer[_default_size + 1]; | |
103 | |
104 intptr_t* _value; | |
105 bool* _is_oop; | |
106 int _size; | |
107 int _max_size; | |
108 bool _start_at_zero; // Support late setting of receiver | |
109 | |
110 void initialize() { | |
111 // Starts at first element to support set_receiver. | |
112 _value = &_value_buffer[1]; | |
113 _is_oop = &_is_oop_buffer[1]; | |
114 | |
115 _max_size = _default_size; | |
116 _size = 0; | |
117 _start_at_zero = false; | |
118 } | |
119 | |
120 public: | |
121 JavaCallArguments() { initialize(); } | |
122 | |
123 JavaCallArguments(Handle receiver) { | |
124 initialize(); | |
125 push_oop(receiver); | |
126 } | |
127 | |
128 JavaCallArguments(int max_size) { | |
129 if (max_size > _default_size) { | |
130 _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1); | |
131 _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1); | |
1506 | 132 |
0 | 133 // Reserve room for potential receiver in value and is_oop |
134 _value++; _is_oop++; | |
1506 | 135 |
0 | 136 _max_size = max_size; |
137 _size = 0; | |
138 _start_at_zero = false; | |
139 } else { | |
140 initialize(); | |
141 } | |
142 } | |
143 | |
144 inline void push_oop(Handle h) { _is_oop[_size] = true; | |
145 JNITypes::put_obj((oop)h.raw_value(), _value, _size); } | |
146 | |
147 inline void push_int(int i) { _is_oop[_size] = false; | |
148 JNITypes::put_int(i, _value, _size); } | |
149 | |
150 inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false; | |
151 JNITypes::put_double(d, _value, _size); } | |
152 | |
153 inline void push_long(jlong l) { _is_oop[_size] = false; _is_oop[_size + 1] = false; | |
154 JNITypes::put_long(l, _value, _size); } | |
155 | |
156 inline void push_float(float f) { _is_oop[_size] = false; | |
157 JNITypes::put_float(f, _value, _size); } | |
158 | |
159 // receiver | |
160 Handle receiver() { | |
161 assert(_size > 0, "must at least be one argument"); | |
162 assert(_is_oop[0], "first argument must be an oop"); | |
163 assert(_value[0] != 0, "receiver must be not-null"); | |
164 return Handle((oop*)_value[0], false); | |
165 } | |
166 | |
167 void set_receiver(Handle h) { | |
168 assert(_start_at_zero == false, "can only be called once"); | |
169 _start_at_zero = true; | |
170 _is_oop--; | |
171 _value--; | |
172 _size++; | |
173 _is_oop[0] = true; | |
174 _value[0] = (intptr_t)h.raw_value(); | |
175 } | |
176 | |
177 // Converts all Handles to oops, and returns a reference to parameter vector | |
178 intptr_t* parameters() ; | |
179 int size_of_parameters() const { return _size; } | |
180 | |
181 // Verify that pushed arguments fits a given method | |
465
dc16daa0329d
6739363: Xcheck jni doesn't check native function arguments
poonam
parents:
0
diff
changeset
|
182 void verify(methodHandle method, BasicType return_type, Thread *thread); |
0 | 183 }; |
184 | |
185 // All calls to Java have to go via JavaCalls. Sets up the stack frame | |
186 // and makes sure that the last_Java_frame pointers are chained correctly. | |
187 // | |
188 | |
189 class JavaCalls: AllStatic { | |
190 static void call_helper(JavaValue* result, methodHandle* method, JavaCallArguments* args, TRAPS); | |
191 public: | |
192 // Optimized Constuctor call | |
193 static void call_default_constructor(JavaThread* thread, methodHandle method, Handle receiver, TRAPS); | |
194 | |
195 // call_special | |
196 // ------------ | |
197 // 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
|
198 static void call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS); |
0 | 199 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
200 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
|
201 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
|
202 static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS); |
0 | 203 |
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 |