1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
3395 assert_different_registers(top, t1, t2, t3, G4, G5 /* preserve G4 and G5 */);
3396 Label do_refill, discard_tlab;
3397
3398 if (!Universe::heap()->supports_inline_contig_alloc()) {
3399 // No allocation in the shared eden.
3400 ba(slow_case);
3401 delayed()->nop();
3402 }
3403
3404 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), top);
3405 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t1);
3406 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), t2);
3407
3408 // calculate amount of free space
3409 sub(t1, top, t1);
3410 srl_ptr(t1, LogHeapWordSize, t1);
3411
3412 // Retain tlab and allocate object in shared space if
3413 // the amount free in the tlab is too large to discard.
3414 cmp(t1, t2);
3415 brx(Assembler::lessEqual, false, Assembler::pt, discard_tlab);
3416
3417 // increment waste limit to prevent getting stuck on this slow path
3418 delayed()->add(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment(), t2);
3419 st_ptr(t2, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
3420 if (TLABStats) {
3421 // increment number of slow_allocations
3422 ld(G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()), t2);
3423 add(t2, 1, t2);
3424 stw(t2, G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()));
3425 }
3426 ba(try_eden);
3427 delayed()->nop();
3428
3429 bind(discard_tlab);
3430 if (TLABStats) {
3431 // increment number of refills
3432 ld(G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()), t2);
3433 add(t2, 1, t2);
3434 stw(t2, G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()));
3435 // accumulate wastage
3436 ld(G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()), t2);
3437 add(t2, t1, t2);
3438 stw(t2, G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()));
|
1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
3395 assert_different_registers(top, t1, t2, t3, G4, G5 /* preserve G4 and G5 */);
3396 Label do_refill, discard_tlab;
3397
3398 if (!Universe::heap()->supports_inline_contig_alloc()) {
3399 // No allocation in the shared eden.
3400 ba(slow_case);
3401 delayed()->nop();
3402 }
3403
3404 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), top);
3405 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t1);
3406 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), t2);
3407
3408 // calculate amount of free space
3409 sub(t1, top, t1);
3410 srl_ptr(t1, LogHeapWordSize, t1);
3411
3412 // Retain tlab and allocate object in shared space if
3413 // the amount free in the tlab is too large to discard.
3414 cmp(t1, t2);
3415
3416 // set64 does not use the temp register if the given constant is 32 bit. So
3417 // we can just use any register; using G0 results in ignoring of the upper 32 bit
3418 // of that value.
3419 set64(ThreadLocalAllocBuffer::refill_waste_limit_increment(), t3, G0);
3420 brx(Assembler::lessEqual, false, Assembler::pt, discard_tlab);
3421
3422 // increment waste limit to prevent getting stuck on this slow path
3423 delayed()->add(t2, t3, t2);
3424 st_ptr(t2, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
3425 if (TLABStats) {
3426 // increment number of slow_allocations
3427 ld(G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()), t2);
3428 add(t2, 1, t2);
3429 stw(t2, G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()));
3430 }
3431 ba(try_eden);
3432 delayed()->nop();
3433
3434 bind(discard_tlab);
3435 if (TLABStats) {
3436 // increment number of refills
3437 ld(G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()), t2);
3438 add(t2, 1, t2);
3439 stw(t2, G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()));
3440 // accumulate wastage
3441 ld(G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()), t2);
3442 add(t2, t1, t2);
3443 stw(t2, G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()));
|