171 |
171 |
172 // ======= Thread ======== |
172 // ======= Thread ======== |
173 // Support for forcing alignment of thread objects for biased locking |
173 // Support for forcing alignment of thread objects for biased locking |
174 void* Thread::allocate(size_t size, bool throw_excpt, MEMFLAGS flags) { |
174 void* Thread::allocate(size_t size, bool throw_excpt, MEMFLAGS flags) { |
175 if (UseBiasedLocking) { |
175 if (UseBiasedLocking) { |
176 const int alignment = markWord::biased_lock_alignment; |
176 const size_t alignment = markWord::biased_lock_alignment; |
177 size_t aligned_size = size + (alignment - sizeof(intptr_t)); |
177 size_t aligned_size = size + (alignment - sizeof(intptr_t)); |
178 void* real_malloc_addr = throw_excpt? AllocateHeap(aligned_size, flags, CURRENT_PC) |
178 void* real_malloc_addr = throw_excpt? AllocateHeap(aligned_size, flags, CURRENT_PC) |
179 : AllocateHeap(aligned_size, flags, CURRENT_PC, |
179 : AllocateHeap(aligned_size, flags, CURRENT_PC, |
180 AllocFailStrategy::RETURN_NULL); |
180 AllocFailStrategy::RETURN_NULL); |
181 void* aligned_addr = align_up(real_malloc_addr, alignment); |
181 void* aligned_addr = align_up(real_malloc_addr, alignment); |
299 _unhandled_oops = new UnhandledOops(this); |
299 _unhandled_oops = new UnhandledOops(this); |
300 } |
300 } |
301 #endif // CHECK_UNHANDLED_OOPS |
301 #endif // CHECK_UNHANDLED_OOPS |
302 #ifdef ASSERT |
302 #ifdef ASSERT |
303 if (UseBiasedLocking) { |
303 if (UseBiasedLocking) { |
304 assert((((uintptr_t) this) & (markWord::biased_lock_alignment - 1)) == 0, "forced alignment of thread object failed"); |
304 assert(is_aligned(this, markWord::biased_lock_alignment), "forced alignment of thread object failed"); |
305 assert(this == _real_malloc_address || |
305 assert(this == _real_malloc_address || |
306 this == align_up(_real_malloc_address, (int)markWord::biased_lock_alignment), |
306 this == align_up(_real_malloc_address, markWord::biased_lock_alignment), |
307 "bug in forced alignment of thread objects"); |
307 "bug in forced alignment of thread objects"); |
308 } |
308 } |
309 #endif // ASSERT |
309 #endif // ASSERT |
310 |
310 |
311 // Notify the barrier set that a thread is being created. The initial |
311 // Notify the barrier set that a thread is being created. The initial |