src/hotspot/share/gc/shared/stringdedup/stringDedupThread.hpp
author tschatzl
Tue, 29 May 2018 09:26:00 +0200
changeset 50605 7f63c74f0974
parent 50574 fa727a4d7934
child 53244 9807daeb47c4
permissions -rw-r--r--
8202845: Refactor reference processing for improved parallelism Summary: Fold reference processing's nine phases into four to decrease startup and termination time of this phase. Reviewed-by: kbarrett, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     1
/*
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     4
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     8
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    13
 * accompanied this code).
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    14
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    18
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    21
 * questions.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    22
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    23
 */
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    24
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_STRINGDEDUP_STRINGDEDUPTHREAD_HPP
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    26
#define SHARE_VM_GC_SHARED_STRINGDEDUP_STRINGDEDUPTHREAD_HPP
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    27
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    28
#include "gc/shared/concurrentGCThread.hpp"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    29
#include "gc/shared/stringdedup/stringDedupStat.hpp"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    30
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    31
//
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    32
// The deduplication thread is where the actual deduplication occurs. It waits for
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    33
// deduplication candidates to appear on the deduplication queue, removes them from
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    34
// the queue and tries to deduplicate them. It uses the deduplication hashtable to
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    35
// find identical, already existing, character arrays on the heap. The thread runs
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    36
// concurrently with the Java application but participates in safepoints to allow
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    37
// the GC to adjust and unlink oops from the deduplication queue and table.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    38
//
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    39
class StringDedupThread: public ConcurrentGCThread {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    40
protected:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    41
  static StringDedupThread* _thread;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    42
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    43
  StringDedupThread();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    44
  ~StringDedupThread();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    45
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    46
  void print_start(const StringDedupStat* last_stat);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    47
  void print_end(const StringDedupStat* last_stat, const StringDedupStat* total_stat);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    48
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    49
  void run_service() { this->do_deduplication(); }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    50
  void stop_service();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    51
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    52
  void deduplicate_shared_strings(StringDedupStat* stat);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    53
protected:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    54
  virtual void do_deduplication() = 0;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    55
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    56
public:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    57
  static StringDedupThread* thread();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    58
};
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    59
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    60
template <typename S>
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    61
class StringDedupThreadImpl : public StringDedupThread {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    62
private:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    63
  StringDedupThreadImpl() { }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    64
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    65
protected:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    66
  void do_deduplication();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    67
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    68
public:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    69
  static void create();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    70
};
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    71
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    72
#endif // SHARE_VM_GC_SHARED_STRINGDEDUP_STRINGDEDUPTHREAD_HPP