src/hotspot/share/gc/epsilon/epsilonThreadLocalData.hpp
author tschatzl
Wed, 08 Aug 2018 15:31:06 +0200
changeset 51332 c25572739e7c
parent 50523 7b7c75d87f9b
child 53244 9807daeb47c4
permissions -rw-r--r--
8208669: GC changes to allow enabling -Wreorder Reviewed-by: kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50523
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     1
/*
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     2
 * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     3
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     6
 * published by the Free Software Foundation.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     7
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     8
 * This code is distributed in the hope that it will be useful, but WITHOUT
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
     9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    10
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    11
 * version 2 for more details (a copy is included in the LICENSE file that
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    12
 * accompanied this code).
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    13
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License version
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    15
 * 2 along with this work; if not, write to the Free Software Foundation,
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    16
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    17
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    18
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    19
 * or visit www.oracle.com if you need additional information or have any
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    20
 * questions.
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    21
 *
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    22
 */
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    23
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    24
#ifndef SHARE_VM_GC_EPSILON_EPSILONTHREADLOCALDATA_HPP
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    25
#define SHARE_VM_GC_EPSILON_EPSILONTHREADLOCALDATA_HPP
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    26
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    27
#include "runtime/thread.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    28
#include "utilities/debug.hpp"
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    29
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    30
class EpsilonThreadLocalData {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    31
private:
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    32
  size_t _ergo_tlab_size;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    33
  int64_t _last_tlab_time;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    34
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    35
  EpsilonThreadLocalData() :
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    36
          _ergo_tlab_size(0),
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    37
          _last_tlab_time(0) {}
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    38
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    39
  static EpsilonThreadLocalData* data(Thread* thread) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    40
    assert(UseEpsilonGC, "Sanity");
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    41
    return thread->gc_data<EpsilonThreadLocalData>();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    42
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    43
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    44
public:
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    45
  static void create(Thread* thread) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    46
    new (data(thread)) EpsilonThreadLocalData();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    47
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    48
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    49
  static void destroy(Thread* thread) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    50
    data(thread)->~EpsilonThreadLocalData();
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    51
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    52
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    53
  static size_t ergo_tlab_size(Thread *thread) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    54
    return data(thread)->_ergo_tlab_size;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    55
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    56
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    57
  static int64_t last_tlab_time(Thread *thread) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    58
    return data(thread)->_last_tlab_time;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    59
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    60
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    61
  static void set_ergo_tlab_size(Thread *thread, size_t val) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    62
    data(thread)->_ergo_tlab_size = val;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    63
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    64
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    65
  static void set_last_tlab_time(Thread *thread, int64_t time) {
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    66
    data(thread)->_last_tlab_time = time;
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    67
  }
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    68
};
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    69
7b7c75d87f9b 8204180: Implementation: JEP 318: Epsilon, A No-Op Garbage Collector
shade
parents:
diff changeset
    70
#endif // SHARE_VM_GC_EPSILON_EPSILONTHREADLOCALDATA_HPP