Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/code/codeBlob.hpp
+++ new/src/share/vm/code/codeBlob.hpp
1 1 /*
2 2 * Copyright 1998-2010 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:
↓ open down ↓ |
46 lines elided |
↑ open up ↑ |
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 - int _oops_offset; // offset to where embedded oop table begins (inside data)
58 - int _oops_length; // number of embedded oops
59 57 int _frame_size; // size of stack frame
60 58 OopMapSet* _oop_maps; // OopMap for this CodeBlob
61 59 CodeComments _comments;
62 60
63 61 friend class OopRecorder;
64 62
65 - void fix_oop_relocations(address begin, address end, bool initialize_immediates);
66 - inline void initialize_immediate_oop(oop* dest, jobject handle);
67 -
68 63 public:
69 64 // Returns the space needed for CodeBlob
70 65 static unsigned int allocation_size(CodeBuffer* cb, int header_size);
71 66
72 67 // Creation
73 68 // a) simple CodeBlob
74 69 // frame_complete is the offset from the beginning of the instructions
75 70 // to where the frame setup (from stackwalk viewpoint) is complete.
76 71 CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
77 72
78 73 // b) full CodeBlob
79 74 CodeBlob(
80 75 const char* name,
81 76 CodeBuffer* cb,
82 77 int header_size,
83 78 int size,
84 79 int frame_complete,
85 80 int frame_size,
86 81 OopMapSet* oop_maps
87 82 );
88 83
89 84 // Deletion
90 85 void flush();
91 86
92 87 // Typing
93 88 virtual bool is_buffer_blob() const { return false; }
94 89 virtual bool is_nmethod() const { return false; }
95 90 virtual bool is_runtime_stub() const { return false; }
96 91 virtual bool is_deoptimization_stub() const { return false; }
97 92 virtual bool is_uncommon_trap_stub() const { return false; }
98 93 virtual bool is_exception_stub() const { return false; }
99 94 virtual bool is_safepoint_stub() const { return false; }
100 95 virtual bool is_adapter_blob() const { return false; }
101 96 virtual bool is_method_handles_adapter_blob() const { return false; }
102 97
103 98 virtual bool is_compiled_by_c2() const { return false; }
104 99 virtual bool is_compiled_by_c1() const { return false; }
105 100
106 101 // Casting
107 102 nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; }
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
108 103
109 104 // Boundaries
110 105 address header_begin() const { return (address) this; }
111 106 address header_end() const { return ((address) this) + _header_size; };
112 107 relocInfo* relocation_begin() const { return (relocInfo*) header_end(); };
113 108 relocInfo* relocation_end() const { return (relocInfo*)(header_end() + _relocation_size); }
114 109 address instructions_begin() const { return (address) header_begin() + _instructions_offset; }
115 110 address instructions_end() const { return (address) header_begin() + _data_offset; }
116 111 address data_begin() const { return (address) header_begin() + _data_offset; }
117 112 address data_end() const { return (address) header_begin() + _size; }
118 - oop* oops_begin() const { return (oop*) (header_begin() + _oops_offset); }
119 - oop* oops_end() const { return oops_begin() + _oops_length; }
120 113
121 114 // Offsets
122 115 int relocation_offset() const { return _header_size; }
123 116 int instructions_offset() const { return _instructions_offset; }
124 117 int data_offset() const { return _data_offset; }
125 - int oops_offset() const { return _oops_offset; }
126 118
127 119 // Sizes
128 120 int size() const { return _size; }
129 121 int header_size() const { return _header_size; }
130 122 int relocation_size() const { return (address) relocation_end() - (address) relocation_begin(); }
131 123 int instructions_size() const { return instructions_end() - instructions_begin(); }
132 124 int data_size() const { return data_end() - data_begin(); }
133 - int oops_size() const { return (address) oops_end() - (address) oops_begin(); }
134 125
135 126 // Containment
136 127 bool blob_contains(address addr) const { return header_begin() <= addr && addr < data_end(); }
137 128 bool relocation_contains(relocInfo* addr) const{ return relocation_begin() <= addr && addr < relocation_end(); }
138 129 bool instructions_contains(address addr) const { return instructions_begin() <= addr && addr < instructions_end(); }
139 130 bool data_contains(address addr) const { return data_begin() <= addr && addr < data_end(); }
140 - bool oops_contains(oop* addr) const { return oops_begin() <= addr && addr < oops_end(); }
141 131 bool contains(address addr) const { return instructions_contains(addr); }
142 132 bool is_frame_complete_at(address addr) const { return instructions_contains(addr) &&
143 133 addr >= instructions_begin() + _frame_complete_offset; }
144 134
145 - // Relocation support
146 - void fix_oop_relocations(address begin, address end) {
147 - fix_oop_relocations(begin, end, false);
148 - }
149 - void fix_oop_relocations() {
150 - fix_oop_relocations(NULL, NULL, false);
151 - }
152 - relocInfo::relocType reloc_type_for_address(address pc);
153 - bool is_at_poll_return(address pc);
154 - bool is_at_poll_or_poll_return(address pc);
155 -
156 - // Support for oops in scopes and relocs:
157 - // Note: index 0 is reserved for null.
158 - oop oop_at(int index) const { return index == 0? (oop)NULL: *oop_addr_at(index); }
159 - oop* oop_addr_at(int index) const{ // for GC
160 - // relocation indexes are biased by 1 (because 0 is reserved)
161 - assert(index > 0 && index <= _oops_length, "must be a valid non-zero index");
162 - return &oops_begin()[index-1];
163 - }
164 -
165 - void copy_oops(GrowableArray<jobject>* oops);
166 -
167 135 // CodeCache support: really only used by the nmethods, but in order to get
168 136 // asserts and certain bookkeeping to work in the CodeCache they are defined
169 137 // virtual here.
170 138 virtual bool is_zombie() const { return false; }
171 139 virtual bool is_locked_by_vm() const { return false; }
172 140
173 141 virtual bool is_unloaded() const { return false; }
174 142 virtual bool is_not_entrant() const { return false; }
175 143
176 144 // GC support
177 145 virtual bool is_alive() const = 0;
178 - virtual void do_unloading(BoolObjectClosure* is_alive,
179 - OopClosure* keep_alive,
180 - bool unloading_occurred);
181 - virtual void oops_do(OopClosure* f) = 0;
182 - // (All CodeBlob subtypes other than NMethod currently have
183 - // an empty oops_do() method.
184 146
185 147 // OopMap for frame
186 148 OopMapSet* oop_maps() const { return _oop_maps; }
187 149 void set_oop_maps(OopMapSet* p);
188 150 OopMap* oop_map_for_return_address(address return_address);
189 151 virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); }
190 152
191 153 // Frame support
192 154 int frame_size() const { return _frame_size; }
193 155 void set_frame_size(int size) { _frame_size = size; }
194 156
195 157 // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
196 158 virtual bool caller_must_gc_arguments(JavaThread* thread) const { return false; }
197 159
198 160 // Naming
199 161 const char* name() const { return _name; }
200 162 void set_name(const char* name) { _name = name; }
201 163
202 164 // Debugging
203 165 virtual void verify();
204 166 virtual void print() const PRODUCT_RETURN;
205 167 virtual void print_value_on(outputStream* st) const PRODUCT_RETURN;
206 168
207 169 // Print the comment associated with offset on stream, if there is one
208 170 virtual void print_block_comment(outputStream* stream, address block_begin) {
209 171 intptr_t offset = (intptr_t)(block_begin - instructions_begin());
210 172 _comments.print_block_comment(stream, offset);
211 173 }
212 174
213 175 // Transfer ownership of comments to this CodeBlob
214 176 void set_comments(CodeComments& comments) {
215 177 _comments.assign(comments);
216 178 }
217 179 };
218 180
219 181
220 182 //----------------------------------------------------------------------------------------------------
221 183 // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
222 184
223 185 class BufferBlob: public CodeBlob {
224 186 friend class VMStructs;
225 187 friend class AdapterBlob;
226 188 friend class MethodHandlesAdapterBlob;
227 189
228 190 private:
229 191 // Creation support
230 192 BufferBlob(const char* name, int size);
231 193 BufferBlob(const char* name, int size, CodeBuffer* cb);
232 194
233 195 void* operator new(size_t s, unsigned size);
234 196
235 197 public:
236 198 // Creation
237 199 static BufferBlob* create(const char* name, int buffer_size);
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
238 200 static BufferBlob* create(const char* name, CodeBuffer* cb);
239 201
240 202 static void free(BufferBlob* buf);
241 203
242 204 // Typing
243 205 virtual bool is_buffer_blob() const { return true; }
244 206
245 207 // GC/Verification support
246 208 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
247 209 bool is_alive() const { return true; }
248 - void do_unloading(BoolObjectClosure* is_alive,
249 - OopClosure* keep_alive,
250 - bool unloading_occurred) { /* do nothing */ }
251 -
252 - void oops_do(OopClosure* f) { /* do nothing*/ }
253 210
254 211 void verify();
255 212 void print() const PRODUCT_RETURN;
256 213 void print_value_on(outputStream* st) const PRODUCT_RETURN;
257 214 };
258 215
259 216
260 217 //----------------------------------------------------------------------------------------------------
261 218 // AdapterBlob: used to hold C2I/I2C adapters
262 219
263 220 class AdapterBlob: public BufferBlob {
264 221 private:
265 222 AdapterBlob(int size) : BufferBlob("I2C/C2I adapters", size) {}
266 223 AdapterBlob(int size, CodeBuffer* cb) : BufferBlob("I2C/C2I adapters", size, cb) {}
267 224
268 225 public:
269 226 // Creation
270 227 static AdapterBlob* create(CodeBuffer* cb);
271 228
272 229 // Typing
273 230 virtual bool is_adapter_blob() const { return true; }
274 231 };
275 232
276 233
277 234 //----------------------------------------------------------------------------------------------------
278 235 // MethodHandlesAdapterBlob: used to hold MethodHandles adapters
279 236
280 237 class MethodHandlesAdapterBlob: public BufferBlob {
281 238 private:
282 239 MethodHandlesAdapterBlob(int size) : BufferBlob("MethodHandles adapters", size) {}
283 240 MethodHandlesAdapterBlob(int size, CodeBuffer* cb) : BufferBlob("MethodHandles adapters", size, cb) {}
284 241
285 242 public:
286 243 // Creation
287 244 static MethodHandlesAdapterBlob* create(int buffer_size);
288 245
289 246 // Typing
290 247 virtual bool is_method_handles_adapter_blob() const { return true; }
291 248 };
292 249
293 250
294 251 //----------------------------------------------------------------------------------------------------
295 252 // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
296 253
297 254 class RuntimeStub: public CodeBlob {
298 255 friend class VMStructs;
299 256 private:
300 257 bool _caller_must_gc_arguments;
301 258
302 259 // Creation support
303 260 RuntimeStub(
304 261 const char* name,
305 262 CodeBuffer* cb,
306 263 int size,
307 264 int frame_complete,
308 265 int frame_size,
309 266 OopMapSet* oop_maps,
310 267 bool caller_must_gc_arguments
311 268 );
312 269
313 270 void* operator new(size_t s, unsigned size);
314 271
315 272 public:
316 273 // Creation
317 274 static RuntimeStub* new_runtime_stub(
318 275 const char* stub_name,
319 276 CodeBuffer* cb,
320 277 int frame_complete,
321 278 int frame_size,
322 279 OopMapSet* oop_maps,
323 280 bool caller_must_gc_arguments
324 281 );
325 282
326 283 // Typing
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
327 284 bool is_runtime_stub() const { return true; }
328 285
329 286 // GC support
330 287 bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
331 288
332 289 address entry_point() { return instructions_begin(); }
333 290
334 291 // GC/Verification support
335 292 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ }
336 293 bool is_alive() const { return true; }
337 - void do_unloading(BoolObjectClosure* is_alive,
338 - OopClosure* keep_alive,
339 - bool unloading_occurred) { /* do nothing */ }
340 - void oops_do(OopClosure* f) { /* do-nothing*/ }
341 294
342 295 void verify();
343 296 void print() const PRODUCT_RETURN;
344 297 void print_value_on(outputStream* st) const PRODUCT_RETURN;
345 298 };
346 299
347 300
348 301 //----------------------------------------------------------------------------------------------------
349 302 // Super-class for all blobs that exist in only one instance. Implements default behaviour.
350 303
351 304 class SingletonBlob: public CodeBlob {
352 305 friend class VMStructs;
353 306 public:
354 307 SingletonBlob(
355 308 const char* name,
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
356 309 CodeBuffer* cb,
357 310 int header_size,
358 311 int size,
359 312 int frame_size,
360 313 OopMapSet* oop_maps
361 314 )
362 315 : CodeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
363 316 {};
364 317
365 318 bool is_alive() const { return true; }
366 - void do_unloading(BoolObjectClosure* is_alive,
367 - OopClosure* keep_alive,
368 - bool unloading_occurred) { /* do-nothing*/ }
369 319
370 320 void verify(); // does nothing
371 321 void print() const PRODUCT_RETURN;
372 322 void print_value_on(outputStream* st) const PRODUCT_RETURN;
373 323 };
374 324
375 325
376 326 //----------------------------------------------------------------------------------------------------
377 327 // DeoptimizationBlob
378 328
379 329 class DeoptimizationBlob: public SingletonBlob {
380 330 friend class VMStructs;
381 331 private:
382 332 int _unpack_offset;
383 333 int _unpack_with_exception;
384 334 int _unpack_with_reexecution;
385 335
386 336 int _unpack_with_exception_in_tls;
387 337
388 338 // Creation support
389 339 DeoptimizationBlob(
390 340 CodeBuffer* cb,
391 341 int size,
392 342 OopMapSet* oop_maps,
393 343 int unpack_offset,
394 344 int unpack_with_exception_offset,
395 345 int unpack_with_reexecution_offset,
396 346 int frame_size
397 347 );
398 348
399 349 void* operator new(size_t s, unsigned size);
400 350
401 351 public:
402 352 // Creation
403 353 static DeoptimizationBlob* create(
404 354 CodeBuffer* cb,
405 355 OopMapSet* oop_maps,
406 356 int unpack_offset,
407 357 int unpack_with_exception_offset,
408 358 int unpack_with_reexecution_offset,
409 359 int frame_size
410 360 );
411 361
412 362 // Typing
413 363 bool is_deoptimization_stub() const { return true; }
414 364 const DeoptimizationBlob *as_deoptimization_stub() const { return this; }
415 365 bool exception_address_is_unpack_entry(address pc) const {
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
416 366 address unpack_pc = unpack();
417 367 return (pc == unpack_pc || (pc + frame::pc_return_offset) == unpack_pc);
418 368 }
419 369
420 370
421 371
422 372
423 373 // GC for args
424 374 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* Nothing to do */ }
425 375
426 - // Iteration
427 - void oops_do(OopClosure* f) {}
428 -
429 376 // Printing
430 377 void print_value_on(outputStream* st) const PRODUCT_RETURN;
431 378
432 379 address unpack() const { return instructions_begin() + _unpack_offset; }
433 380 address unpack_with_exception() const { return instructions_begin() + _unpack_with_exception; }
434 381 address unpack_with_reexecution() const { return instructions_begin() + _unpack_with_reexecution; }
435 382
436 383 // Alternate entry point for C1 where the exception and issuing pc
437 384 // are in JavaThread::_exception_oop and JavaThread::_exception_pc
438 385 // instead of being in registers. This is needed because C1 doesn't
439 386 // model exception paths in a way that keeps these registers free so
440 387 // there may be live values in those registers during deopt.
441 388 void set_unpack_with_exception_in_tls_offset(int offset) {
442 389 _unpack_with_exception_in_tls = offset;
443 390 assert(contains(instructions_begin() + _unpack_with_exception_in_tls), "must be PC inside codeblob");
444 391 }
445 392 address unpack_with_exception_in_tls() const { return instructions_begin() + _unpack_with_exception_in_tls; }
446 393 };
447 394
448 395
449 396 //----------------------------------------------------------------------------------------------------
450 397 // UncommonTrapBlob (currently only used by Compiler 2)
451 398
452 399 #ifdef COMPILER2
453 400
454 401 class UncommonTrapBlob: public SingletonBlob {
455 402 friend class VMStructs;
456 403 private:
457 404 // Creation support
458 405 UncommonTrapBlob(
459 406 CodeBuffer* cb,
460 407 int size,
461 408 OopMapSet* oop_maps,
462 409 int frame_size
463 410 );
464 411
465 412 void* operator new(size_t s, unsigned size);
466 413
467 414 public:
468 415 // Creation
469 416 static UncommonTrapBlob* create(
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
470 417 CodeBuffer* cb,
471 418 OopMapSet* oop_maps,
472 419 int frame_size
473 420 );
474 421
475 422 // GC for args
476 423 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ }
477 424
478 425 // Typing
479 426 bool is_uncommon_trap_stub() const { return true; }
480 -
481 - // Iteration
482 - void oops_do(OopClosure* f) {}
483 427 };
484 428
485 429
486 430 //----------------------------------------------------------------------------------------------------
487 431 // ExceptionBlob: used for exception unwinding in compiled code (currently only used by Compiler 2)
488 432
489 433 class ExceptionBlob: public SingletonBlob {
490 434 friend class VMStructs;
491 435 private:
492 436 // Creation support
493 437 ExceptionBlob(
494 438 CodeBuffer* cb,
495 439 int size,
496 440 OopMapSet* oop_maps,
497 441 int frame_size
498 442 );
499 443
500 444 void* operator new(size_t s, unsigned size);
501 445
502 446 public:
503 447 // Creation
504 448 static ExceptionBlob* create(
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
505 449 CodeBuffer* cb,
506 450 OopMapSet* oop_maps,
507 451 int frame_size
508 452 );
509 453
510 454 // GC for args
511 455 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
512 456
513 457 // Typing
514 458 bool is_exception_stub() const { return true; }
515 -
516 - // Iteration
517 - void oops_do(OopClosure* f) {}
518 459 };
519 460 #endif // COMPILER2
520 461
521 462
522 463 //----------------------------------------------------------------------------------------------------
523 464 // SafepointBlob: handles illegal_instruction exceptions during a safepoint
524 465
525 466 class SafepointBlob: public SingletonBlob {
526 467 friend class VMStructs;
527 468 private:
528 469 // Creation support
529 470 SafepointBlob(
530 471 CodeBuffer* cb,
531 472 int size,
532 473 OopMapSet* oop_maps,
533 474 int frame_size
534 475 );
535 476
536 477 void* operator new(size_t s, unsigned size);
537 478
538 479 public:
539 480 // Creation
540 481 static SafepointBlob* create(
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
541 482 CodeBuffer* cb,
542 483 OopMapSet* oop_maps,
543 484 int frame_size
544 485 );
545 486
546 487 // GC for args
547 488 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
548 489
549 490 // Typing
550 491 bool is_safepoint_stub() const { return true; }
551 -
552 - // Iteration
553 - void oops_do(OopClosure* f) {}
554 492 };
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX