1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2011, 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. |
3201 // (creates a new TLAB, etc.) |
3201 // (creates a new TLAB, etc.) |
3202 |
3202 |
3203 const bool allow_shared_alloc = |
3203 const bool allow_shared_alloc = |
3204 Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode; |
3204 Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode; |
3205 |
3205 |
|
3206 const Register thread = rcx; |
|
3207 if (UseTLAB || allow_shared_alloc) { |
|
3208 __ get_thread(thread); |
|
3209 } |
|
3210 |
3206 if (UseTLAB) { |
3211 if (UseTLAB) { |
3207 const Register thread = rcx; |
|
3208 |
|
3209 __ get_thread(thread); |
|
3210 __ movptr(rax, Address(thread, in_bytes(JavaThread::tlab_top_offset()))); |
3212 __ movptr(rax, Address(thread, in_bytes(JavaThread::tlab_top_offset()))); |
3211 __ lea(rbx, Address(rax, rdx, Address::times_1)); |
3213 __ lea(rbx, Address(rax, rdx, Address::times_1)); |
3212 __ cmpptr(rbx, Address(thread, in_bytes(JavaThread::tlab_end_offset()))); |
3214 __ cmpptr(rbx, Address(thread, in_bytes(JavaThread::tlab_end_offset()))); |
3213 __ jcc(Assembler::above, allow_shared_alloc ? allocate_shared : slow_case); |
3215 __ jcc(Assembler::above, allow_shared_alloc ? allocate_shared : slow_case); |
3214 __ movptr(Address(thread, in_bytes(JavaThread::tlab_top_offset())), rbx); |
3216 __ movptr(Address(thread, in_bytes(JavaThread::tlab_top_offset())), rbx); |
3245 // rdx: instance size in bytes |
3247 // rdx: instance size in bytes |
3246 __ locked_cmpxchgptr(rbx, heap_top); |
3248 __ locked_cmpxchgptr(rbx, heap_top); |
3247 |
3249 |
3248 // if someone beat us on the allocation, try again, otherwise continue |
3250 // if someone beat us on the allocation, try again, otherwise continue |
3249 __ jcc(Assembler::notEqual, retry); |
3251 __ jcc(Assembler::notEqual, retry); |
|
3252 |
|
3253 __ incr_allocated_bytes(thread, rdx, 0); |
3250 } |
3254 } |
3251 |
3255 |
3252 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { |
3256 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) { |
3253 // The object is initialized before the header. If the object size is |
3257 // The object is initialized before the header. If the object size is |
3254 // zero, go directly to the header initialization. |
3258 // zero, go directly to the header initialization. |
3255 __ bind(initialize_object); |
3259 __ bind(initialize_object); |
3256 __ decrement(rdx, sizeof(oopDesc)); |
3260 __ decrement(rdx, sizeof(oopDesc)); |
3257 __ jcc(Assembler::zero, initialize_header); |
3261 __ jcc(Assembler::zero, initialize_header); |
3258 |
3262 |
3259 // Initialize topmost object field, divide rdx by 8, check if odd and |
3263 // Initialize topmost object field, divide rdx by 8, check if odd and |
3260 // test if zero. |
3264 // test if zero. |
3261 __ xorl(rcx, rcx); // use zero reg to clear memory (shorter code) |
3265 __ xorl(rcx, rcx); // use zero reg to clear memory (shorter code) |
3262 __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd |
3266 __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd |
3263 |
3267 |
3264 // rdx must have been multiple of 8 |
3268 // rdx must have been multiple of 8 |
3265 #ifdef ASSERT |
3269 #ifdef ASSERT |
3266 // make sure rdx was multiple of 8 |
3270 // make sure rdx was multiple of 8 |
3267 Label L; |
3271 Label L; |
3268 // Ignore partial flag stall after shrl() since it is debug VM |
3272 // Ignore partial flag stall after shrl() since it is debug VM |
3269 __ jccb(Assembler::carryClear, L); |
3273 __ jccb(Assembler::carryClear, L); |