Mercurial > hg > graal-compiler
comparison src/share/vm/gc_interface/collectedHeap.inline.hpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | 9a9bb0010c91 |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
5891:fd8832ae511d | 6275:957c266d8bc5 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
48 #endif | 48 #endif |
49 | 49 |
50 // Inline allocation implementations. | 50 // Inline allocation implementations. |
51 | 51 |
52 void CollectedHeap::post_allocation_setup_common(KlassHandle klass, | 52 void CollectedHeap::post_allocation_setup_common(KlassHandle klass, |
53 HeapWord* obj, | 53 HeapWord* obj) { |
54 size_t size) { | 54 post_allocation_setup_no_klass_install(klass, obj); |
55 post_allocation_setup_no_klass_install(klass, obj, size); | 55 post_allocation_install_obj_klass(klass, oop(obj)); |
56 post_allocation_install_obj_klass(klass, oop(obj), (int) size); | |
57 } | 56 } |
58 | 57 |
59 void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, | 58 void CollectedHeap::post_allocation_setup_no_klass_install(KlassHandle klass, |
60 HeapWord* objPtr, | 59 HeapWord* objPtr) { |
61 size_t size) { | |
62 oop obj = (oop)objPtr; | 60 oop obj = (oop)objPtr; |
63 | 61 |
64 assert(obj != NULL, "NULL object pointer"); | 62 assert(obj != NULL, "NULL object pointer"); |
65 if (UseBiasedLocking && (klass() != NULL)) { | 63 if (UseBiasedLocking && (klass() != NULL)) { |
66 obj->set_mark(klass->prototype_header()); | 64 obj->set_mark(klass->prototype_header()); |
69 obj->set_mark(markOopDesc::prototype()); | 67 obj->set_mark(markOopDesc::prototype()); |
70 } | 68 } |
71 } | 69 } |
72 | 70 |
73 void CollectedHeap::post_allocation_install_obj_klass(KlassHandle klass, | 71 void CollectedHeap::post_allocation_install_obj_klass(KlassHandle klass, |
74 oop obj, | 72 oop obj) { |
75 int size) { | |
76 // These asserts are kind of complicated because of klassKlass | 73 // These asserts are kind of complicated because of klassKlass |
77 // and the beginning of the world. | 74 // and the beginning of the world. |
78 assert(klass() != NULL || !Universe::is_fully_initialized(), "NULL klass"); | 75 assert(klass() != NULL || !Universe::is_fully_initialized(), "NULL klass"); |
79 assert(klass() == NULL || klass()->is_klass(), "not a klass"); | 76 assert(klass() == NULL || klass()->is_klass(), "not a klass"); |
80 assert(klass() == NULL || klass()->klass_part() != NULL, "not a klass"); | 77 assert(klass() == NULL || klass()->klass_part() != NULL, "not a klass"); |
99 } | 96 } |
100 } | 97 } |
101 } | 98 } |
102 | 99 |
103 void CollectedHeap::post_allocation_setup_obj(KlassHandle klass, | 100 void CollectedHeap::post_allocation_setup_obj(KlassHandle klass, |
104 HeapWord* obj, | 101 HeapWord* obj) { |
105 size_t size) { | 102 post_allocation_setup_common(klass, obj); |
106 post_allocation_setup_common(klass, obj, size); | |
107 assert(Universe::is_bootstrapping() || | 103 assert(Universe::is_bootstrapping() || |
108 !((oop)obj)->blueprint()->oop_is_array(), "must not be an array"); | 104 !((oop)obj)->blueprint()->oop_is_array(), "must not be an array"); |
109 // notify jvmti and dtrace | 105 // notify jvmti and dtrace |
110 post_allocation_notify(klass, (oop)obj); | 106 post_allocation_notify(klass, (oop)obj); |
111 } | 107 } |
112 | 108 |
113 void CollectedHeap::post_allocation_setup_array(KlassHandle klass, | 109 void CollectedHeap::post_allocation_setup_array(KlassHandle klass, |
114 HeapWord* obj, | 110 HeapWord* obj, |
115 size_t size, | |
116 int length) { | 111 int length) { |
117 // Set array length before setting the _klass field | 112 // Set array length before setting the _klass field |
118 // in post_allocation_setup_common() because the klass field | 113 // in post_allocation_setup_common() because the klass field |
119 // indicates that the object is parsable by concurrent GC. | 114 // indicates that the object is parsable by concurrent GC. |
120 assert(length >= 0, "length should be non-negative"); | 115 assert(length >= 0, "length should be non-negative"); |
121 ((arrayOop)obj)->set_length(length); | 116 ((arrayOop)obj)->set_length(length); |
122 post_allocation_setup_common(klass, obj, size); | 117 post_allocation_setup_common(klass, obj); |
123 assert(((oop)obj)->blueprint()->oop_is_array(), "must be an array"); | 118 assert(((oop)obj)->blueprint()->oop_is_array(), "must be an array"); |
124 // notify jvmti and dtrace (must be after length is set for dtrace) | 119 // notify jvmti and dtrace (must be after length is set for dtrace) |
125 post_allocation_notify(klass, (oop)obj); | 120 post_allocation_notify(klass, (oop)obj); |
126 } | 121 } |
127 | 122 |
254 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) { | 249 oop CollectedHeap::obj_allocate(KlassHandle klass, int size, TRAPS) { |
255 debug_only(check_for_valid_allocation_state()); | 250 debug_only(check_for_valid_allocation_state()); |
256 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | 251 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
257 assert(size >= 0, "int won't convert to size_t"); | 252 assert(size >= 0, "int won't convert to size_t"); |
258 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); | 253 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); |
259 post_allocation_setup_obj(klass, obj, size); | 254 post_allocation_setup_obj(klass, obj); |
260 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); | 255 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
261 return (oop)obj; | 256 return (oop)obj; |
262 } | 257 } |
263 | 258 |
264 oop CollectedHeap::array_allocate(KlassHandle klass, | 259 oop CollectedHeap::array_allocate(KlassHandle klass, |
267 TRAPS) { | 262 TRAPS) { |
268 debug_only(check_for_valid_allocation_state()); | 263 debug_only(check_for_valid_allocation_state()); |
269 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | 264 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
270 assert(size >= 0, "int won't convert to size_t"); | 265 assert(size >= 0, "int won't convert to size_t"); |
271 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); | 266 HeapWord* obj = common_mem_allocate_init(size, CHECK_NULL); |
272 post_allocation_setup_array(klass, obj, size, length); | 267 post_allocation_setup_array(klass, obj, length); |
273 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); | 268 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
274 return (oop)obj; | 269 return (oop)obj; |
275 } | 270 } |
276 | 271 |
277 oop CollectedHeap::array_allocate_nozero(KlassHandle klass, | 272 oop CollectedHeap::array_allocate_nozero(KlassHandle klass, |
281 debug_only(check_for_valid_allocation_state()); | 276 debug_only(check_for_valid_allocation_state()); |
282 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | 277 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
283 assert(size >= 0, "int won't convert to size_t"); | 278 assert(size >= 0, "int won't convert to size_t"); |
284 HeapWord* obj = common_mem_allocate_noinit(size, CHECK_NULL); | 279 HeapWord* obj = common_mem_allocate_noinit(size, CHECK_NULL); |
285 ((oop)obj)->set_klass_gap(0); | 280 ((oop)obj)->set_klass_gap(0); |
286 post_allocation_setup_array(klass, obj, size, length); | 281 post_allocation_setup_array(klass, obj, length); |
287 #ifndef PRODUCT | 282 #ifndef PRODUCT |
288 const size_t hs = oopDesc::header_size()+1; | 283 const size_t hs = oopDesc::header_size()+1; |
289 Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs); | 284 Universe::heap()->check_for_non_bad_heap_word_value(obj+hs, size-hs); |
290 #endif | 285 #endif |
291 return (oop)obj; | 286 return (oop)obj; |
292 } | 287 } |
293 | 288 |
294 oop CollectedHeap::permanent_obj_allocate(KlassHandle klass, int size, TRAPS) { | 289 oop CollectedHeap::permanent_obj_allocate(KlassHandle klass, int size, TRAPS) { |
295 oop obj = permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL); | 290 oop obj = permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL); |
296 post_allocation_install_obj_klass(klass, obj, size); | 291 post_allocation_install_obj_klass(klass, obj); |
297 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value((HeapWord*) obj, | 292 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value((HeapWord*) obj, |
298 size)); | 293 size)); |
299 return obj; | 294 return obj; |
300 } | 295 } |
301 | 296 |
304 TRAPS) { | 299 TRAPS) { |
305 debug_only(check_for_valid_allocation_state()); | 300 debug_only(check_for_valid_allocation_state()); |
306 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | 301 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
307 assert(size >= 0, "int won't convert to size_t"); | 302 assert(size >= 0, "int won't convert to size_t"); |
308 HeapWord* obj = common_permanent_mem_allocate_init(size, CHECK_NULL); | 303 HeapWord* obj = common_permanent_mem_allocate_init(size, CHECK_NULL); |
309 post_allocation_setup_no_klass_install(klass, obj, size); | 304 post_allocation_setup_no_klass_install(klass, obj); |
310 #ifndef PRODUCT | 305 #ifndef PRODUCT |
311 const size_t hs = oopDesc::header_size(); | 306 const size_t hs = oopDesc::header_size(); |
312 Universe::heap()->check_for_bad_heap_word_value(obj+hs, size-hs); | 307 Universe::heap()->check_for_bad_heap_word_value(obj+hs, size-hs); |
313 #endif | 308 #endif |
314 return (oop)obj; | 309 return (oop)obj; |
320 TRAPS) { | 315 TRAPS) { |
321 debug_only(check_for_valid_allocation_state()); | 316 debug_only(check_for_valid_allocation_state()); |
322 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); | 317 assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed"); |
323 assert(size >= 0, "int won't convert to size_t"); | 318 assert(size >= 0, "int won't convert to size_t"); |
324 HeapWord* obj = common_permanent_mem_allocate_init(size, CHECK_NULL); | 319 HeapWord* obj = common_permanent_mem_allocate_init(size, CHECK_NULL); |
325 post_allocation_setup_array(klass, obj, size, length); | 320 post_allocation_setup_array(klass, obj, length); |
326 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); | 321 NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size)); |
327 return (oop)obj; | 322 return (oop)obj; |
328 } | 323 } |
329 | 324 |
330 // Returns "TRUE" if "p" is a method oop in the | 325 // Returns "TRUE" if "p" is a method oop in the |