src/hotspot/share/gc/z/zThread.hpp
author eosterlund
Tue, 12 Nov 2019 20:01:23 +0000
changeset 59038 b9a42ca342db
parent 58706 d8e211419aaf
permissions -rw-r--r--
8233061: ZGC: Enforce memory ordering in segmented bit maps Reviewed-by: pliden, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     1
/*
58706
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     4
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     8
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    13
 * accompanied this code).
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    14
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    18
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    21
 * questions.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    22
 */
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    23
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    24
#ifndef SHARE_GC_Z_ZTHREAD_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    25
#define SHARE_GC_Z_ZTHREAD_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    27
#include "memory/allocation.hpp"
58125
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    28
#include "utilities/globalDefinitions.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    29
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    30
class ZThread : public AllStatic {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    31
  friend class ZTask;
53072
82d3f0820d37 8215487: ZGC: ZRuntimeWorkers incorrectly identify themselves as ZWorkers
pliden
parents: 50525
diff changeset
    32
  friend class ZWorkersInitializeTask;
82d3f0820d37 8215487: ZGC: ZRuntimeWorkers incorrectly identify themselves as ZWorkers
pliden
parents: 50525
diff changeset
    33
  friend class ZRuntimeWorkersInitializeTask;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    34
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    35
private:
58125
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    36
  static THREAD_LOCAL bool      _initialized;
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    37
  static THREAD_LOCAL uintptr_t _id;
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    38
  static THREAD_LOCAL bool      _is_vm;
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    39
  static THREAD_LOCAL bool      _is_java;
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    40
  static THREAD_LOCAL bool      _is_worker;
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    41
  static THREAD_LOCAL bool      _is_runtime_worker;
9b4717ca9bd1 8230878: ZGC: Use THREAD_LOCAL instead of __thread
pliden
parents: 53072
diff changeset
    42
  static THREAD_LOCAL uint      _worker_id;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    43
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    44
  static void initialize();
58706
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
    45
  static void ensure_initialized();
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    46
53072
82d3f0820d37 8215487: ZGC: ZRuntimeWorkers incorrectly identify themselves as ZWorkers
pliden
parents: 50525
diff changeset
    47
  static void set_worker();
82d3f0820d37 8215487: ZGC: ZRuntimeWorkers incorrectly identify themselves as ZWorkers
pliden
parents: 50525
diff changeset
    48
  static void set_runtime_worker();
82d3f0820d37 8215487: ZGC: ZRuntimeWorkers incorrectly identify themselves as ZWorkers
pliden
parents: 50525
diff changeset
    49
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    50
  static bool has_worker_id();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    51
  static void set_worker_id(uint worker_id);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    52
  static void clear_worker_id();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    53
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    54
public:
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    55
  static const char* name();
58706
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
    56
  static uintptr_t id();
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
    57
  static bool is_vm();
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
    58
  static bool is_java();
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
    59
  static bool is_worker();
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
    60
  static bool is_runtime_worker();
d8e211419aaf 8232236: ZGC: Move ZThread inline funtions to zThread.inline.hpp
pliden
parents: 58125
diff changeset
    61
  static uint worker_id();
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    62
};
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    63
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    64
#endif // SHARE_GC_Z_ZTHREAD_HPP