src/hotspot/share/oops/access.hpp
author iklam
Thu, 26 Apr 2018 13:40:58 -0700
changeset 50039 9fec54fe663d
parent 49658 8237a91c1cca
child 50389 7e8c0409a747
permissions -rw-r--r--
8197954: Remove unnecessary intermediary APIs from AppCDS implementation Reviewed-by: jiangli, ccheung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     1
/*
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 47998
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     4
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     8
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    13
 * accompanied this code).
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    14
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    18
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    21
 * questions.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    22
 *
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    23
 */
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    24
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    25
#ifndef SHARE_OOPS_ACCESS_HPP
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    26
#define SHARE_OOPS_ACCESS_HPP
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    27
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    28
#include "memory/allocation.hpp"
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    29
#include "oops/accessBackend.hpp"
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    30
#include "oops/accessDecorators.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    31
#include "oops/oopsHierarchy.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    32
#include "utilities/debug.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    33
#include "utilities/globalDefinitions.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    34
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    35
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    36
// = GENERAL =
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    37
// Access is an API for performing accesses with declarative semantics. Each access can have a number of "decorators".
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    38
// A decorator is an attribute or property that affects the way a memory access is performed in some way.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    39
// There are different groups of decorators. Some have to do with memory ordering, others to do with,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    40
// e.g. strength of references, strength of GC barriers, or whether compression should be applied or not.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    41
// Some decorators are set at buildtime, such as whether primitives require GC barriers or not, others
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    42
// at callsites such as whether an access is in the heap or not, and others are resolved at runtime
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    43
// such as GC-specific barriers and encoding/decoding compressed oops. For more information about what
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    44
// decorators are available, cf. oops/accessDecorators.hpp.
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    45
// By pipelining handling of these decorators, the design of the Access API allows separation of concern
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    46
// over the different orthogonal concerns of decorators, while providing a powerful way of
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    47
// expressing these orthogonal semantic properties in a unified way.
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    48
//
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    49
// == OPERATIONS ==
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    50
// * load: Load a value from an address.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    51
// * load_at: Load a value from an internal pointer relative to a base object.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    52
// * store: Store a value at an address.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    53
// * store_at: Store a value in an internal pointer relative to a base object.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    54
// * atomic_cmpxchg: Atomically compare-and-swap a new value at an address if previous value matched the compared value.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    55
// * atomic_cmpxchg_at: Atomically compare-and-swap a new value at an internal pointer address if previous value matched the compared value.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    56
// * atomic_xchg: Atomically swap a new value at an address if previous value matched the compared value.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    57
// * atomic_xchg_at: Atomically swap a new value at an internal pointer address if previous value matched the compared value.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    58
// * arraycopy: Copy data from one heap array to another heap array.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    59
// * clone: Clone the contents of an object to a newly allocated object.
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48966
diff changeset
    60
// * resolve: Resolve a stable to-space invariant oop that is guaranteed not to relocate its payload until a subsequent thread transition.
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    61
// * equals: Object equality, e.g. when different copies of the same objects are in use (from-space vs. to-space)
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    62
//
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    63
// == IMPLEMENTATION ==
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    64
// Each access goes through the following steps in a template pipeline.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    65
// There are essentially 5 steps for each access:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    66
// * Step 1:   Set default decorators and decay types. This step gets rid of CV qualifiers
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    67
//             and sets default decorators to sensible values.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    68
// * Step 2:   Reduce types. This step makes sure there is only a single T type and not
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    69
//             multiple types. The P type of the address and T type of the value must
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    70
//             match.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    71
// * Step 3:   Pre-runtime dispatch. This step checks whether a runtime call can be
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    72
//             avoided, and in that case avoids it (calling raw accesses or
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    73
//             primitive accesses in a build that does not require primitive GC barriers)
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    74
// * Step 4:   Runtime-dispatch. This step performs a runtime dispatch to the corresponding
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    75
//             BarrierSet::AccessBarrier accessor that attaches GC-required barriers
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    76
//             to the access.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    77
// * Step 5.a: Barrier resolution. This step is invoked the first time a runtime-dispatch
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    78
//             happens for an access. The appropriate BarrierSet::AccessBarrier accessor
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    79
//             is resolved, then the function pointer is updated to that accessor for
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    80
//             future invocations.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    81
// * Step 5.b: Post-runtime dispatch. This step now casts previously unknown types such
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    82
//             as the address type of an oop on the heap (is it oop* or narrowOop*) to
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    83
//             the appropriate type. It also splits sufficiently orthogonal accesses into
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    84
//             different functions, such as whether the access involves oops or primitives
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    85
//             and whether the access is performed on the heap or outside. Then the
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    86
//             appropriate BarrierSet::AccessBarrier is called to perform the access.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    87
//
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    88
// The implementation of step 1-4 resides in in accessBackend.hpp, to allow selected
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    89
// accesses to be accessible from only access.hpp, as opposed to access.inline.hpp.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    90
// Steps 5.a and 5.b require knowledge about the GC backends, and therefore needs to
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    91
// include the various GC backend .inline.hpp headers. Their implementation resides in
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    92
// access.inline.hpp. The accesses that are allowed through the access.hpp file
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
    93
