src/hotspot/share/oops/accessBackend.hpp
author ihse
Mon, 26 Nov 2018 14:18:22 +0100
branchihse-manpages-branch
changeset 57043 23d7457ca4c6
parent 52100 62523934374c
child 53075 747d29313e5a
permissions -rw-r--r--
Clean up login in when running which kind of man page creation.
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: 48019
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: 49454
diff changeset
    25
#ifndef SHARE_OOPS_ACCESSBACKEND_HPP
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    26
#define SHARE_OOPS_ACCESSBACKEND_HPP
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    27
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    28
#include "gc/shared/barrierSetConfig.hpp"
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    29
#include "memory/allocation.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    30
#include "metaprogramming/conditional.hpp"
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    31
#include "metaprogramming/decay.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    32
#include "metaprogramming/enableIf.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    33
#include "metaprogramming/integralConstant.hpp"
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    34
#include "metaprogramming/isFloatingPoint.hpp"
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    35
#include "metaprogramming/isIntegral.hpp"
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    36
#include "metaprogramming/isPointer.hpp"
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
    37
#include "metaprogramming/isSame.hpp"
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    38
#include "metaprogramming/isVolatile.hpp"
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    39
#include "oops/accessDecorators.hpp"
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    40
#include "oops/oopsHierarchy.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    41
#include "utilities/debug.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    42
#include "utilities/globalDefinitions.hpp"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    43
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    44
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    45
// This metafunction returns either oop or narrowOop depending on whether
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    46
// an access needs to use compressed oops or not.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    47
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    48
struct HeapOopType: AllStatic {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    49
  static const bool needs_oop_compress = HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value &&
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    50
                                         HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    51
  typedef typename Conditional<needs_oop_compress, narrowOop, oop>::type type;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    52
};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    53
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    54
namespace AccessInternal {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    55
  enum BarrierType {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    56
    BARRIER_STORE,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    57
    BARRIER_STORE_AT,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    58
    BARRIER_LOAD,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    59
    BARRIER_LOAD_AT,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    60
    BARRIER_ATOMIC_CMPXCHG,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    61
    BARRIER_ATOMIC_CMPXCHG_AT,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    62
    BARRIER_ATOMIC_XCHG,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    63
    BARRIER_ATOMIC_XCHG_AT,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    64
    BARRIER_ARRAYCOPY,
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48628
diff changeset
    65
    BARRIER_CLONE,
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    66
    BARRIER_RESOLVE,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
    67
    BARRIER_EQUALS
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    68
  };
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    69
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
    70
  template <DecoratorSet decorators, typename T>
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    71
  struct MustConvertCompressedOop: public IntegralConstant<bool,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    72
    HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value &&
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
    73
    IsSame<typename HeapOopType<decorators>::type, narrowOop>::value &&
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
    74
    IsSame<T, oop>::value> {};
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    75
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    76
  // This metafunction returns an appropriate oop type if the value is oop-like
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    77
  // and otherwise returns the same type T.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    78
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    79
  struct EncodedType: AllStatic {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    80
    typedef typename Conditional<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    81
      HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    82
      typename HeapOopType<decorators>::type, T>::type type;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    83
  };
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    84
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    85
  template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    86
  inline typename HeapOopType<decorators>::type*
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    87
  oop_field_addr(oop base, ptrdiff_t byte_offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    88
    return reinterpret_cast<typename HeapOopType<decorators>::type*>(
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    89
             reinterpret_cast<intptr_t>((void*)base) + byte_offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    90
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    91
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    92
  // This metafunction returns whether it is possible for a type T to require
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    93
  // locking to support wide atomics or not.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    94
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    95
#ifdef SUPPORTS_NATIVE_CX8
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    96
  struct PossiblyLockedAccess: public IntegralConstant<bool, false> {};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    97
#else
48019
827e4ac05579 8191663: Zero variant broken after 8189170 and 8189871
glaubitz
parents: 47998
diff changeset
    98
  struct PossiblyLockedAccess: public IntegralConstant<bool, (sizeof(T) > 4)> {};
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
    99
#endif
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   100
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   101
  template <DecoratorSet decorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   102
  struct AccessFunctionTypes {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   103
    typedef T (*load_at_func_t)(oop base, ptrdiff_t offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   104
    typedef void (*store_at_func_t)(oop base, ptrdiff_t offset, T value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   105
    typedef T (*atomic_cmpxchg_at_func_t)(T new_value, oop base, ptrdiff_t offset, T compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   106
    typedef T (*atomic_xchg_at_func_t)(T new_value, oop base, ptrdiff_t offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   107
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   108
    typedef T (*load_func_t)(void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   109
    typedef void (*store_func_t)(void* addr, T value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   110
    typedef T (*atomic_cmpxchg_func_t)(T new_value, void* addr, T compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   111
    typedef T (*atomic_xchg_func_t)(T new_value, void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   112
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   113
    typedef bool (*arraycopy_func_t)(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   114
                                     arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   115
                                     size_t length);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   116
    typedef void (*clone_func_t)(oop src, oop dst, size_t size);
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48628
diff changeset
   117
    typedef oop (*resolve_func_t)(oop obj);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   118
    typedef bool (*equals_func_t)(oop o1, oop o2);
47998
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
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 49364
diff changeset
   121
  template <DecoratorSet decorators>
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 49364
diff changeset
   122
  struct AccessFunctionTypes<decorators, void> {
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   123
    typedef bool (*arraycopy_func_t)(arrayOop src_obj, size_t src_offset_in_bytes, void* src,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   124
                                     arrayOop dst_obj, size_t dst_offset_in_bytes, void* dst,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   125
                                     size_t length);
49383
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 49364
diff changeset
   126
  };
bf2ff45e592f 8198445: Access API for primitive/native arraycopy
rkennke
parents: 49364
diff changeset
   127
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   128
  template <DecoratorSet decorators, typename T, BarrierType barrier> struct AccessFunction {};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   129
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   130
#define ACCESS_GENERATE_ACCESS_FUNCTION(bt, func)                   \
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   131
  template <DecoratorSet decorators, typename T>                    \
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   132
  struct AccessFunction<decorators, T, bt>: AllStatic{              \
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   133
    typedef typename AccessFunctionTypes<decorators, T>::func type; \
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   134
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   135
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE, store_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   136
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE_AT, store_at_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   137
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_LOAD, load_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   138
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_LOAD_AT, load_at_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   139
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_CMPXCHG, atomic_cmpxchg_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   140
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_CMPXCHG_AT, atomic_cmpxchg_at_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   141
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_XCHG, atomic_xchg_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   142
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_XCHG_AT, atomic_xchg_at_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   143
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ARRAYCOPY, arraycopy_func_t);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   144
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_CLONE, clone_func_t);
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48628
diff changeset
   145
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_RESOLVE, resolve_func_t);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   146
  ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_EQUALS, equals_func_t);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   147
#undef ACCESS_GENERATE_ACCESS_FUNCTION
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   148
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   149
  template <DecoratorSet decorators, typename T, BarrierType barrier_type>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   150
  typename AccessFunction<decorators, T, barrier_type>::type resolve_barrier();
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 <DecoratorSet decorators, typename T, BarrierType barrier_type>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   153
  typename AccessFunction<decorators, T, barrier_type>::type resolve_oop_barrier();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   154
49364
601146c66cad 8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents: 49041
diff changeset
   155
  class AccessLocker {
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   156
  public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   157
    AccessLocker();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   158
    ~AccessLocker();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   159
  };
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   160
  bool wide_atomic_needs_locking();
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   161
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   162
  void* field_addr(oop base, ptrdiff_t offset);
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
  // Forward calls to Copy:: in the cpp file to reduce dependencies and allow
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   165
  // faster build times, given how frequently included access is.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   166
  void arraycopy_arrayof_conjoint_oops(void* src, void* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   167
  void arraycopy_conjoint_oops(oop* src, oop* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   168
  void arraycopy_conjoint_oops(narrowOop* src, narrowOop* dst, size_t length);
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
  void arraycopy_disjoint_words(void* src, void* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   171
  void arraycopy_disjoint_words_atomic(void* src, void* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   172
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   173
  template<typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   174
  void arraycopy_conjoint(T* src, T* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   175
  template<typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   176
  void arraycopy_arrayof_conjoint(T* src, T* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   177
  template<typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   178
  void arraycopy_conjoint_atomic(T* src, T* dst, size_t length);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   179
}
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   180
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   181
// This mask specifies what decorators are relevant for raw accesses. When passing
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   182
// accesses to the raw layer, irrelevant decorators are removed.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   183
const DecoratorSet RAW_DECORATOR_MASK = INTERNAL_DECORATOR_MASK | MO_DECORATOR_MASK |
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50389
diff changeset
   184
                                        ARRAYCOPY_DECORATOR_MASK | IS_NOT_NULL;
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   185
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   186
// The RawAccessBarrier performs raw accesses with additional knowledge of
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   187
// memory ordering, so that OrderAccess/Atomic is called when necessary.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   188
// It additionally handles compressed oops, and hence is not completely "raw"
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   189
// strictly speaking.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   190
template <DecoratorSet decorators>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   191
class RawAccessBarrier: public AllStatic {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   192
protected:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   193
  static inline void* field_addr(oop base, ptrdiff_t byte_offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   194
    return AccessInternal::field_addr(base, byte_offset);
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
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   197
protected:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   198
  // Only encode if INTERNAL_VALUE_IS_OOP
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   199
  template <DecoratorSet idecorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   200
  static inline typename EnableIf<
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
   201
    AccessInternal::MustConvertCompressedOop<idecorators, T>::value,
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   202
    typename HeapOopType<idecorators>::type>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   203
  encode_internal(T value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   204
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   205
  template <DecoratorSet idecorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   206
  static inline typename EnableIf<
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
   207
    !AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   208
  encode_internal(T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   209
    return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   210
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   211
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   212
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   213
  static inline typename AccessInternal::EncodedType<decorators, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   214
  encode(T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   215
    return encode_internal<decorators, T>(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   216
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   217
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   218
  // Only decode if INTERNAL_VALUE_IS_OOP
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   219
  template <DecoratorSet idecorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   220
  static inline typename EnableIf<
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
   221
    AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   222
  decode_internal(typename HeapOopType<idecorators>::type value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   223
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   224
  template <DecoratorSet idecorators, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   225
  static inline typename EnableIf<
48628
69d65d9dcadb 8193063: Enabling narrowOop values for RawAccess accesses
eosterlund
parents: 48019
diff changeset
   226
    !AccessInternal::MustConvertCompressedOop<idecorators, T>::value, T>::type
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   227
  decode_internal(T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   228
    return value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   229
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   230
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   231
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   232
  static inline T decode(typename AccessInternal::EncodedType<decorators, T>::type value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   233
    return decode_internal<decorators, T>(value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   234
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   235
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   236
protected:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   237
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   238
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   239
    HasDecorator<ds, MO_SEQ_CST>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   240
  load_internal(void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   241
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   242
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   243
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   244
    HasDecorator<ds, MO_ACQUIRE>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   245
  load_internal(void* addr);
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
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   248
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   249
    HasDecorator<ds, MO_RELAXED>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   250
  load_internal(void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   251
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   252
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   253
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   254
    HasDecorator<ds, MO_VOLATILE>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   255
  load_internal(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   256
    return *reinterpret_cast<const volatile T*>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   257
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   258
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   259
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   260
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   261
    HasDecorator<ds, MO_UNORDERED>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   262
  load_internal(void* addr) {
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   263
    return *reinterpret_cast<T*>(addr);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   264
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   265
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   266
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   267
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   268
    HasDecorator<ds, MO_SEQ_CST>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   269
  store_internal(void* addr, T value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   270
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   271
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   272
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   273
    HasDecorator<ds, MO_RELEASE>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   274
  store_internal(void* addr, T value);
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
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   277
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   278
    HasDecorator<ds, MO_RELAXED>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   279
  store_internal(void* addr, T value);
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
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   282
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   283
    HasDecorator<ds, MO_VOLATILE>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   284
  store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   285
    (void)const_cast<T&>(*reinterpret_cast<volatile T*>(addr) = value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   286
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   287
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   288
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   289
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   290
    HasDecorator<ds, MO_UNORDERED>::value>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   291
  store_internal(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   292
    *reinterpret_cast<T*>(addr) = value;
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   293
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   294
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   295
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   296
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   297
    HasDecorator<ds, MO_SEQ_CST>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   298
  atomic_cmpxchg_internal(T new_value, void* addr, T compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   299
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   300
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   301
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   302
    HasDecorator<ds, MO_RELAXED>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   303
  atomic_cmpxchg_internal(T new_value, void* addr, T compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   304
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   305
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   306
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   307
    HasDecorator<ds, MO_SEQ_CST>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   308
  atomic_xchg_internal(T new_value, void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   309
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   310
  // The following *_locked mechanisms serve the purpose of handling atomic operations
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   311
  // that are larger than a machine can handle, and then possibly opt for using
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   312
  // a slower path using a mutex to perform the operation.
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   313
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   314
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   315
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   316
    !AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   317
  atomic_cmpxchg_maybe_locked(T new_value, void* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   318
    return atomic_cmpxchg_internal<ds>(new_value, addr, compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   319
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   320
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   321
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   322
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   323
    AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   324
  atomic_cmpxchg_maybe_locked(T new_value, void* addr, T compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   325
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   326
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   327
  static inline typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   328
    !AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   329
  atomic_xchg_maybe_locked(T new_value, void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   330
    return atomic_xchg_internal<ds>(new_value, addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   331
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   332
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   333
  template <DecoratorSet ds, typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   334
  static typename EnableIf<
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   335
    AccessInternal::PossiblyLockedAccess<T>::value, T>::type
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   336
  atomic_xchg_maybe_locked(T new_value, void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   337
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   338
public:
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   339
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   340
  static inline void store(void* addr, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   341
    store_internal<decorators>(addr, value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   342
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   343
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   344
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   345
  static inline T load(void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   346
    return load_internal<decorators, T>(addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   347
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   348
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   349
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   350
  static inline T atomic_cmpxchg(T new_value, void* addr, T compare_value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   351
    return atomic_cmpxchg_maybe_locked<decorators>(new_value, addr, compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   352
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   353
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   354
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   355
  static inline T atomic_xchg(T new_value, void* addr) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   356
    return atomic_xchg_maybe_locked<decorators>(new_value, addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   357
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   358
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   359
  template <typename T>
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   360
  static bool arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   361
                        arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   362
                        size_t length);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   363
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   364
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   365
  static void oop_store(void* addr, T value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   366
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   367
  static void oop_store_at(oop base, ptrdiff_t offset, T value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   368
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   369
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   370
  static T oop_load(void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   371
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   372
  static T oop_load_at(oop base, ptrdiff_t offset);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   373
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   374
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   375
  static T oop_atomic_cmpxchg(T new_value, void* addr, T compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   376
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   377
  static 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
   378
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   379
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   380
  static T oop_atomic_xchg(T new_value, void* addr);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   381
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   382
  static 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
   383
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   384
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   385
  static void store_at(oop base, ptrdiff_t offset, T value) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   386
    store(field_addr(base, offset), value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   387
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   388
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   389
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   390
  static T load_at(oop base, ptrdiff_t offset) {
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   391
    return load<T>(field_addr(base, offset));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   392
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   393
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   394
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   395
  static 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
   396
    return atomic_cmpxchg(new_value, field_addr(base, offset), compare_value);
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   397
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   398
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   399
  template <typename T>
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   400
  static 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
   401
    return atomic_xchg(new_value, field_addr(base, offset));
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   402
  }
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   403
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   404
  template <typename T>
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   405
  static bool oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   406
                            arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   407
                            size_t length);
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   408
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   409
  static void clone(oop src, oop dst, size_t size);
49041
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48628
diff changeset
   410
44122f767467 8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents: 48628
diff changeset
   411
  static oop resolve(oop obj) { return obj; }
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   412
52070
e4d72440d60e 8211279: Verify missing object equals barriers
rkennke
parents: 50728
diff changeset
   413
  static bool equals(oop o1, oop o2) { return (void*)o1 == (void*)o2; }
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   414
};
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
diff changeset
   415
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   416
// Below is the implementation of the first 4 steps of the template pipeline:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   417
// * 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: 49454
diff changeset
   418
//           and sets default decorators to sensible values.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   419
// * 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: 49454
diff changeset
   420
//           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: 49454
diff changeset
   421
//           match.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   422
// * 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: 49454
diff changeset
   423
//           avoided, and in that case avoids it (calling raw accesses or
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   424
//           primitive accesses in a build that does not require primitive GC barriers)
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   425
// * Step 4: Runtime-dispatch. This step performs a runtime dispatch to the corresponding
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   426
//           BarrierSet::AccessBarrier accessor that attaches GC-required barriers
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   427
//           to the access.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   428
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   429
namespace AccessInternal {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   430
  template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   431
  struct OopOrNarrowOopInternal: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   432
    typedef oop type;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   433
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   434
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   435
  template <>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   436
  struct OopOrNarrowOopInternal<narrowOop>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   437
    typedef narrowOop type;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   438
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   439
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   440
  // This metafunction returns a canonicalized oop/narrowOop type for a passed
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   441
  // in oop-like types passed in from oop_* overloads where the user has sworn
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   442
  // that the passed in values should be oop-like (e.g. oop, oopDesc*, arrayOop,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   443
  // narrowOoop, instanceOopDesc*, and random other things).
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   444
  // In the oop_* overloads, it must hold that if the passed in type T is not
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   445
  // narrowOop, then it by contract has to be one of many oop-like types implicitly
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   446
  // convertible to oop, and hence returns oop as the canonical oop type.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   447
  // If it turns out it was not, then the implicit conversion to oop will fail
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   448
  // to compile, as desired.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   449
  template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   450
  struct OopOrNarrowOop: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   451
    typedef typename OopOrNarrowOopInternal<typename Decay<T>::type>::type type;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   452
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   453
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   454
  inline void* field_addr(oop base, ptrdiff_t byte_offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   455
    return reinterpret_cast<void*>(reinterpret_cast<intptr_t>((void*)base) + byte_offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   456
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   457
  // Step 4: Runtime dispatch
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   458
  // The RuntimeDispatch class is responsible for performing a runtime dispatch of the
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   459
  // accessor. This is required when the access either depends on whether compressed oops
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   460
  // is being used, or it depends on which GC implementation was chosen (e.g. requires GC
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   461
  // barriers). The way it works is that a function pointer initially pointing to an
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   462
  // accessor resolution function gets called for each access. Upon first invocation,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   463
  // it resolves which accessor to be used in future invocations and patches the
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   464
  // function pointer to this new accessor.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   465
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   466
  template <DecoratorSet decorators, typename T, BarrierType type>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   467
  struct RuntimeDispatch: AllStatic {};
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   468
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   469
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   470
  struct RuntimeDispatch<decorators, T, BARRIER_STORE>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   471
    typedef typename AccessFunction<decorators, T, BARRIER_STORE>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   472
    static func_t _store_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   473
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   474
    static void store_init(void* addr, T value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   475
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   476
    static inline void store(void* addr, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   477
      _store_func(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   478
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   479
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   480
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   481
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   482
  struct RuntimeDispatch<decorators, T, BARRIER_STORE_AT>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   483
    typedef typename AccessFunction<decorators, T, BARRIER_STORE_AT>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   484
    static func_t _store_at_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   485
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   486
    static void store_at_init(oop base, ptrdiff_t offset, T value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   487
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   488
    static inline void store_at(oop base, ptrdiff_t offset, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   489
      _store_at_func(base, offset, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   490
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   491
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   492
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   493
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   494
  struct RuntimeDispatch<decorators, T, BARRIER_LOAD>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   495
    typedef typename AccessFunction<decorators, T, BARRIER_LOAD>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   496
    static func_t _load_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   497
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   498
    static T load_init(void* addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   499
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   500
    static inline T load(void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   501
      return _load_func(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   502
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   503
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   504
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   505
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   506
  struct RuntimeDispatch<decorators, T, BARRIER_LOAD_AT>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   507
    typedef typename AccessFunction<decorators, T, BARRIER_LOAD_AT>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   508
    static func_t _load_at_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   509
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   510
    static T load_at_init(oop base, ptrdiff_t offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   511
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   512
    static inline T load_at(oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   513
      return _load_at_func(base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   514
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   515
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   516
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   517
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   518
  struct RuntimeDispatch<decorators, T, BARRIER_ATOMIC_CMPXCHG>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   519
    typedef typename AccessFunction<decorators, T, BARRIER_ATOMIC_CMPXCHG>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   520
    static func_t _atomic_cmpxchg_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   521
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   522
    static T atomic_cmpxchg_init(T new_value, void* addr, T compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   523
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   524
    static inline T atomic_cmpxchg(T new_value, void* addr, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   525
      return _atomic_cmpxchg_func(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   526
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   527
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   528
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   529
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   530
  struct RuntimeDispatch<decorators, T, BARRIER_ATOMIC_CMPXCHG_AT>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   531
    typedef typename AccessFunction<decorators, T, BARRIER_ATOMIC_CMPXCHG_AT>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   532
    static func_t _atomic_cmpxchg_at_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   533
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   534
    static T atomic_cmpxchg_at_init(T new_value, oop base, ptrdiff_t offset, T compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   535
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   536
    static inline T atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   537
      return _atomic_cmpxchg_at_func(new_value, base, offset, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   538
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   539
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   540
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   541
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   542
  struct RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   543
    typedef typename AccessFunction<decorators, T, BARRIER_ATOMIC_XCHG>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   544
    static func_t _atomic_xchg_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   545
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   546
    static T atomic_xchg_init(T new_value, void* addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   547
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   548
    static inline T atomic_xchg(T new_value, void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   549
      return _atomic_xchg_func(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   550
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   551
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   552
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   553
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   554
  struct RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG_AT>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   555
    typedef typename AccessFunction<decorators, T, BARRIER_ATOMIC_XCHG_AT>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   556
    static func_t _atomic_xchg_at_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   557
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   558
    static T atomic_xchg_at_init(T new_value, oop base, ptrdiff_t offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   559
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   560
    static inline T atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   561
      return _atomic_xchg_at_func(new_value, base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   562
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   563
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   564
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   565
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   566
  struct RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   567
    typedef typename AccessFunction<decorators, T, BARRIER_ARRAYCOPY>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   568
    static func_t _arraycopy_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   569
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   570
    static bool arraycopy_init(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   571
                               arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   572
                               size_t length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   573
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   574
    static inline bool arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   575
                                 arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   576
                                 size_t length) {
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   577
      return _arraycopy_func(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   578
                             dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   579
                             length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   580
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   581
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   582
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   583
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   584
  struct RuntimeDispatch<decorators, T, BARRIER_CLONE>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   585
    typedef typename AccessFunction<decorators, T, BARRIER_CLONE>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   586
    static func_t _clone_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   587
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   588
    static void clone_init(oop src, oop dst, size_t size);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   589
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   590
    static inline void clone(oop src, oop dst, size_t size) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   591
      _clone_func(src, dst, size);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   592
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   593
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   594
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   595
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   596
  struct RuntimeDispatch<decorators, T, BARRIER_RESOLVE>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   597
    typedef typename AccessFunction<decorators, T, BARRIER_RESOLVE>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   598
    static func_t _resolve_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   599
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   600
    static oop resolve_init(oop obj);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   601
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   602
    static inline oop resolve(oop obj) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   603
      return _resolve_func(obj);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   604
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   605
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   606
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   607
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   608
  struct RuntimeDispatch<decorators, T, BARRIER_EQUALS>: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   609
    typedef typename AccessFunction<decorators, T, BARRIER_EQUALS>::type func_t;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   610
    static func_t _equals_func;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   611
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   612
    static bool equals_init(oop o1, oop o2);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   613
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   614
    static inline bool equals(oop o1, oop o2) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   615
      return _equals_func(o1, o2);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   616
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   617
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   618
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   619
  // Initialize the function pointers to point to the resolving function.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   620
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   621
  typename AccessFunction<decorators, T, BARRIER_STORE>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   622
  RuntimeDispatch<decorators, T, BARRIER_STORE>::_store_func = &store_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   623
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   624
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   625
  typename AccessFunction<decorators, T, BARRIER_STORE_AT>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   626
  RuntimeDispatch<decorators, T, BARRIER_STORE_AT>::_store_at_func = &store_at_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   627
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   628
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   629
  typename AccessFunction<decorators, T, BARRIER_LOAD>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   630
  RuntimeDispatch<decorators, T, BARRIER_LOAD>::_load_func = &load_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   631
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   632
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   633
  typename AccessFunction<decorators, T, BARRIER_LOAD_AT>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   634
  RuntimeDispatch<decorators, T, BARRIER_LOAD_AT>::_load_at_func = &load_at_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   635
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   636
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   637
  typename AccessFunction<decorators, T, BARRIER_ATOMIC_CMPXCHG>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   638
  RuntimeDispatch<decorators, T, BARRIER_ATOMIC_CMPXCHG>::_atomic_cmpxchg_func = &atomic_cmpxchg_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   639
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   640
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   641
  typename AccessFunction<decorators, T, BARRIER_ATOMIC_CMPXCHG_AT>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   642
  RuntimeDispatch<decorators, T, BARRIER_ATOMIC_CMPXCHG_AT>::_atomic_cmpxchg_at_func = &atomic_cmpxchg_at_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   643
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   644
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   645
  typename AccessFunction<decorators, T, BARRIER_ATOMIC_XCHG>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   646
  RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG>::_atomic_xchg_func = &atomic_xchg_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   647
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   648
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   649
  typename AccessFunction<decorators, T, BARRIER_ATOMIC_XCHG_AT>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   650
  RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG_AT>::_atomic_xchg_at_func = &atomic_xchg_at_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   651
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   652
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   653
  typename AccessFunction<decorators, T, BARRIER_ARRAYCOPY>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   654
  RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::_arraycopy_func = &arraycopy_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   655
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   656
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   657
  typename AccessFunction<decorators, T, BARRIER_CLONE>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   658
  RuntimeDispatch<decorators, T, BARRIER_CLONE>::_clone_func = &clone_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   659
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   660
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   661
  typename AccessFunction<decorators, T, BARRIER_RESOLVE>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   662
  RuntimeDispatch<decorators, T, BARRIER_RESOLVE>::_resolve_func = &resolve_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   663
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   664
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   665
  typename AccessFunction<decorators, T, BARRIER_EQUALS>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   666
  RuntimeDispatch<decorators, T, BARRIER_EQUALS>::_equals_func = &equals_init;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   667
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   668
  // Step 3: Pre-runtime dispatching.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   669
  // The PreRuntimeDispatch class is responsible for filtering the barrier strength
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   670
  // decorators. That is, for AS_RAW, it hardwires the accesses without a runtime
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   671
  // dispatch point. Otherwise it goes through a runtime check if hardwiring was
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   672
  // not possible.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   673
  struct PreRuntimeDispatch: AllStatic {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   674
    template<DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   675
    struct CanHardwireRaw: public IntegralConstant<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   676
      bool,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   677
      !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value || // primitive access
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   678
      !HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value || // don't care about compressed oops (oop* address)
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   679
      HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value> // we can infer we use compressed oops (narrowOop* address)
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   680
    {};
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   681
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   682
    static const DecoratorSet convert_compressed_oops = INTERNAL_RT_USE_COMPRESSED_OOPS | INTERNAL_CONVERT_COMPRESSED_OOP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   683
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   684
    template<DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   685
    static bool is_hardwired_primitive() {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   686
      return !HasDecorator<decorators, INTERNAL_BT_BARRIER_ON_PRIMITIVES>::value &&
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   687
             !HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   688
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   689
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   690
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   691
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   692
      HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   693
    store(void* addr, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   694
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   695
      if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   696
        Raw::oop_store(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   697
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   698
        Raw::store(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   699
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   700
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   701
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   702
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   703
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   704
      HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   705
    store(void* addr, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   706
      if (UseCompressedOops) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   707
        const DecoratorSet expanded_decorators = decorators | convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   708
        PreRuntimeDispatch::store<expanded_decorators>(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   709
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   710
        const DecoratorSet expanded_decorators = decorators & ~convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   711
        PreRuntimeDispatch::store<expanded_decorators>(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   712
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   713
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   714
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   715
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   716
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   717
      !HasDecorator<decorators, AS_RAW>::value>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   718
    store(void* addr, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   719
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   720
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   721
        PreRuntimeDispatch::store<expanded_decorators>(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   722
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   723
        RuntimeDispatch<decorators, T, BARRIER_STORE>::store(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   724
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   725
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   726
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   727
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   728
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   729
      HasDecorator<decorators, AS_RAW>::value>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   730
    store_at(oop base, ptrdiff_t offset, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   731
      store<decorators>(field_addr(base, offset), value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   732
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   733
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   734
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   735
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   736
      !HasDecorator<decorators, AS_RAW>::value>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   737
    store_at(oop base, ptrdiff_t offset, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   738
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   739
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   740
        PreRuntimeDispatch::store_at<expanded_decorators>(base, offset, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   741
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   742
        RuntimeDispatch<decorators, T, BARRIER_STORE_AT>::store_at(base, offset, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   743
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   744
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   745
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   746
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   747
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   748
      HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   749
    load(void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   750
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   751
      if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   752
        return Raw::template oop_load<T>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   753
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   754
        return Raw::template load<T>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   755
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   756
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   757
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   758
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   759
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   760
      HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   761
    load(void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   762
      if (UseCompressedOops) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   763
        const DecoratorSet expanded_decorators = decorators | convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   764
        return PreRuntimeDispatch::load<expanded_decorators, T>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   765
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   766
        const DecoratorSet expanded_decorators = decorators & ~convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   767
        return PreRuntimeDispatch::load<expanded_decorators, T>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   768
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   769
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   770
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   771
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   772
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   773
      !HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   774
    load(void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   775
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   776
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   777
        return PreRuntimeDispatch::load<expanded_decorators, T>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   778
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   779
        return RuntimeDispatch<decorators, T, BARRIER_LOAD>::load(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   780
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   781
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   782
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   783
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   784
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   785
      HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   786
    load_at(oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   787
      return load<decorators, T>(field_addr(base, offset));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   788
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   789
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   790
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   791
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   792
      !HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   793
    load_at(oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   794
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   795
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   796
        return PreRuntimeDispatch::load_at<expanded_decorators, T>(base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   797
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   798
        return RuntimeDispatch<decorators, T, BARRIER_LOAD_AT>::load_at(base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   799
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   800
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   801
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   802
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   803
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   804
      HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   805
    atomic_cmpxchg(T new_value, void* addr, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   806
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   807
      if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   808
        return Raw::oop_atomic_cmpxchg(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   809
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   810
        return Raw::atomic_cmpxchg(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   811
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   812
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   813
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   814
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   815
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   816
      HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   817
    atomic_cmpxchg(T new_value, void* addr, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   818
      if (UseCompressedOops) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   819
        const DecoratorSet expanded_decorators = decorators | convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   820
        return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   821
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   822
        const DecoratorSet expanded_decorators = decorators & ~convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   823
        return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   824
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   825
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   826
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   827
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   828
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   829
      !HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   830
    atomic_cmpxchg(T new_value, void* addr, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   831
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   832
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   833
        return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   834
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   835
        return RuntimeDispatch<decorators, T, BARRIER_ATOMIC_CMPXCHG>::atomic_cmpxchg(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   836
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   837
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   838
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   839
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   840
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   841
      HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   842
    atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   843
      return atomic_cmpxchg<decorators>(new_value, field_addr(base, offset), compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   844
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   845
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   846
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   847
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   848
      !HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   849
    atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   850
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   851
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   852
        return PreRuntimeDispatch::atomic_cmpxchg_at<expanded_decorators>(new_value, base, offset, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   853
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   854
        return RuntimeDispatch<decorators, T, BARRIER_ATOMIC_CMPXCHG_AT>::atomic_cmpxchg_at(new_value, base, offset, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   855
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   856
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   857
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   858
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   859
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   860
      HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   861
    atomic_xchg(T new_value, void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   862
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   863
      if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   864
        return Raw::oop_atomic_xchg(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   865
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   866
        return Raw::atomic_xchg(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   867
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   868
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   869
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   870
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   871
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   872
      HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   873
    atomic_xchg(T new_value, void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   874
      if (UseCompressedOops) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   875
        const DecoratorSet expanded_decorators = decorators | convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   876
        return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   877
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   878
        const DecoratorSet expanded_decorators = decorators & ~convert_compressed_oops;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   879
        return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   880
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   881
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   882
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   883
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   884
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   885
      !HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   886
    atomic_xchg(T new_value, void* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   887
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   888
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   889
        return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   890
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   891
        return RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG>::atomic_xchg(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   892
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   893
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   894
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   895
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   896
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   897
      HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   898
    atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   899
      return atomic_xchg<decorators>(new_value, field_addr(base, offset));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   900
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   901
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   902
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   903
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   904
      !HasDecorator<decorators, AS_RAW>::value, T>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   905
    atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   906
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   907
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   908
        return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   909
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   910
        return RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG_AT>::atomic_xchg_at(new_value, base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   911
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   912
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   913
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   914
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   915
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   916
      HasDecorator<decorators, AS_RAW>::value && CanHardwireRaw<decorators>::value, bool>::type
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   917
    arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   918
              arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   919
              size_t length) {
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   920
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   921
      if (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value) {
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   922
        return Raw::oop_arraycopy(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   923
                                  dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   924
                                  length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   925
      } else {
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   926
        return Raw::arraycopy(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   927
                              dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   928
                              length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   929
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   930
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   931
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   932
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   933
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   934
      HasDecorator<decorators, AS_RAW>::value && !CanHardwireRaw<decorators>::value, bool>::type
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   935
    arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   936
              arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   937
              size_t length) {
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   938
      if (UseCompressedOops) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   939
        const DecoratorSet expanded_decorators = decorators | convert_compressed_oops;
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   940
        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   941
                                                                  dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   942
                                                                  length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   943
      } else {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   944
        const DecoratorSet expanded_decorators = decorators & ~convert_compressed_oops;
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   945
        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   946
                                                                  dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   947
                                                                  length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   948
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   949
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   950
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   951
    template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   952
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   953
      !HasDecorator<decorators, AS_RAW>::value, bool>::type
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   954
    arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   955
              arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   956
              size_t length) {
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   957
      if (is_hardwired_primitive<decorators>()) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   958
        const DecoratorSet expanded_decorators = decorators | AS_RAW;
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   959
        return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   960
                                                                  dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   961
                                                                  length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   962
      } else {
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   963
        return RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   964
                                                                            dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
   965
                                                                            length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   966
      }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   967
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   968
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   969
    template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   970
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   971
      HasDecorator<decorators, AS_RAW>::value>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   972
    clone(oop src, oop dst, size_t size) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   973
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   974
      Raw::clone(src, dst, size);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   975
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   976
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   977
    template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   978
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   979
      !HasDecorator<decorators, AS_RAW>::value>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   980
    clone(oop src, oop dst, size_t size) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   981
      RuntimeDispatch<decorators, oop, BARRIER_CLONE>::clone(src, dst, size);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   982
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   983
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   984
    template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   985
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   986
      HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, oop>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   987
    resolve(oop obj) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   988
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   989
      return Raw::resolve(obj);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   990
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   991
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   992
    template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   993
    inline static typename EnableIf<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   994
      !HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, oop>::type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   995
    resolve(oop obj) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   996
      return RuntimeDispatch<decorators, oop, BARRIER_RESOLVE>::resolve(obj);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   997
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   998
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
   999
    template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1000
    inline static typename EnableIf<
52100
62523934374c 8212054: Boilerplate to bind oopDesc::equals_raw() to actual raw implementation
rkennke
parents: 52070
diff changeset
  1001
      HasDecorator<decorators, AS_RAW>::value || HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, bool>::type
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1002
    equals(oop o1, oop o2) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1003
      typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1004
      return Raw::equals(o1, o2);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1005
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1006
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1007
    template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1008
    inline static typename EnableIf<
52100
62523934374c 8212054: Boilerplate to bind oopDesc::equals_raw() to actual raw implementation
rkennke
parents: 52070
diff changeset
  1009
      !HasDecorator<decorators, AS_RAW>::value && !HasDecorator<decorators, INTERNAL_BT_TO_SPACE_INVARIANT>::value, bool>::type
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1010
    equals(oop o1, oop o2) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1011
      return RuntimeDispatch<decorators, oop, BARRIER_EQUALS>::equals(o1, o2);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1012
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1013
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1014
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1015
  // Step 2: Reduce types.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1016
  // Enforce that for non-oop types, T and P have to be strictly the same.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1017
  // P is the type of the address and T is the type of the values.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1018
  // As for oop types, it is allow to send T in {narrowOop, oop} and
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1019
  // P in {narrowOop, oop, HeapWord*}. The following rules apply according to
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1020
  // the subsequent table. (columns are P, rows are T)
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1021
  // |           | HeapWord  |   oop   | narrowOop |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1022
  // |   oop     |  rt-comp  | hw-none |  hw-comp  |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1023
  // | narrowOop |     x     |    x    |  hw-none  |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1024
  //
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1025
  // x means not allowed
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1026
  // rt-comp means it must be checked at runtime whether the oop is compressed.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1027
  // hw-none means it is statically known the oop will not be compressed.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1028
  // hw-comp means it is statically known the oop will be compressed.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1029
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1030
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1031
  inline void store_reduce_types(T* addr, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1032
    PreRuntimeDispatch::store<decorators>(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1033
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1034
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1035
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1036
  inline void store_reduce_types(narrowOop* addr, oop value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1037
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1038
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1039
    PreRuntimeDispatch::store<expanded_decorators>(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1040
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1041
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1042
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1043
  inline void store_reduce_types(narrowOop* addr, narrowOop value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1044
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1045
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1046
    PreRuntimeDispatch::store<expanded_decorators>(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1047
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1048
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1049
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1050
  inline void store_reduce_types(HeapWord* addr, oop value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1051
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1052
    PreRuntimeDispatch::store<expanded_decorators>(addr, value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1053
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1054
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1055
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1056
  inline T atomic_cmpxchg_reduce_types(T new_value, T* addr, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1057
    return PreRuntimeDispatch::atomic_cmpxchg<decorators>(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1058
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1059
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1060
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1061
  inline oop atomic_cmpxchg_reduce_types(oop new_value, narrowOop* addr, oop compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1062
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1063
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1064
    return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1065
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1066
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1067
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1068
  inline narrowOop atomic_cmpxchg_reduce_types(narrowOop new_value, narrowOop* addr, narrowOop compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1069
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1070
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1071
    return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1072
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1073
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1074
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1075
  inline oop atomic_cmpxchg_reduce_types(oop new_value,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1076
                                         HeapWord* addr,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1077
                                         oop compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1078
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1079
    return PreRuntimeDispatch::atomic_cmpxchg<expanded_decorators>(new_value, addr, compare_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1080
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1081
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1082
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1083
  inline T atomic_xchg_reduce_types(T new_value, T* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1084
    const DecoratorSet expanded_decorators = decorators;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1085
    return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1086
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1087
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1088
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1089
  inline oop atomic_xchg_reduce_types(oop new_value, narrowOop* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1090
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1091
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1092
    return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1093
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1094
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1095
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1096
  inline narrowOop atomic_xchg_reduce_types(narrowOop new_value, narrowOop* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1097
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1098
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1099
    return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1100
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1101
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1102
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1103
  inline oop atomic_xchg_reduce_types(oop new_value, HeapWord* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1104
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1105
    return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1106
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1107
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1108
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1109
  inline T load_reduce_types(T* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1110
    return PreRuntimeDispatch::load<decorators, T>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1111
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1112
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1113
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1114
  inline typename OopOrNarrowOop<T>::type load_reduce_types(narrowOop* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1115
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1116
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1117
    return PreRuntimeDispatch::load<expanded_decorators, typename OopOrNarrowOop<T>::type>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1118
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1119
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1120
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1121
  inline oop load_reduce_types(HeapWord* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1122
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1123
    return PreRuntimeDispatch::load<expanded_decorators, oop>(addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1124
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1125
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1126
  template <DecoratorSet decorators, typename T>
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1127
  inline bool arraycopy_reduce_types(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1128
                                     arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1129
                                     size_t length) {
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1130
    return PreRuntimeDispatch::arraycopy<decorators>(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1131
                                                     dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1132
                                                     length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1133
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1134
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1135
  template <DecoratorSet decorators>
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1136
  inline bool arraycopy_reduce_types(arrayOop src_obj, size_t src_offset_in_bytes, HeapWord* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1137
                                     arrayOop dst_obj, size_t dst_offset_in_bytes, HeapWord* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1138
                                     size_t length) {
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1139
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP;
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1140
    return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1141
                                                              dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1142
                                                              length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1143
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1144
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1145
  template <DecoratorSet decorators>
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1146
  inline bool arraycopy_reduce_types(arrayOop src_obj, size_t src_offset_in_bytes, narrowOop* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1147
                                     arrayOop dst_obj, size_t dst_offset_in_bytes, narrowOop* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1148
                                     size_t length) {
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1149
    const DecoratorSet expanded_decorators = decorators | INTERNAL_CONVERT_COMPRESSED_OOP |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1150
                                             INTERNAL_RT_USE_COMPRESSED_OOPS;
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1151
    return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, src_offset_in_bytes, src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1152
                                                              dst_obj, dst_offset_in_bytes, dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1153
                                                              length);
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1154
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1155
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1156
  // Step 1: Set default decorators. This step remembers if a type was volatile
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1157
  // and then sets the MO_VOLATILE decorator by default. Otherwise, a default
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1158
  // memory ordering is set for the access, and the implied decorator rules
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1159
  // are applied to select sensible defaults for decorators that have not been
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1160
  // explicitly set. For example, default object referent strength is set to strong.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1161
  // This step also decays the types passed in (e.g. getting rid of CV qualifiers
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1162
  // and references from the types). This step also perform some type verification
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1163
  // that the passed in types make sense.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1164
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1165
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1166
  static void verify_types(){
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1167
    // If this fails to compile, then you have sent in something that is
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1168
    // not recognized as a valid primitive type to a primitive Access function.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1169
    STATIC_ASSERT((HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value || // oops have already been validated
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1170
                   (IsPointer<T>::value || IsIntegral<T>::value) ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1171
                    IsFloatingPoint<T>::value)); // not allowed primitive type
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1172
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1173
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1174
  template <DecoratorSet decorators, typename P, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1175
  inline void store(P* addr, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1176
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1177
    typedef typename Decay<P>::type DecayedP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1178
    typedef typename Decay<T>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1179
    DecayedT decayed_value = value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1180
    // If a volatile address is passed in but no memory ordering decorator,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1181
    // set the memory ordering to MO_VOLATILE by default.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1182
    const DecoratorSet expanded_decorators = DecoratorFixup<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1183
      (IsVolatile<P>::value && !HasDecorator<decorators, MO_DECORATOR_MASK>::value) ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1184
      (MO_VOLATILE | decorators) : decorators>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1185
    store_reduce_types<expanded_decorators>(const_cast<DecayedP*>(addr), decayed_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1186
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1187
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1188
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1189
  inline void store_at(oop base, ptrdiff_t offset, T value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1190
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1191
    typedef typename Decay<T>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1192
    DecayedT decayed_value = value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1193
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1194
                                             (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1195
                                              INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY)>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1196
    PreRuntimeDispatch::store_at<expanded_decorators>(base, offset, decayed_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1197
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1198
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1199
  template <DecoratorSet decorators, typename P, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1200
  inline T load(P* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1201
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1202
    typedef typename Decay<P>::type DecayedP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1203
    typedef typename Conditional<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1204
                                 typename OopOrNarrowOop<T>::type,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1205
                                 typename Decay<T>::type>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1206
    // If a volatile address is passed in but no memory ordering decorator,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1207
    // set the memory ordering to MO_VOLATILE by default.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1208
    const DecoratorSet expanded_decorators = DecoratorFixup<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1209
      (IsVolatile<P>::value && !HasDecorator<decorators, MO_DECORATOR_MASK>::value) ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1210
      (MO_VOLATILE | decorators) : decorators>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1211
    return load_reduce_types<expanded_decorators, DecayedT>(const_cast<DecayedP*>(addr));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1212
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1213
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1214
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1215
  inline T load_at(oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1216
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1217
    typedef typename Conditional<HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1218
                                 typename OopOrNarrowOop<T>::type,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1219
                                 typename Decay<T>::type>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1220
    // Expand the decorators (figure out sensible defaults)
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1221
    // Potentially remember if we need compressed oop awareness
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1222
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1223
                                             (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1224
                                              INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY)>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1225
    return PreRuntimeDispatch::load_at<expanded_decorators, DecayedT>(base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1226
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1227
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1228
  template <DecoratorSet decorators, typename P, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1229
  inline T atomic_cmpxchg(T new_value, P* addr, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1230
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1231
    typedef typename Decay<P>::type DecayedP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1232
    typedef typename Decay<T>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1233
    DecayedT new_decayed_value = new_value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1234
    DecayedT compare_decayed_value = compare_value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1235
    const DecoratorSet expanded_decorators = DecoratorFixup<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1236
      (!HasDecorator<decorators, MO_DECORATOR_MASK>::value) ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1237
      (MO_SEQ_CST | decorators) : decorators>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1238
    return atomic_cmpxchg_reduce_types<expanded_decorators>(new_decayed_value,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1239
                                                            const_cast<DecayedP*>(addr),
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1240
                                                            compare_decayed_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1241
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1242
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1243
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1244
  inline T atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1245
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1246
    typedef typename Decay<T>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1247
    DecayedT new_decayed_value = new_value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1248
    DecayedT compare_decayed_value = compare_value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1249
    // Determine default memory ordering
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1250
    const DecoratorSet expanded_decorators = DecoratorFixup<
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1251
      (!HasDecorator<decorators, MO_DECORATOR_MASK>::value) ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1252
      (MO_SEQ_CST | decorators) : decorators>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1253
    // Potentially remember that we need compressed oop awareness
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1254
    const DecoratorSet final_decorators = expanded_decorators |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1255
                                          (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1256
                                           INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1257
    return PreRuntimeDispatch::atomic_cmpxchg_at<final_decorators>(new_decayed_value, base,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1258
                                                                   offset, compare_decayed_value);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1259
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1260
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1261
  template <DecoratorSet decorators, typename P, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1262
  inline T atomic_xchg(T new_value, P* addr) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1263
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1264
    typedef typename Decay<P>::type DecayedP;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1265
    typedef typename Decay<T>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1266
    DecayedT new_decayed_value = new_value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1267
    // atomic_xchg is only available in SEQ_CST flavour.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1268
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators | MO_SEQ_CST>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1269
    return atomic_xchg_reduce_types<expanded_decorators>(new_decayed_value,
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1270
                                                         const_cast<DecayedP*>(addr));
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1271
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1272
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1273
  template <DecoratorSet decorators, typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1274
  inline T atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1275
    verify_types<decorators, T>();
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1276
    typedef typename Decay<T>::type DecayedT;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1277
    DecayedT new_decayed_value = new_value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1278
    // atomic_xchg is only available in SEQ_CST flavour.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1279
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators | MO_SEQ_CST |
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1280
                                             (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1281
                                              INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY)>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1282
    return PreRuntimeDispatch::atomic_xchg_at<expanded_decorators>(new_decayed_value, base, offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1283
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1284
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1285
  template <DecoratorSet decorators, typename T>
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1286
  inline bool arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1287
                        arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1288
                        size_t length) {
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1289
    STATIC_ASSERT((HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1290
                   (IsSame<T, void>::value || IsIntegral<T>::value) ||
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1291
                    IsFloatingPoint<T>::value)); // arraycopy allows type erased void elements
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1292
    typedef typename Decay<T>::type DecayedT;
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50389
diff changeset
  1293
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators | IS_ARRAY | IN_HEAP>::value;
50389
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1294
    return arraycopy_reduce_types<expanded_decorators>(src_obj, src_offset_in_bytes, const_cast<DecayedT*>(src_raw),
7e8c0409a747 8198285: More consistent Access API for arraycopy
rkennke
parents: 49906
diff changeset
  1295
                                                       dst_obj, dst_offset_in_bytes, const_cast<DecayedT*>(dst_raw),
49658
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1296
                                                       length);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1297
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1298
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1299
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1300
  inline void clone(oop src, oop dst, size_t size) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1301
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1302
    PreRuntimeDispatch::clone<expanded_decorators>(src, dst, size);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1303
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1304
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1305
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1306
  inline oop resolve(oop obj) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1307
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1308
    return PreRuntimeDispatch::resolve<expanded_decorators>(obj);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1309
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1310
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1311
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1312
  inline bool equals(oop o1, oop o2) {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1313
    const DecoratorSet expanded_decorators = DecoratorFixup<decorators>::value;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1314
    return PreRuntimeDispatch::equals<expanded_decorators>(o1, o2);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1315
  }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1316
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1317
  // Infer the type that should be returned from an Access::oop_load.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1318
  template <typename P, DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1319
  class OopLoadProxy: public StackObj {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1320
  private:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1321
    P *const _addr;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1322
  public:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1323
    OopLoadProxy(P* addr) : _addr(addr) {}
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1324
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1325
    inline operator oop() {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1326
      return load<decorators | INTERNAL_VALUE_IS_OOP, P, oop>(_addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1327
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1328
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1329
    inline operator narrowOop() {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1330
      return load<decorators | INTERNAL_VALUE_IS_OOP, P, narrowOop>(_addr);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1331
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1332
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1333
    template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1334
    inline bool operator ==(const T& other) const {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1335
      return load<decorators | INTERNAL_VALUE_IS_OOP, P, T>(_addr) == other;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1336
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1337
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1338
    template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1339
    inline bool operator !=(const T& other) const {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1340
      return load<decorators | INTERNAL_VALUE_IS_OOP, P, T>(_addr) != other;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1341
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1342
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1343
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1344
  // Infer the type that should be returned from an Access::load_at.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1345
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1346
  class LoadAtProxy: public StackObj {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1347
  private:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1348
    const oop _base;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1349
    const ptrdiff_t _offset;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1350
  public:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1351
    LoadAtProxy(oop base, ptrdiff_t offset) : _base(base), _offset(offset) {}
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1352
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1353
    template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1354
    inline operator T() const {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1355
      return load_at<decorators, T>(_base, _offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1356
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1357
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1358
    template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1359
    inline bool operator ==(const T& other) const { return load_at<decorators, T>(_base, _offset) == other; }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1360
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1361
    template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1362
    inline bool operator !=(const T& other) const { return load_at<decorators, T>(_base, _offset) != other; }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1363
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1364
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1365
  // Infer the type that should be returned from an Access::oop_load_at.
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1366
  template <DecoratorSet decorators>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1367
  class OopLoadAtProxy: public StackObj {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1368
  private:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1369
    const oop _base;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1370
    const ptrdiff_t _offset;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1371
  public:
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1372
    OopLoadAtProxy(oop base, ptrdiff_t offset) : _base(base), _offset(offset) {}
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1373
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1374
    inline operator oop() const {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1375
      return load_at<decorators | INTERNAL_VALUE_IS_OOP, oop>(_base, _offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1376
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1377
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1378
    inline operator narrowOop() const {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1379
      return load_at<decorators | INTERNAL_VALUE_IS_OOP, narrowOop>(_base, _offset);
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1380
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1381
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1382
    template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1383
    inline bool operator ==(const T& other) const {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1384
      return load_at<decorators | INTERNAL_VALUE_IS_OOP, T>(_base, _offset) == other;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1385
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1386
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1387
    template <typename T>
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1388
    inline bool operator !=(const T& other) const {
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1389
      return load_at<decorators | INTERNAL_VALUE_IS_OOP, T>(_base, _offset) != other;
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1390
    }
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1391
  };
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1392
}
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1393
8237a91c1cca 8199781: Don't use naked == for comparing oops
rkennke
parents: 49454
diff changeset
  1394
#endif // SHARE_OOPS_ACCESSBACKEND_HPP