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
25#ifndef SHARE_GC_G1_G1STRINGDEDUP_HPP
26#define SHARE_GC_G1_G1STRINGDEDUP_HPP
27
28//
29// G1 string deduplication candidate selection
30//
31// An object is considered a deduplication candidate if all of the following
32// statements are true:
33//
34// - The object is an instance of java.lang.String
35//
36// - The object is being evacuated from a young heap region
37//
38// - The object is being evacuated to a young/survivor heap region and the
39// object's age is equal to the deduplication age threshold
40//
41// or
42//
43// The object is being evacuated to an old heap region and the object's age is
44// less than the deduplication age threshold
45//
46// Once an string object has been promoted to an old region, or its age is higher
47// than the deduplication age threshold, is will never become a candidate again.
48// This approach avoids making the same object a candidate more than once.
49//
50
51#include "gc/shared/stringdedup/stringDedup.hpp"
52#include "memory/allocation.hpp"
53#include "oops/oop.hpp"
54
55class OopClosure;
56class BoolObjectClosure;
57class G1GCPhaseTimes;
58class G1StringDedupUnlinkOrOopsDoClosure;
59
60//
61// G1 interface for interacting with string deduplication.
62//
63class G1StringDedup : public StringDedup {
64private:
65
66 // Candidate selection policies, returns true if the given object is
67 // candidate for string deduplication.
68 static bool is_candidate_from_mark(oop obj);
69 static bool is_candidate_from_evacuation(bool from_young, bool to_young, oop obj);
70
71public:
72 // Initialize string deduplication.
73 static void initialize();
74
75 // Enqueues a deduplication candidate for later processing by the deduplication
76 // thread. Before enqueuing, these functions apply the appropriate candidate
77 // selection policy to filters out non-candidates.
78 static void enqueue_from_mark(oop java_string, uint worker_id);
79 static void enqueue_from_evacuation(bool from_young, bool to_young,
80 unsigned int queue, oop java_string);
81};
82
83#endif // SHARE_GC_G1_G1STRINGDEDUP_HPP
84