hotspot/src/share/vm/gc/g1/workerDataArray.hpp
author ehelin
Thu, 29 Oct 2015 14:58:44 +0100
changeset 33623 8b6afaf25abd
child 35061 be6025ebffea
permissions -rw-r--r--
8140393: Move WorkerDataArray to its own file Reviewed-by: tschatzl, mgerdin, tbenson
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33623
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     1
/*
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     4
 *
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     8
 *
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    13
 * accompanied this code).
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    14
 *
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    18
 *
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    21
 * questions.
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    22
 *
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    23
 */
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    24
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    25
#include "memory/allocation.hpp"
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    26
#include "utilities/debug.hpp"
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    27
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    28
template <class T>
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    29
class WorkerDataArray  : public CHeapObj<mtGC> {
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    30
  friend class G1GCParPhasePrinter;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    31
  T*          _data;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    32
  uint        _length;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    33
  const char* _title;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    34
  bool        _print_sum;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    35
  int         _log_level;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    36
  uint        _indent_level;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    37
  bool        _enabled;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    38
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    39
  WorkerDataArray<size_t>* _thread_work_items;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    40
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    41
  NOT_PRODUCT(inline T uninitialized() const;)
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    42
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    43
  void set_all(T value);
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    44
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    45
 public:
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    46
  WorkerDataArray(uint length,
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    47
                  const char* title,
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    48
                  bool print_sum,
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    49
                  int log_level,
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    50
                  uint indent_level);
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    51
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    52
  ~WorkerDataArray();
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    53
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    54
  void link_thread_work_items(WorkerDataArray<size_t>* thread_work_items);
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    55
  void set_thread_work_item(uint worker_i, size_t value);
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    56
  WorkerDataArray<size_t>* thread_work_items() const {
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    57
    return _thread_work_items;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    58
  }
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    59
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    60
  void set(uint worker_i, T value);
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    61
  T get(uint worker_i) const;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    62
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    63
  void add(uint worker_i, T value);
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    64
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    65
  double average(uint active_threads) const;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    66
  T sum(uint active_threads) const;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    67
  T minimum(uint active_threads) const;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    68
  T maximum(uint active_threads) const;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    69
  T diff(uint active_threads) const;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    70
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    71
  uint indentation() const {
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    72
    return _indent_level;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    73
  }
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    74
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    75
  const char* title() const {
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    76
    return _title;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    77
  }
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    78
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    79
  bool should_print_sum() const {
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    80
    return _print_sum;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    81
  }
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    82
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    83
  int log_level() const {
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    84
    return _log_level;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    85
  }
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    86
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    87
  void clear();
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    88
  void set_enabled(bool enabled) {
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    89
    _enabled = enabled;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    90
  }
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    91
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    92
  void reset() PRODUCT_RETURN;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    93
  void verify(uint active_threads) const PRODUCT_RETURN;
8b6afaf25abd 8140393: Move WorkerDataArray to its own file
ehelin
parents:
diff changeset
    94
};