1 /*
2 * Copyright (c) 1999, 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 *
25 #include "precompiled.hpp"
26 #include "gc/shared/genCollectedHeap.hpp"
27 #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
28 #include "logging/log.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "memory/universe.inline.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "runtime/thread.inline.hpp"
33 #include "utilities/copy.hpp"
34
35 // Thread-Local Edens support
36
37 // static member initialization
38 size_t ThreadLocalAllocBuffer::_max_size = 0;
39 int ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch = 0;
40 unsigned ThreadLocalAllocBuffer::_target_refills = 0;
41 GlobalTLABStats* ThreadLocalAllocBuffer::_global_stats = NULL;
42
43 void ThreadLocalAllocBuffer::clear_before_allocation() {
44 _slow_refill_waste += (unsigned)remaining();
45 make_parsable(true); // also retire the TLAB
46 }
47
48 void ThreadLocalAllocBuffer::accumulate_statistics_before_gc() {
49 global_stats()->initialize();
50
51 for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
52 thread->tlab().accumulate_statistics();
53 thread->tlab().initialize_statistics();
54 }
55
56 // Publish new stats if some allocation occurred.
57 if (global_stats()->allocation() != 0) {
58 global_stats()->publish();
59 global_stats()->print();
60 }
61 }
62
63 void ThreadLocalAllocBuffer::accumulate_statistics() {
64 Thread* thread = myThread();
|
1 /*
2 * Copyright (c) 1999, 2017, 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 *
25 #include "precompiled.hpp"
26 #include "gc/shared/genCollectedHeap.hpp"
27 #include "gc/shared/threadLocalAllocBuffer.inline.hpp"
28 #include "logging/log.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "memory/universe.inline.hpp"
31 #include "oops/oop.inline.hpp"
32 #include "runtime/thread.inline.hpp"
33 #include "utilities/copy.hpp"
34
35 // Thread-Local Edens support
36
37 // static member initialization
38 size_t ThreadLocalAllocBuffer::_max_size = 0;
39 int ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch = 0;
40 unsigned ThreadLocalAllocBuffer::_target_refills = 0;
41 GlobalTLABStats* ThreadLocalAllocBuffer::_global_stats = NULL;
42
43 void ThreadLocalAllocBuffer::clear_before_allocation() {
44 _slow_refill_waste += (unsigned)remaining();
45 assert(!ZapUnusedHeapArea || _reserve_for_allocation_prefetch > 0 ||
46 top() == NULL || *(intptr_t*)top() != 0, "overzeroing detected");
47 make_parsable(true); // also retire the TLAB
48 }
49
50 void ThreadLocalAllocBuffer::accumulate_statistics_before_gc() {
51 global_stats()->initialize();
52
53 for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
54 thread->tlab().accumulate_statistics();
55 thread->tlab().initialize_statistics();
56 }
57
58 // Publish new stats if some allocation occurred.
59 if (global_stats()->allocation() != 0) {
60 global_stats()->publish();
61 global_stats()->print();
62 }
63 }
64
65 void ThreadLocalAllocBuffer::accumulate_statistics() {
66 Thread* thread = myThread();
|