author | ysr |
Fri, 16 Oct 2009 02:05:46 -0700 | |
changeset 4030 | 4c471254865e |
parent 1374 | 4c24294029a9 |
child 4637 | af4d405aacc1 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2 |
* Copyright 1998-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
//------------------------------OptoRuntime------------------------------------ |
|
26 |
// Opto compiler runtime routines |
|
27 |
// |
|
28 |
// These are all generated from Ideal graphs. They are called with the |
|
29 |
// Java calling convention. Internally they call C++. They are made once at |
|
30 |
// startup time and Opto compiles calls to them later. |
|
31 |
// Things are broken up into quads: the signature they will be called with, |
|
32 |
// the address of the generated code, the corresponding C++ code and an |
|
33 |
// nmethod. |
|
34 |
||
35 |
// The signature (returned by "xxx_Type()") is used at startup time by the |
|
36 |
// Generator to make the generated code "xxx_Java". Opto compiles calls |
|
37 |
// to the generated code "xxx_Java". When the compiled code gets executed, |
|
38 |
// it calls the C++ code "xxx_C". The generated nmethod is saved in the |
|
39 |
// CodeCache. Exception handlers use the nmethod to get the callee-save |
|
40 |
// register OopMaps. |
|
41 |
class CallInfo; |
|
42 |
||
43 |
// |
|
44 |
// NamedCounters are tagged counters which can be used for profiling |
|
45 |
// code in various ways. Currently they are used by the lock coarsening code |
|
46 |
// |
|
47 |
||
48 |
class NamedCounter : public CHeapObj { |
|
49 |
public: |
|
50 |
enum CounterTag { |
|
51 |
NoTag, |
|
52 |
LockCounter, |
|
53 |
EliminatedLockCounter, |
|
54 |
BiasedLockingCounter |
|
55 |
}; |
|
56 |
||
57 |
private: |
|
58 |
const char * _name; |
|
59 |
int _count; |
|
60 |
CounterTag _tag; |
|
61 |
NamedCounter* _next; |
|
62 |
||
63 |
public: |
|
64 |
NamedCounter(const char *n, CounterTag tag = NoTag): |
|
65 |
_name(n), |
|
66 |
_count(0), |
|
67 |
_next(NULL), |
|
68 |
_tag(tag) {} |
|
69 |
||
70 |
const char * name() const { return _name; } |
|
71 |
int count() const { return _count; } |
|
72 |
address addr() { return (address)&_count; } |
|
73 |
CounterTag tag() const { return _tag; } |
|
74 |
void set_tag(CounterTag tag) { _tag = tag; } |
|
75 |
||
76 |
NamedCounter* next() const { return _next; } |
|
77 |
void set_next(NamedCounter* next) { |
|
78 |
assert(_next == NULL, "already set"); |
|
79 |
_next = next; |
|
80 |
} |
|
81 |
||
82 |
}; |
|
83 |
||
84 |
class BiasedLockingNamedCounter : public NamedCounter { |
|
85 |
private: |
|
86 |
BiasedLockingCounters _counters; |
|
87 |
||
88 |
public: |
|
89 |
BiasedLockingNamedCounter(const char *n) : |
|
90 |
NamedCounter(n, BiasedLockingCounter), _counters() {} |
|
91 |
||
92 |
BiasedLockingCounters* counters() { return &_counters; } |
|
93 |
}; |
|
94 |
||
95 |
typedef const TypeFunc*(*TypeFunc_generator)(); |
|
96 |
||
97 |
class OptoRuntime : public AllStatic { |
|
98 |
friend class Matcher; // allow access to stub names |
|
99 |
||
100 |
private: |
|
101 |
// define stubs |
|
102 |
static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char *name, int is_fancy_jump, bool pass_tls, bool save_arguments, bool return_pc); |
|
103 |
||
104 |
// References to generated stubs |
|
105 |
static address _new_instance_Java; |
|
106 |
static address _new_array_Java; |
|
107 |
static address _multianewarray2_Java; |
|
108 |
static address _multianewarray3_Java; |
|
109 |
static address _multianewarray4_Java; |
|
110 |
static address _multianewarray5_Java; |
|
1374 | 111 |
static address _g1_wb_pre_Java; |
112 |
static address _g1_wb_post_Java; |
|
1 | 113 |
static address _vtable_must_compile_Java; |
114 |
static address _complete_monitor_locking_Java; |
|
115 |
static address _rethrow_Java; |
|
116 |
||
117 |
static address _slow_arraycopy_Java; |
|
118 |
static address _register_finalizer_Java; |
|
119 |
||
120 |
# ifdef ENABLE_ZAP_DEAD_LOCALS |
|
121 |
static address _zap_dead_Java_locals_Java; |
|
122 |
static address _zap_dead_native_locals_Java; |
|
123 |
# endif |
|
124 |
||
125 |
||
126 |
// |
|
127 |
// Implementation of runtime methods |
|
128 |
// ================================= |
|
129 |
||
130 |
// Allocate storage for a Java instance. |
|
131 |
static void new_instance_C(klassOopDesc* instance_klass, JavaThread *thread); |
|
132 |
||
133 |
// Allocate storage for a objArray or typeArray |
|
134 |
static void new_array_C(klassOopDesc* array_klass, int len, JavaThread *thread); |
|
135 |
||
4030
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
1374
diff
changeset
|
136 |
// Post-slow-path-allocation step for implementing ReduceInitialCardMarks: |
4c471254865e
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
ysr
parents:
1374
diff
changeset
|
137 |
static void maybe_defer_card_mark(JavaThread* thread); |
1 | 138 |
|
139 |
// Allocate storage for a multi-dimensional arrays |
|
140 |
// Note: needs to be fixed for arbitrary number of dimensions |
|
141 |
static void multianewarray2_C(klassOopDesc* klass, int len1, int len2, JavaThread *thread); |
|
142 |
static void multianewarray3_C(klassOopDesc* klass, int len1, int len2, int len3, JavaThread *thread); |
|
143 |
static void multianewarray4_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, JavaThread *thread); |
|
144 |
static void multianewarray5_C(klassOopDesc* klass, int len1, int len2, int len3, int len4, int len5, JavaThread *thread); |
|
1374 | 145 |
static void g1_wb_pre_C(oopDesc* orig, JavaThread* thread); |
146 |
static void g1_wb_post_C(void* card_addr, JavaThread* thread); |
|
1 | 147 |
|
148 |
public: |
|
149 |
// Slow-path Locking and Unlocking |
|
150 |
static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread); |
|
151 |
static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock); |
|
152 |
||
153 |
private: |
|
154 |
||
155 |
// Implicit exception support |
|
156 |
static void throw_null_exception_C(JavaThread* thread); |
|
157 |
||
158 |
// Exception handling |
|
159 |
static address handle_exception_C (JavaThread* thread); |
|
160 |
static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm); |
|
161 |
static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc ); |
|
162 |
static void deoptimize_caller_frame (JavaThread *thread, bool doit); |
|
163 |
||
164 |
// CodeBlob support |
|
165 |
// =================================================================== |
|
166 |
||
167 |
static ExceptionBlob* _exception_blob; |
|
168 |
static void generate_exception_blob(); |
|
169 |
||
170 |
static void register_finalizer(oopDesc* obj, JavaThread* thread); |
|
171 |
||
172 |
// zaping dead locals, either from Java frames or from native frames |
|
173 |
# ifdef ENABLE_ZAP_DEAD_LOCALS |
|
174 |
static void zap_dead_Java_locals_C( JavaThread* thread); |
|
175 |
static void zap_dead_native_locals_C( JavaThread* thread); |
|
176 |
||
177 |
static void zap_dead_java_or_native_locals( JavaThread*, bool (*)(frame*)); |
|
178 |
||
179 |
public: |
|
180 |
static int ZapDeadCompiledLocals_count; |
|
181 |
||
182 |
# endif |
|
183 |
||
184 |
||
185 |
public: |
|
186 |
||
187 |
static bool is_callee_saved_register(MachRegisterNumbers reg); |
|
188 |
||
189 |
// One time only generate runtime code stubs |
|
190 |
static void generate(ciEnv* env); |
|
191 |
||
192 |
// Returns the name of a stub |
|
193 |
static const char* stub_name(address entry); |
|
194 |
||
195 |
// access to runtime stubs entry points for java code |
|
196 |
static address new_instance_Java() { return _new_instance_Java; } |
|
197 |
static address new_array_Java() { return _new_array_Java; } |
|
198 |
static address multianewarray2_Java() { return _multianewarray2_Java; } |
|
199 |
static address multianewarray3_Java() { return _multianewarray3_Java; } |
|
200 |
static address multianewarray4_Java() { return _multianewarray4_Java; } |
|
201 |
static address multianewarray5_Java() { return _multianewarray5_Java; } |
|
1374 | 202 |
static address g1_wb_pre_Java() { return _g1_wb_pre_Java; } |
203 |
static address g1_wb_post_Java() { return _g1_wb_post_Java; } |
|
1 | 204 |
static address vtable_must_compile_stub() { return _vtable_must_compile_Java; } |
205 |
static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; } |
|
206 |
||
207 |
static address slow_arraycopy_Java() { return _slow_arraycopy_Java; } |
|
208 |
static address register_finalizer_Java() { return _register_finalizer_Java; } |
|
209 |
||
210 |
||
211 |
# ifdef ENABLE_ZAP_DEAD_LOCALS |
|
212 |
static address zap_dead_locals_stub(bool is_native) { return is_native |
|
213 |
? _zap_dead_native_locals_Java |
|
214 |
: _zap_dead_Java_locals_Java; } |
|
215 |
static MachNode* node_to_call_zap_dead_locals(Node* n, int block_num, bool is_native); |
|
216 |
# endif |
|
217 |
||
218 |
static ExceptionBlob* exception_blob() { return _exception_blob; } |
|
219 |
||
220 |
// Leaf routines helping with method data update |
|
221 |
static void profile_receiver_type_C(DataLayout* data, oopDesc* receiver); |
|
222 |
||
223 |
// Implicit exception support |
|
224 |
static void throw_div0_exception_C (JavaThread* thread); |
|
225 |
static void throw_stack_overflow_error_C(JavaThread* thread); |
|
226 |
||
227 |
// Exception handling |
|
228 |
static address rethrow_stub() { return _rethrow_Java; } |
|
229 |
||
230 |
||
231 |
// Type functions |
|
232 |
// ====================================================== |
|
233 |
||
234 |
static const TypeFunc* new_instance_Type(); // object allocation (slow case) |
|
235 |
static const TypeFunc* new_array_Type (); // [a]newarray (slow case) |
|
236 |
static const TypeFunc* multianewarray_Type(int ndim); // multianewarray |
|
237 |
static const TypeFunc* multianewarray2_Type(); // multianewarray |
|
238 |
static const TypeFunc* multianewarray3_Type(); // multianewarray |
|
239 |
static const TypeFunc* multianewarray4_Type(); // multianewarray |
|
240 |
static const TypeFunc* multianewarray5_Type(); // multianewarray |
|
1374 | 241 |
static const TypeFunc* g1_wb_pre_Type(); |
242 |
static const TypeFunc* g1_wb_post_Type(); |
|
1 | 243 |
static const TypeFunc* complete_monitor_enter_Type(); |
244 |
static const TypeFunc* complete_monitor_exit_Type(); |
|
245 |
static const TypeFunc* uncommon_trap_Type(); |
|
246 |
static const TypeFunc* athrow_Type(); |
|
247 |
static const TypeFunc* rethrow_Type(); |
|
248 |
static const TypeFunc* Math_D_D_Type(); // sin,cos & friends |
|
249 |
static const TypeFunc* Math_DD_D_Type(); // mod,pow & friends |
|
250 |
static const TypeFunc* modf_Type(); |
|
251 |
static const TypeFunc* l2f_Type(); |
|
252 |
static const TypeFunc* current_time_millis_Type(); |
|
253 |
||
254 |
static const TypeFunc* flush_windows_Type(); |
|
255 |
||
256 |
// arraycopy routine types |
|
257 |
static const TypeFunc* fast_arraycopy_Type(); // bit-blasters |
|
258 |
static const TypeFunc* checkcast_arraycopy_Type(); |
|
259 |
static const TypeFunc* generic_arraycopy_Type(); |
|
260 |
static const TypeFunc* slow_arraycopy_Type(); // the full routine |
|
261 |
||
262 |
// leaf on stack replacement interpreter accessor types |
|
263 |
static const TypeFunc* osr_end_Type(); |
|
264 |
||
265 |
// leaf methodData routine types |
|
266 |
static const TypeFunc* profile_receiver_type_Type(); |
|
267 |
||
268 |
// leaf on stack replacement interpreter accessor types |
|
269 |
static const TypeFunc* fetch_int_Type(); |
|
270 |
static const TypeFunc* fetch_long_Type(); |
|
271 |
static const TypeFunc* fetch_float_Type(); |
|
272 |
static const TypeFunc* fetch_double_Type(); |
|
273 |
static const TypeFunc* fetch_oop_Type(); |
|
274 |
static const TypeFunc* fetch_monitor_Type(); |
|
275 |
||
276 |
static const TypeFunc* register_finalizer_Type(); |
|
277 |
||
278 |
// Dtrace support |
|
279 |
static const TypeFunc* dtrace_method_entry_exit_Type(); |
|
280 |
static const TypeFunc* dtrace_object_alloc_Type(); |
|
281 |
||
282 |
# ifdef ENABLE_ZAP_DEAD_LOCALS |
|
283 |
static const TypeFunc* zap_dead_locals_Type(); |
|
284 |
# endif |
|
285 |
||
286 |
private: |
|
287 |
static NamedCounter * volatile _named_counters; |
|
288 |
||
289 |
public: |
|
290 |
// helper function which creates a named counter labeled with the |
|
291 |
// if they are available |
|
292 |
static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag); |
|
293 |
||
294 |
// dumps all the named counters |
|
295 |
static void print_named_counters(); |
|
296 |
||
297 |
}; |