// must be instantiated in access.cpp using the INSTANTIATE_HPP_ACCESS macro.
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    94
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    95
template <DecoratorSet decorators = INTERNAL_EMPTY>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    96
class Access: public AllStatic {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    97
  // This function asserts that if an access gets passed in a decorator outside
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    98
  // of the expected_decorators, then something is wrong. It additionally checks
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    99
  // the consistency of the decorators so that supposedly disjoint decorators are indeed
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   100
  // disjoint. For example, an access can not be both in heap and on root at the
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   101
  // same time.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   102
  template <DecoratorSet expected_decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   103
  static void verify_decorators();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   104
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   105
  template <DecoratorSet expected_mo_decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   106
  static void verify_primitive_decorators() {
48966
e6eb66d2e765 8197454: Need Access decorator for storing oop into uninitialized location
kbarrett
parents: 48784
diff changeset
   107
    const DecoratorSet primitive_decorators = (AS_DECORATOR_MASK ^ AS_NO_KEEPALIVE ^ AS_DEST_NOT_INITIALIZED) |
e6eb66d2e765 8197454: Need Access decorator for storing oop into uninitialized location
kbarrett
parents: 48784
diff changeset
   108
                                              IN_HEAP | IN_HEAP_ARRAY;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   109
    verify_decorators<expected_mo_decorators | primitive_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   110
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   111
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   112
  template <DecoratorSet expected_mo_decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   113
  static void verify_oop_decorators() {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   114
    const DecoratorSet oop_decorators = AS_DECORATOR_MASK | IN_DECORATOR_MASK |
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   115
                                        (ON_DECORATOR_MASK ^ ON_UNKNOWN_OOP_REF) | // no unknown oop refs outside of the heap
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 47998
diff changeset
   116
                                        OOP_DECORATOR_MASK;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   117
    verify_decorators<expected_mo_decorators | oop_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   118
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   119
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   120
  template <DecoratorSet expected_mo_decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   121
  static void verify_heap_oop_decorators() {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   122
    const DecoratorSet heap_oop_decorators = AS_DECORATOR_MASK | ON_DECORATOR_MASK |
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   123
                                             OOP_DECORATOR_MASK | (IN_DECORATOR_MASK ^
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 47998
diff changeset
   124
                                                                   (IN_ROOT | IN_CONCURRENT_ROOT)); // no root accesses in the heap
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   125
    verify_decorators<expected_mo_decorators | heap_oop_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   126
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   127
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   128
  static const DecoratorSet load_mo_decorators = MO_UNORDERED | MO_VOLATILE | MO_RELAXED | MO_ACQUIRE | MO_SEQ_CST;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   129
  static const DecoratorSet store_mo_decorators = MO_UNORDERED | MO_VOLATILE | MO_RELAXED | MO_RELEASE | MO_SEQ_CST;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   130
  static const DecoratorSet atomic_xchg_mo_decorators = MO_SEQ_CST;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   131
  static const DecoratorSet atomic_cmpxchg_mo_decorators = MO_RELAXED | MO_SEQ_CST;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   132
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   133
public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   134
  // Primitive heap accesses
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   135
  static inline AccessInternal::LoadAtProxy<decorators> load_at(oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   136
    verify_primitive_decorators<load_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   137
    return AccessInternal::LoadAtProxy<decorators>(base, offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   138
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   139
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   140
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   141
  static inline void store_at(oop base, ptrdiff_t offset, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   142
    verify_primitive_decorators<store_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   143
    AccessInternal::store_at<decorators>(base, offset, value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   144
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   145
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   146
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   147
  static inline T atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   148
    verify_primitive_decorators<atomic_cmpxchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   149
    return AccessInternal::atomic_cmpxchg_at<decorators>(new_value, base, offset, compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   150
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   151
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   152
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   153
  static inline T atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   154
    verify_primitive_decorators<atomic_xchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   155
    return AccessInternal::atomic_xchg_at<decorators>(new_value, base, offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   156
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   157
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   158
  template <typename T>
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 49041
diff changeset
   159
  static inline void arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T *dst, size_t length) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   160
    verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP |
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   161
                      AS_DECORATOR_MASK>();
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 49041
diff changeset
   162
    AccessInternal::arraycopy<decorators>(src_obj, dst_obj, src, dst, length);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   163
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   164
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   165
  // Oop heap accesses
49591
272dff61a2de 8200113: Make Access load proxys smarter
eosterlund
parents: 49383
diff changeset
   166
  static inline AccessInternal::OopLoadAtProxy<decorators> oop_load_at(oop base, ptrdiff_t offset) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   167
    verify_heap_oop_decorators<load_mo_decorators>();
49591
272dff61a2de 8200113: Make Access load proxys smarter
eosterlund
parents: 49383
diff changeset
   168
    return AccessInternal::OopLoadAtProxy<decorators>(base, offset);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   169
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   170
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   171
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   172
  static inline void oop_store_at(oop base, ptrdiff_t offset, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   173
    verify_heap_oop_decorators<store_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   174
    typedef typename AccessInternal::OopOrNarrowOop<T>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   175
    OopType oop_value = value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   176
    AccessInternal::store_at<decorators | INTERNAL_VALUE_IS_OOP>(base, offset, oop_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   177
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   178
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   179
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   180
  static inline T oop_atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   181
    verify_heap_oop_decorators<atomic_cmpxchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   182
    typedef typename AccessInternal::OopOrNarrowOop<T>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   183
    OopType new_oop_value = new_value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   184
    OopType compare_oop_value = compare_value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   185
    return AccessInternal::atomic_cmpxchg_at<decorators | INTERNAL_VALUE_IS_OOP>(new_oop_value, base, offset, compare_oop_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   186
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   187
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   188
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   189
  static inline T oop_atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   190
    verify_heap_oop_decorators<atomic_xchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   191
    typedef typename AccessInternal::OopOrNarrowOop<T>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   192
    OopType new_oop_value = new_value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   193
    return AccessInternal::atomic_xchg_at<decorators | INTERNAL_VALUE_IS_OOP>(new_oop_value, base, offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   194
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   195
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   196
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   197
  static inline bool oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T *dst, size_t length) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   198
    verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP | AS_DECORATOR_MASK>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   199
    return AccessInternal::arraycopy<decorators | INTERNAL_VALUE_IS_OOP>(src_obj, dst_obj, src, dst, length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   200
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   201
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   202
  // Clone an object from src to dst
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   203
  static inline void clone(oop src, oop dst, size_t size) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   204
    verify_decorators<IN_HEAP>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   205
    AccessInternal::clone<decorators>(src, dst, size);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   206
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   207
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   208
  // Primitive accesses
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   209
  template <typename P>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   210
  static inline P load(P* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   211
    verify_primitive_decorators<load_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   212
    return AccessInternal::load<decorators, P, P>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   213
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   214
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   215
  template <typename P, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   216
  static inline void store(P* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   217
    verify_primitive_decorators<store_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   218
    AccessInternal::store<decorators>(addr, value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   219
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   220
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   221
  template <typename P, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   222
  static inline T atomic_cmpxchg(T new_value, P* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   223
    verify_primitive_decorators<atomic_cmpxchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   224
    return AccessInternal::atomic_cmpxchg<decorators>(new_value, addr, compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   225
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   226
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   227
  template <typename P, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   228
  static inline T atomic_xchg(T new_value, P* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   229
    verify_primitive_decorators<atomic_xchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   230
    return AccessInternal::atomic_xchg<decorators>(new_value, addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   231
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   232
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   233
  // Oop accesses
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   234
  template <typename P>
49591
272dff61a2de 8200113: Make Access load proxys smarter
eosterlund
parents: 49383
diff changeset
   235
  static inline AccessInternal::OopLoadProxy<P, decorators> oop_load(P* addr) {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   236
    verify_oop_decorators<load_mo_decorators>();
49591
272dff61a2de 8200113: Make Access load proxys smarter
eosterlund
parents: 49383
diff changeset
   237
    return AccessInternal::OopLoadProxy<P, decorators>(addr);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   238
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   239
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   240
  template <typename P, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   241
  static inline void oop_store(P* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   242
    verify_oop_decorators<store_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   243
    typedef typename AccessInternal::OopOrNarrowOop<T>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   244
    OopType oop_value = value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   245
    AccessInternal::store<decorators | INTERNAL_VALUE_IS_OOP>(addr, oop_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   246
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   247
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   248
  template <typename P, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   249
  static inline T oop_atomic_cmpxchg(T new_value, P* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   250
    verify_oop_decorators<atomic_cmpxchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   251
    typedef typename AccessInternal::OopOrNarrowOop<T>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   252
    OopType new_oop_value = new_value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   253
    OopType compare_oop_value = compare_value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   254
    return AccessInternal::atomic_cmpxchg<decorators | INTERNAL_VALUE_IS_OOP>(new_oop_value, addr, compare_oop_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   255
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   256
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   257
  template <typename P, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   258
  static inline T oop_atomic_xchg(T new_value, P* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   259
    verify_oop_decorators<atomic_xchg_mo_decorators>();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   260
    typedef typename AccessInternal::OopOrNarrowOop<T>::type OopType;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   261
    OopType new_oop_value = new_value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   262
    return AccessInternal::atomic_xchg<decorators | INTERNAL_VALUE_IS_OOP>(new_oop_value, addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   263
  }
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48966
diff changeset
   264
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48966
diff changeset
   265
  static oop resolve(oop obj) {
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48966
diff changeset
   266
    verify_decorators<INTERNAL_EMPTY>();
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48966
diff changeset
   267
    return AccessInternal::resolve<decorators>(obj);
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48966
diff changeset
   268
  }
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   269
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   270
  static bool equals(oop o1, oop o2) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   271
    verify_decorators<INTERNAL_EMPTY>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   272
    return AccessInternal::equals<decorators>(o1, o2);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   273
  }
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   274
};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   275
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   276
// Helper for performing raw accesses (knows only of memory ordering
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   277
// atomicity decorators as well as compressed oops)
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   278
template <DecoratorSet decorators = INTERNAL_EMPTY>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   279
class RawAccess: public Access<AS_RAW | decorators> {};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   280
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   281
// Helper for performing normal accesses on the heap. These accesses
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   282
// may resolve an accessor on a GC barrier set
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   283
template <DecoratorSet decorators = INTERNAL_EMPTY>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   284
class HeapAccess: public Access<IN_HEAP | decorators> {};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   285
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   286
// Helper for performing normal accesses in roots. These accesses
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   287
// may resolve an accessor on a GC barrier set
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   288
template <DecoratorSet decorators = INTERNAL_EMPTY>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   289
class RootAccess: public Access<IN_ROOT | decorators> {};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   290
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   291
template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   292
template <DecoratorSet expected_decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   293
void Access<decorators>::verify_decorators() {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   294
  STATIC_ASSERT((~expected_decorators & decorators) == 0); // unexpected decorator used
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   295
  const DecoratorSet barrier_strength_decorators = decorators & AS_DECORATOR_MASK;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   296
  STATIC_ASSERT(barrier_strength_decorators == 0 || ( // make sure barrier strength decorators are disjoint if set
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   297
    (barrier_strength_decorators ^ AS_NO_KEEPALIVE) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   298
    (barrier_strength_decorators ^ AS_DEST_NOT_INITIALIZED) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   299
    (barrier_strength_decorators ^ AS_RAW) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   300
    (barrier_strength_decorators ^ AS_NORMAL) == 0
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   301
  ));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   302
  const DecoratorSet ref_strength_decorators = decorators & ON_DECORATOR_MASK;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   303
  STATIC_ASSERT(ref_strength_decorators == 0 || ( // make sure ref strength decorators are disjoint if set
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   304
    (ref_strength_decorators ^ ON_STRONG_OOP_REF) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   305
    (ref_strength_decorators ^ ON_WEAK_OOP_REF) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   306
    (ref_strength_decorators ^ ON_PHANTOM_OOP_REF) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   307
    (ref_strength_decorators ^ ON_UNKNOWN_OOP_REF) == 0
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   308
  ));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   309
  const DecoratorSet memory_ordering_decorators = decorators & MO_DECORATOR_MASK;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   310
  STATIC_ASSERT(memory_ordering_decorators == 0 || ( // make sure memory ordering decorators are disjoint if set
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   311
    (memory_ordering_decorators ^ MO_UNORDERED) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   312
    (memory_ordering_decorators ^ MO_VOLATILE) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   313
    (memory_ordering_decorators ^ MO_RELAXED) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   314
    (memory_ordering_decorators ^ MO_ACQUIRE) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   315
    (memory_ordering_decorators ^ MO_RELEASE) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   316
    (memory_ordering_decorators ^ MO_SEQ_CST) == 0
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   317
  ));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   318
  const DecoratorSet location_decorators = decorators & IN_DECORATOR_MASK;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   319
  STATIC_ASSERT(location_decorators == 0 || ( // make sure location decorators are disjoint if set
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   320
    (location_decorators ^ IN_ROOT) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   321
    (location_decorators ^ IN_HEAP) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   322
    (location_decorators ^ (IN_HEAP | IN_HEAP_ARRAY)) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   323
    (location_decorators ^ (IN_ROOT | IN_CONCURRENT_ROOT)) == 0 ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   324
    (location_decorators ^ (IN_ROOT | IN_ARCHIVE_ROOT)) == 0
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   325
  ));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   326
}
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   327
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49591
diff changeset
   328
#endif // SHARE_OOPS_ACCESS_HPP