src/hotspot/share/gc/g1/g1StringDedup.hpp
author tschatzl
Tue, 29 Jan 2019 11:30:17 +0100
changeset 53536 482109fae02b
parent 53244 9807daeb47c4
permissions -rw-r--r--
8213229: Investigate treating StringTable as weak in young collections Reviewed-by: zgu, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50574
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     4
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     8
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    13
 * accompanied this code).
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    14
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    18
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    21
 * questions.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    22
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    23
 */
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50574
diff changeset
    25
#ifndef SHARE_GC_G1_G1STRINGDEDUP_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50574
diff changeset
    26
#define SHARE_GC_G1_G1STRINGDEDUP_HPP
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    27
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    28
//
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47885
diff changeset
    29
// G1 string deduplication candidate selection
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    30
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    31
// An object is considered a deduplication candidate if all of the following
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    32
// statements are true:
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    33
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    34
// - The object is an instance of java.lang.String
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    35
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    36
// - The object is being evacuated from a young heap region
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    37
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    38
// - The object is being evacuated to a young/survivor heap region and the
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    39
//   object's age is equal to the deduplication age threshold
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    40
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    41
//   or
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    42
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    43
//   The object is being evacuated to an old heap region and the object's age is
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    44
//   less than the deduplication age threshold
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    45
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    46
// Once an string object has been promoted to an old region, or its age is higher
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    47
// than the deduplication age threshold, is will never become a candidate again.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    48
// This approach avoids making the same object a candidate more than once.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    49
//
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    50
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47885
diff changeset
    51
#include "gc/shared/stringdedup/stringDedup.hpp"
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    52
#include "memory/allocation.hpp"
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    53
#include "oops/oop.hpp"
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    54
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    55
class OopClosure;
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    56
class BoolObjectClosure;
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47885
diff changeset
    57
class G1GCPhaseTimes;
46348
5803de68c14d 8171238: Unify cleanup code used in G1 Remark and Full GC marking
sjohanss
parents: 40655
diff changeset
    58
class G1StringDedupUnlinkOrOopsDoClosure;
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    59
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    60
//
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47885
diff changeset
    61
// G1 interface for interacting with string deduplication.
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    62
//
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47885
diff changeset
    63
class G1StringDedup : public StringDedup {
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    64
private:
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    65
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    66
  // Candidate selection policies, returns true if the given object is
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    67
  // candidate for string deduplication.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    68
  static bool is_candidate_from_mark(oop obj);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    69
  static bool is_candidate_from_evacuation(bool from_young, bool to_young, oop obj);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    70
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    71
public:
24093
095cc0a63ed9 8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV
pliden
parents: 23472
diff changeset
    72
  // Initialize string deduplication.
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    73
  static void initialize();
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    74
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    75
  // Enqueues a deduplication candidate for later processing by the deduplication
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    76
  // thread. Before enqueuing, these functions apply the appropriate candidate
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    77
  // selection policy to filters out non-candidates.
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    78
  static void enqueue_from_mark(oop java_string, uint worker_id);
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    79
  static void enqueue_from_evacuation(bool from_young, bool to_young,
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    80
                                      unsigned int queue, oop java_string);
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    81
};
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    82
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50574
diff changeset
    83
#endif // SHARE_GC_G1_G1STRINGDEDUP_HPP