src/hotspot/share/gc/shared/workerDataArray.hpp
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 59198 92c98aa0f801
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     4
 *
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     7
 * published by the Free Software Foundation.
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     8
 *
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    13
 * accompanied this code).
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    14
 *
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    18
 *
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    21
 * questions.
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    22
 *
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    23
 */
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    25
#ifndef SHARE_GC_SHARED_WORKERDATAARRAY_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    26
#define SHARE_GC_SHARED_WORKERDATAARRAY_HPP
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    27
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    28
#include "memory/allocation.hpp"
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    29
#include "utilities/debug.hpp"
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    30
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    31
class outputStream;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    32
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    33
template <class T>
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    34
class WorkerDataArray  : public CHeapObj<mtGC> {
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    35
  friend class WDAPrinter;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    36
public:
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54465
diff changeset
    37
  static const uint MaxThreadWorkItems = 6;
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    38
private:
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    39
  T*          _data;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    40
  uint        _length;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    41
  const char* _title;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    42
59198
92c98aa0f801 8228609: G1 copy cost prediction uses used vs. actual copied byte
tschatzl
parents: 55510
diff changeset
    43
  bool _is_serial;
92c98aa0f801 8228609: G1 copy cost prediction uses used vs. actual copied byte
tschatzl
parents: 55510
diff changeset
    44
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    45
  WorkerDataArray<size_t>* _thread_work_items[MaxThreadWorkItems];
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    46
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    47
 public:
59198
92c98aa0f801 8228609: G1 copy cost prediction uses used vs. actual copied byte
tschatzl
parents: 55510
diff changeset
    48
  WorkerDataArray(uint length, const char* title, bool is_serial = false);
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    49
  ~WorkerDataArray();
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    50
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    51
  void link_thread_work_items(WorkerDataArray<size_t>* thread_work_items, uint index = 0);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    52
  void set_thread_work_item(uint worker_i, size_t value, uint index = 0);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    53
  void add_thread_work_item(uint worker_i, size_t value, uint index = 0);
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 47216
diff changeset
    54
  void set_or_add_thread_work_item(uint worker_i, size_t value, uint index = 0);
54465
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53244
diff changeset
    55
  size_t get_thread_work_item(uint worker_i, uint index = 0);
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 47216
diff changeset
    56
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    57
  WorkerDataArray<size_t>* thread_work_items(uint index = 0) const {
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    58
    assert(index < MaxThreadWorkItems, "Tried to access thread work item %u max %u", index, MaxThreadWorkItems);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    59
    return _thread_work_items[index];
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    60
  }
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    61
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    62
  static T uninitialized();
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    63
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    64
  void set(uint worker_i, T value);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    65
  T get(uint worker_i) const;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    66
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    67
  void add(uint worker_i, T value);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    68
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    69
  // The sum() and average() methods below consider uninitialized slots to be 0.
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    70
  double average() const;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    71
  T sum() const;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    72
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    73
  const char* title() const {
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    74
    return _title;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    75
  }
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    76
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    77
  void reset();
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    78
  void set_all(T value);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    79
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    80
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    81
 private:
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    82
  class WDAPrinter {
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    83
  public:
59198
92c98aa0f801 8228609: G1 copy cost prediction uses used vs. actual copied byte
tschatzl
parents: 55510
diff changeset
    84
    static void summary(outputStream* out, double time);
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    85
    static void summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum);
59198
92c98aa0f801 8228609: G1 copy cost prediction uses used vs. actual copied byte
tschatzl
parents: 55510
diff changeset
    86
    static void summary(outputStream* out, size_t value);
46795
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    87
    static void summary(outputStream* out, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    88
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    89
    static void details(const WorkerDataArray<double>* phase, outputStream* out);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    90
    static void details(const WorkerDataArray<size_t>* phase, outputStream* out);
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    91
  };
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    92
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    93
 public:
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    94
  void print_summary_on(outputStream* out, bool print_sum = true) const;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    95
  void print_details_on(outputStream* out) const;
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    96
};
623a5e42deb6 8173335: Improve logging for j.l.ref.reference processing
sangheki
parents:
diff changeset
    97
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    98
#endif // SHARE_GC_SHARED_WORKERDATAARRAY_HPP