1/*
2 * Copyright (c) 2014, 2019, 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 *
23 */
24#include "precompiled.hpp"
25
26#include "gc/shared/stringdedup/stringDedup.hpp"
27#include "gc/shared/stringdedup/stringDedupQueue.hpp"
28#include "gc/shared/stringdedup/stringDedupTable.hpp"
29#include "gc/shared/stringdedup/stringDedupThread.hpp"
30
31bool StringDedup::_enabled = false;
32
33void StringDedup::gc_prologue(bool resize_and_rehash_table) {
34 assert(is_enabled(), "String deduplication not enabled");
35 StringDedupQueue::gc_prologue();
36 StringDedupTable::gc_prologue(resize_and_rehash_table);
37
38}
39void StringDedup::gc_epilogue() {
40 assert(is_enabled(), "String deduplication not enabled");
41 StringDedupQueue::gc_epilogue();
42 StringDedupTable::gc_epilogue();
43}
44
45void StringDedup::stop() {
46 assert(is_enabled(), "String deduplication not enabled");
47 StringDedupThread::thread()->stop();
48}
49
50void StringDedup::deduplicate(oop java_string) {
51 assert(is_enabled(), "String deduplication not enabled");
52 StringDedupStat dummy; // Statistics from this path is never used
53 StringDedupTable::deduplicate(java_string, &dummy);
54}
55
56void StringDedup::parallel_unlink(StringDedupUnlinkOrOopsDoClosure* unlink, uint worker_id) {
57 assert(is_enabled(), "String deduplication not enabled");
58 StringDedupQueue::unlink_or_oops_do(unlink);
59 StringDedupTable::unlink_or_oops_do(unlink, worker_id);
60}
61
62void StringDedup::threads_do(ThreadClosure* tc) {
63 assert(is_enabled(), "String deduplication not enabled");
64 tc->do_thread(StringDedupThread::thread());
65}
66
67void StringDedup::print_worker_threads_on(outputStream* st) {
68 assert(is_enabled(), "String deduplication not enabled");
69 StringDedupThread::thread()->print_on(st);
70 st->cr();
71}
72
73void StringDedup::verify() {
74 assert(is_enabled(), "String deduplication not enabled");
75 StringDedupQueue::verify();
76 StringDedupTable::verify();
77}
78
79
80StringDedupUnlinkOrOopsDoClosure::StringDedupUnlinkOrOopsDoClosure(BoolObjectClosure* is_alive,
81 OopClosure* keep_alive) :
82 _always_true(),
83 _do_nothing(),
84 _is_alive(is_alive != NULL ? is_alive : &_always_true),
85 _keep_alive(keep_alive != NULL ? keep_alive : &_do_nothing) {
86}
87