Print this page
rev 1024 : imported patch indy-cleanup-6893081.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/code/codeBlob.hpp
+++ new/src/share/vm/code/codeBlob.hpp
1 1 /*
2 - * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
2 + * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 // CodeBlob - superclass for all entries in the CodeCache.
26 26 //
27 27 // Suptypes are:
28 28 // nmethod : Compiled Java methods (include method that calls to native code)
29 29 // RuntimeStub : Call to VM runtime methods
30 30 // DeoptimizationBlob : Used for deoptimizatation
31 31 // ExceptionBlob : Used for stack unrolling
32 32 // SafepointBlob : Used to handle illegal instruction exceptions
33 33 //
34 34 //
35 35 // Layout:
36 36 // - header
37 37 // - relocation
38 38 // - instruction space
39 39 // - data space
40 40 class DeoptimizationBlob;
41 41
42 42 class CodeBlob VALUE_OBJ_CLASS_SPEC {
43 43
44 44 friend class VMStructs;
45 45
46 46 private:
47 47 const char* _name;
48 48 int _size; // total size of CodeBlob in bytes
49 49 int _header_size; // size of header (depends on subclass)
50 50 int _relocation_size; // size of relocation
51 51 int _instructions_offset; // offset to where instructions region begins
52 52 int _frame_complete_offset; // instruction offsets in [0.._frame_complete_offset) have
53 53 // not finished setting up their frame. Beware of pc's in
54 54 // that range. There is a similar range(s) on returns
55 55 // which we don't detect.
56 56 int _data_offset; // offset to where data region begins
57 57 int _oops_offset; // offset to where embedded oop table begins (inside data)
58 58 int _oops_length; // number of embedded oops
59 59 int _frame_size; // size of stack frame
60 60 OopMapSet* _oop_maps; // OopMap for this CodeBlob
61 61 CodeComments _comments;
62 62
63 63 friend class OopRecorder;
64 64
65 65 void fix_oop_relocations(address begin, address end, bool initialize_immediates);
66 66 inline void initialize_immediate_oop(oop* dest, jobject handle);
67 67
68 68 public:
69 69 // Returns the space needed for CodeBlob
70 70 static unsigned int allocation_size(CodeBuffer* cb, int header_size);
71 71
72 72 // Creation
73 73 // a) simple CodeBlob
74 74 // frame_complete is the offset from the beginning of the instructions
75 75 // to where the frame setup (from stackwalk viewpoint) is complete.
76 76 CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
77 77
78 78 // b) full CodeBlob
79 79 CodeBlob(
80 80 const char* name,
81 81 CodeBuffer* cb,
82 82 int header_size,
83 83 int size,
84 84 int frame_complete,
85 85 int frame_size,
86 86 OopMapSet* oop_maps
87 87 );
88 88
89 89 // Deletion
90 90 void flush();
91 91
92 92 // Typing
93 93 virtual bool is_buffer_blob() const { return false; }
94 94 virtual bool is_nmethod() const { return false; }
↓ open down ↓ |
82 lines elided |
↑ open up ↑ |
95 95 virtual bool is_runtime_stub() const { return false; }
96 96 virtual bool is_deoptimization_stub() const { return false; }
97 97 virtual bool is_uncommon_trap_stub() const { return false; }
98 98 virtual bool is_exception_stub() const { return false; }
99 99 virtual bool is_safepoint_stub() const { return false; }
100 100 virtual bool is_adapter_blob() const { return false; }
101 101
102 102 virtual bool is_compiled_by_c2() const { return false; }
103 103 virtual bool is_compiled_by_c1() const { return false; }
104 104
105 + // Casting
106 + nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; }
107 +
105 108 // Boundaries
106 109 address header_begin() const { return (address) this; }
107 110 address header_end() const { return ((address) this) + _header_size; };
108 111 relocInfo* relocation_begin() const { return (relocInfo*) header_end(); };
109 112 relocInfo* relocation_end() const { return (relocInfo*)(header_end() + _relocation_size); }
110 113 address instructions_begin() const { return (address) header_begin() + _instructions_offset; }
111 114 address instructions_end() const { return (address) header_begin() + _data_offset; }
112 115 address data_begin() const { return (address) header_begin() + _data_offset; }
113 116 address data_end() const { return (address) header_begin() + _size; }
114 117 oop* oops_begin() const { return (oop*) (header_begin() + _oops_offset); }
115 118 oop* oops_end() const { return oops_begin() + _oops_length; }
116 119
117 120 // Offsets
118 121 int relocation_offset() const { return _header_size; }
119 122 int instructions_offset() const { return _instructions_offset; }
120 123 int data_offset() const { return _data_offset; }
121 124 int oops_offset() const { return _oops_offset; }
122 125
123 126 // Sizes
124 127 int size() const { return _size; }
125 128 int header_size() const { return _header_size; }
126 129 int relocation_size() const { return (address) relocation_end() - (address) relocation_begin(); }
127 130 int instructions_size() const { return instructions_end() - instructions_begin(); }
128 131 int data_size() const { return data_end() - data_begin(); }
129 132 int oops_size() const { return (address) oops_end() - (address) oops_begin(); }
130 133
131 134 // Containment
132 135 bool blob_contains(address addr) const { return header_begin() <= addr && addr < data_end(); }
133 136 bool relocation_contains(relocInfo* addr) const{ return relocation_begin() <= addr && addr < relocation_end(); }
134 137 bool instructions_contains(address addr) const { return instructions_begin() <= addr && addr < instructions_end(); }
135 138 bool data_contains(address addr) const { return data_begin() <= addr && addr < data_end(); }
136 139 bool oops_contains(oop* addr) const { return oops_begin() <= addr && addr < oops_end(); }
137 140 bool contains(address addr) const { return instructions_contains(addr); }
138 141 bool is_frame_complete_at(address addr) const { return instructions_contains(addr) &&
139 142 addr >= instructions_begin() + _frame_complete_offset; }
140 143
141 144 // Relocation support
142 145 void fix_oop_relocations(address begin, address end) {
143 146 fix_oop_relocations(begin, end, false);
144 147 }
145 148 void fix_oop_relocations() {
146 149 fix_oop_relocations(NULL, NULL, false);
147 150 }
148 151 relocInfo::relocType reloc_type_for_address(address pc);
149 152 bool is_at_poll_return(address pc);
150 153 bool is_at_poll_or_poll_return(address pc);
151 154
152 155 // Support for oops in scopes and relocs:
153 156 // Note: index 0 is reserved for null.
154 157 oop oop_at(int index) const { return index == 0? (oop)NULL: *oop_addr_at(index); }
155 158 oop* oop_addr_at(int index) const{ // for GC
156 159 // relocation indexes are biased by 1 (because 0 is reserved)
157 160 assert(index > 0 && index <= _oops_length, "must be a valid non-zero index");
158 161 return &oops_begin()[index-1];
159 162 }
160 163
161 164 void copy_oops(GrowableArray<jobject>* oops);
162 165
163 166 // CodeCache support: really only used by the nmethods, but in order to get
164 167 // asserts and certain bookkeeping to work in the CodeCache they are defined
165 168 // virtual here.
166 169 virtual bool is_zombie() const { return false; }
167 170 virtual bool is_locked_by_vm() const { return false; }
168 171
169 172 virtual bool is_unloaded() const { return false; }
170 173 virtual bool is_not_entrant() const { return false; }
171 174
172 175 // GC support
173 176 virtual bool is_alive() const = 0;
174 177 virtual void do_unloading(BoolObjectClosure* is_alive,
175 178 OopClosure* keep_alive,
176 179 bool unloading_occurred);
177 180 virtual void oops_do(OopClosure* f) = 0;
178 181 // (All CodeBlob subtypes other than NMethod currently have
179 182 // an empty oops_do() method.
180 183
181 184 // OopMap for frame
182 185 OopMapSet* oop_maps() const { return _oop_maps; }
183 186 void set_oop_maps(OopMapSet* p);
184 187 OopMap* oop_map_for_return_address(address return_address);
185 188 virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); }
186 189
187 190 // Frame support
188 191 int frame_size() const { return _frame_size; }
189 192 void set_frame_size(int size) { _frame_size = size; }
190 193
191 194 // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
192 195 virtual bool caller_must_gc_arguments(JavaThread* thread) const { return false; }
193 196
194 197 // Naming
195 198 const char* name() const { return _name; }
196 199 void set_name(const char* name) { _name = name; }
197 200
198 201 // Debugging
199 202 virtual void verify();
200 203 virtual void print() const PRODUCT_RETURN;
201 204 virtual void print_value_on(outputStream* st) const PRODUCT_RETURN;
202 205
203 206 // Print the comment associated with offset on stream, if there is one
204 207 void print_block_comment(outputStream* stream, intptr_t offset) {
205 208 _comments.print_block_comment(stream, offset);
206 209 }
207 210
208 211 // Transfer ownership of comments to this CodeBlob
209 212 void set_comments(CodeComments& comments) {
210 213 _comments.assign(comments);
211 214 }
212 215 };
213 216
214 217
215 218 //----------------------------------------------------------------------------------------------------
216 219 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
217 220
218 221 class BufferBlob: public CodeBlob {
219 222 friend class VMStructs;
220 223 private:
221 224 // Creation support
222 225 BufferBlob(const char* name, int size);
223 226 BufferBlob(const char* name, int size, CodeBuffer* cb);
224 227
225 228 void* operator new(size_t s, unsigned size);
226 229
227 230 public:
228 231 // Creation
229 232 static BufferBlob* create(const char* name, int buffer_size);
230 233 static BufferBlob* create(const char* name, CodeBuffer* cb);
231 234
232 235 static void free(BufferBlob* buf);
233 236
234 237 // Typing
235 238 bool is_buffer_blob() const { return true; }
236 239 bool is_adapter_blob() const;
237 240
238 241 // GC/Verification support
239 242 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
240 243 bool is_alive() const { return true; }
241 244 void do_unloading(BoolObjectClosure* is_alive,
242 245 OopClosure* keep_alive,
243 246 bool unloading_occurred) { /* do nothing */ }
244 247
245 248 void oops_do(OopClosure* f) { /* do nothing*/ }
246 249
247 250 void verify();
248 251 void print() const PRODUCT_RETURN;
249 252 void print_value_on(outputStream* st) const PRODUCT_RETURN;
250 253 };
251 254
252 255
253 256 //----------------------------------------------------------------------------------------------------
254 257 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
255 258
256 259 class RuntimeStub: public CodeBlob {
257 260 friend class VMStructs;
258 261 private:
259 262 bool _caller_must_gc_arguments;
260 263
261 264 // Creation support
262 265 RuntimeStub(
263 266 const char* name,
264 267 CodeBuffer* cb,
265 268 int size,
266 269 int frame_complete,
267 270 int frame_size,
268 271 OopMapSet* oop_maps,
269 272 bool caller_must_gc_arguments
270 273 );
271 274
272 275 void* operator new(size_t s, unsigned size);
273 276
274 277 public:
275 278 // Creation
276 279 static RuntimeStub* new_runtime_stub(
277 280 const char* stub_name,
278 281 CodeBuffer* cb,
279 282 int frame_complete,
280 283 int frame_size,
281 284 OopMapSet* oop_maps,
282 285 bool caller_must_gc_arguments
283 286 );
284 287
285 288 // Typing
286 289 bool is_runtime_stub() const { return true; }
287 290
288 291 // GC support
289 292 bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
290 293
291 294 address entry_point() { return instructions_begin(); }
292 295
293 296 // GC/Verification support
294 297 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ }
295 298 bool is_alive() const { return true; }
296 299 void do_unloading(BoolObjectClosure* is_alive,
297 300 OopClosure* keep_alive,
298 301 bool unloading_occurred) { /* do nothing */ }
299 302 void oops_do(OopClosure* f) { /* do-nothing*/ }
300 303
301 304 void verify();
302 305 void print() const PRODUCT_RETURN;
303 306 void print_value_on(outputStream* st) const PRODUCT_RETURN;
304 307 };
305 308
306 309
307 310 //----------------------------------------------------------------------------------------------------
308 311 // Super-class for all blobs that exist in only one instance. Implements default behaviour.
309 312
310 313 class SingletonBlob: public CodeBlob {
311 314 friend class VMStructs;
312 315 public:
313 316 SingletonBlob(
314 317 const char* name,
315 318 CodeBuffer* cb,
316 319 int header_size,
317 320 int size,
318 321 int frame_size,
319 322 OopMapSet* oop_maps
320 323 )
321 324 : CodeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
322 325 {};
323 326
324 327 bool is_alive() const { return true; }
325 328 void do_unloading(BoolObjectClosure* is_alive,
326 329 OopClosure* keep_alive,
327 330 bool unloading_occurred) { /* do-nothing*/ }
328 331
329 332 void verify(); // does nothing
330 333 void print() const PRODUCT_RETURN;
331 334 void print_value_on(outputStream* st) const PRODUCT_RETURN;
332 335 };
333 336
334 337
335 338 //----------------------------------------------------------------------------------------------------
336 339 // DeoptimizationBlob
337 340
338 341 class DeoptimizationBlob: public SingletonBlob {
339 342 friend class VMStructs;
340 343 private:
341 344 int _unpack_offset;
342 345 int _unpack_with_exception;
343 346 int _unpack_with_reexecution;
344 347
345 348 int _unpack_with_exception_in_tls;
346 349
347 350 // Creation support
348 351 DeoptimizationBlob(
349 352 CodeBuffer* cb,
350 353 int size,
351 354 OopMapSet* oop_maps,
352 355 int unpack_offset,
353 356 int unpack_with_exception_offset,
354 357 int unpack_with_reexecution_offset,
355 358 int frame_size
356 359 );
357 360
358 361 void* operator new(size_t s, unsigned size);
359 362
360 363 public:
361 364 // Creation
362 365 static DeoptimizationBlob* create(
363 366 CodeBuffer* cb,
364 367 OopMapSet* oop_maps,
365 368 int unpack_offset,
366 369 int unpack_with_exception_offset,
367 370 int unpack_with_reexecution_offset,
368 371 int frame_size
369 372 );
370 373
371 374 // Typing
372 375 bool is_deoptimization_stub() const { return true; }
373 376 const DeoptimizationBlob *as_deoptimization_stub() const { return this; }
374 377 bool exception_address_is_unpack_entry(address pc) const {
375 378 address unpack_pc = unpack();
376 379 return (pc == unpack_pc || (pc + frame::pc_return_offset) == unpack_pc);
377 380 }
378 381
379 382
380 383
381 384
382 385 // GC for args
383 386 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* Nothing to do */ }
384 387
385 388 // Iteration
386 389 void oops_do(OopClosure* f) {}
387 390
388 391 // Printing
389 392 void print_value_on(outputStream* st) const PRODUCT_RETURN;
390 393
391 394 address unpack() const { return instructions_begin() + _unpack_offset; }
392 395 address unpack_with_exception() const { return instructions_begin() + _unpack_with_exception; }
393 396 address unpack_with_reexecution() const { return instructions_begin() + _unpack_with_reexecution; }
394 397
395 398 // Alternate entry point for C1 where the exception and issuing pc
396 399 // are in JavaThread::_exception_oop and JavaThread::_exception_pc
397 400 // instead of being in registers. This is needed because C1 doesn't
398 401 // model exception paths in a way that keeps these registers free so
399 402 // there may be live values in those registers during deopt.
400 403 void set_unpack_with_exception_in_tls_offset(int offset) {
401 404 _unpack_with_exception_in_tls = offset;
402 405 assert(contains(instructions_begin() + _unpack_with_exception_in_tls), "must be PC inside codeblob");
403 406 }
404 407 address unpack_with_exception_in_tls() const { return instructions_begin() + _unpack_with_exception_in_tls; }
405 408 };
406 409
407 410
408 411 //----------------------------------------------------------------------------------------------------
409 412 // UncommonTrapBlob (currently only used by Compiler 2)
410 413
411 414 #ifdef COMPILER2
412 415
413 416 class UncommonTrapBlob: public SingletonBlob {
414 417 friend class VMStructs;
415 418 private:
416 419 // Creation support
417 420 UncommonTrapBlob(
418 421 CodeBuffer* cb,
419 422 int size,
420 423 OopMapSet* oop_maps,
421 424 int frame_size
422 425 );
423 426
424 427 void* operator new(size_t s, unsigned size);
425 428
426 429 public:
427 430 // Creation
428 431 static UncommonTrapBlob* create(
429 432 CodeBuffer* cb,
430 433 OopMapSet* oop_maps,
431 434 int frame_size
432 435 );
433 436
434 437 // GC for args
435 438 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ }
436 439
437 440 // Typing
438 441 bool is_uncommon_trap_stub() const { return true; }
439 442
440 443 // Iteration
441 444 void oops_do(OopClosure* f) {}
442 445 };
443 446
444 447
445 448 //----------------------------------------------------------------------------------------------------
446 449 // ExceptionBlob: used for exception unwinding in compiled code (currently only used by Compiler 2)
447 450
448 451 class ExceptionBlob: public SingletonBlob {
449 452 friend class VMStructs;
450 453 private:
451 454 // Creation support
452 455 ExceptionBlob(
453 456 CodeBuffer* cb,
454 457 int size,
455 458 OopMapSet* oop_maps,
456 459 int frame_size
457 460 );
458 461
459 462 void* operator new(size_t s, unsigned size);
460 463
461 464 public:
462 465 // Creation
463 466 static ExceptionBlob* create(
464 467 CodeBuffer* cb,
465 468 OopMapSet* oop_maps,
466 469 int frame_size
467 470 );
468 471
469 472 // GC for args
470 473 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
471 474
472 475 // Typing
473 476 bool is_exception_stub() const { return true; }
474 477
475 478 // Iteration
476 479 void oops_do(OopClosure* f) {}
477 480 };
478 481 #endif // COMPILER2
479 482
480 483
481 484 //----------------------------------------------------------------------------------------------------
482 485 // SafepointBlob: handles illegal_instruction exceptions during a safepoint
483 486
484 487 class SafepointBlob: public SingletonBlob {
485 488 friend class VMStructs;
486 489 private:
487 490 // Creation support
488 491 SafepointBlob(
489 492 CodeBuffer* cb,
490 493 int size,
491 494 OopMapSet* oop_maps,
492 495 int frame_size
493 496 );
494 497
495 498 void* operator new(size_t s, unsigned size);
496 499
497 500 public:
498 501 // Creation
499 502 static SafepointBlob* create(
500 503 CodeBuffer* cb,
501 504 OopMapSet* oop_maps,
502 505 int frame_size
503 506 );
504 507
505 508 // GC for args
506 509 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
507 510
508 511 // Typing
509 512 bool is_safepoint_stub() const { return true; }
510 513
511 514 // Iteration
512 515 void oops_do(OopClosure* f) {}
513 516 };
↓ open down ↓ |
399 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX