hotspot/src/share/vm/oops/fieldInfo.hpp
author johnc
Tue, 18 Jun 2013 12:31:07 -0700
changeset 18091 ddde9f0f414d
parent 16370 4b75aa6388ab
child 19770 7cb9f982ea81
permissions -rw-r--r--
8015237: Parallelize string table scanning during strong root processing Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>. Reviewed-by: tschatzl, stefank, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     1
/*
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
     2
 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     4
 *
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     8
 *
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    13
 * accompanied this code).
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    14
 *
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    18
 *
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    21
 * questions.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    22
 *
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    23
 */
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    24
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    25
#ifndef SHARE_VM_OOPS_FIELDINFO_HPP
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    26
#define SHARE_VM_OOPS_FIELDINFO_HPP
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    27
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    28
#include "oops/constantPool.hpp"
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    29
#include "oops/typeArrayOop.hpp"
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    30
#include "classfile/vmSymbols.hpp"
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    31
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    32
// This class represents the field information contained in the fields
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    33
// array of an InstanceKlass.  Currently it's laid on top an array of
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    34
// Java shorts but in the future it could simply be used as a real
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    35
// array type.  FieldInfo generally shouldn't be used directly.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    36
// Fields should be queried either through InstanceKlass or through
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    37
// the various FieldStreams.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    38
class FieldInfo VALUE_OBJ_CLASS_SPEC {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    39
  friend class fieldDescriptor;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    40
  friend class JavaFieldStream;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    41
  friend class ClassFileParser;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    42
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    43
 public:
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    44
  // fields
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    45
  // Field info extracted from the class file and stored
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    46
  // as an array of 6 shorts.
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    47
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    48
#define FIELDINFO_TAG_SIZE             2
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    49
#define FIELDINFO_TAG_BLANK            0
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    50
#define FIELDINFO_TAG_OFFSET           1
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    51
#define FIELDINFO_TAG_TYPE_PLAIN       2
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    52
#define FIELDINFO_TAG_TYPE_CONTENDED   3
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    53
#define FIELDINFO_TAG_MASK             3
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    54
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    55
  // Packed field has the tag, and can be either of:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    56
  //    hi bits <--------------------------- lo bits
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    57
  //   |---------high---------|---------low---------|
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    58
  //    ..........................................00  - blank
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    59
  //    [------------------offset----------------]01  - real field offset
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    60
  //    ......................[-------type-------]10  - plain field with type
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    61
  //    [--contention_group--][-------type-------]11  - contended field with type and contention group
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    62
  enum FieldOffset {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    63
    access_flags_offset      = 0,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    64
    name_index_offset        = 1,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    65
    signature_index_offset   = 2,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    66
    initval_index_offset     = 3,
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    67
    low_packed_offset        = 4,
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    68
    high_packed_offset       = 5,
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    69
    field_slots              = 6
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    70
  };
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    71
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    72
 private:
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    73
  u2 _shorts[field_slots];
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    74
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    75
  void set_name_index(u2 val)                    { _shorts[name_index_offset] = val;         }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    76
  void set_signature_index(u2 val)               { _shorts[signature_index_offset] = val;    }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    77
  void set_initval_index(u2 val)                 { _shorts[initval_index_offset] = val;      }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    78
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    79
  u2 name_index() const                          { return _shorts[name_index_offset];        }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    80
  u2 signature_index() const                     { return _shorts[signature_index_offset];   }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    81
  u2 initval_index() const                       { return _shorts[initval_index_offset];     }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    82
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    83
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    84
  static FieldInfo* from_field_array(Array<u2>* fields, int index) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    85
    return ((FieldInfo*)fields->adr_at(index * field_slots));
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    86
  }
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    87
  static FieldInfo* from_field_array(u2* fields, int index) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    88
    return ((FieldInfo*)(fields + index * field_slots));
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    89
  }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    90
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    91
  void initialize(u2 access_flags,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    92
                  u2 name_index,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    93
                  u2 signature_index,
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    94
                  u2 initval_index) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    95
    _shorts[access_flags_offset] = access_flags;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    96
    _shorts[name_index_offset] = name_index;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    97
    _shorts[signature_index_offset] = signature_index;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    98
    _shorts[initval_index_offset] = initval_index;
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
    99
    _shorts[low_packed_offset] = 0;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   100
    _shorts[high_packed_offset] = 0;
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   101
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   102
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   103
  u2 access_flags() const                        { return _shorts[access_flags_offset];            }
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   104
  u4 offset() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   105
    u2 lo = _shorts[low_packed_offset];
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   106
    switch(lo & FIELDINFO_TAG_MASK) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   107
      case FIELDINFO_TAG_OFFSET:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   108
        return build_int_from_shorts(_shorts[low_packed_offset], _shorts[high_packed_offset]) >> FIELDINFO_TAG_SIZE;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   109
#ifndef PRODUCT
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   110
      case FIELDINFO_TAG_TYPE_PLAIN:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   111
        fatal("Asking offset for the plain type field");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   112
      case FIELDINFO_TAG_TYPE_CONTENDED:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   113
        fatal("Asking offset for the contended type field");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   114
      case FIELDINFO_TAG_BLANK:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   115
        fatal("Asking offset for the blank field");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   116
#endif
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   117
    }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   118
    ShouldNotReachHere();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   119
    return 0;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   120
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   121
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   122
  bool is_contended() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   123
    u2 lo = _shorts[low_packed_offset];
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   124
    switch(lo & FIELDINFO_TAG_MASK) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   125
      case FIELDINFO_TAG_TYPE_PLAIN:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   126
        return false;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   127
      case FIELDINFO_TAG_TYPE_CONTENDED:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   128
        return true;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   129
#ifndef PRODUCT
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   130
      case FIELDINFO_TAG_OFFSET:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   131
        fatal("Asking contended flag for the field with offset");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   132
      case FIELDINFO_TAG_BLANK:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   133
        fatal("Asking contended flag for the blank field");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   134
#endif
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   135
    }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   136
    ShouldNotReachHere();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   137
    return false;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   138
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   139
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   140
  u2 contended_group() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   141
    u2 lo = _shorts[low_packed_offset];
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   142
    switch(lo & FIELDINFO_TAG_MASK) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   143
      case FIELDINFO_TAG_TYPE_PLAIN:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   144
        return 0;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   145
      case FIELDINFO_TAG_TYPE_CONTENDED:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   146
        return _shorts[high_packed_offset];
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   147
#ifndef PRODUCT
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   148
      case FIELDINFO_TAG_OFFSET:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   149
        fatal("Asking the contended group for the field with offset");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   150
      case FIELDINFO_TAG_BLANK:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   151
        fatal("Asking the contended group for the blank field");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   152
#endif
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   153
    }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   154
    ShouldNotReachHere();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   155
    return 0;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   156
 }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   157
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   158
  u2 allocation_type() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   159
    u2 lo = _shorts[low_packed_offset];
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   160
    switch(lo & FIELDINFO_TAG_MASK) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   161
      case FIELDINFO_TAG_TYPE_PLAIN:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   162
      case FIELDINFO_TAG_TYPE_CONTENDED:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   163
        return (lo >> FIELDINFO_TAG_SIZE);
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   164
#ifndef PRODUCT
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   165
      case FIELDINFO_TAG_OFFSET:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   166
        fatal("Asking the field type for field with offset");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   167
      case FIELDINFO_TAG_BLANK:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   168
        fatal("Asking the field type for the blank field");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   169
#endif
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   170
    }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   171
    ShouldNotReachHere();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   172
    return 0;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   173
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   174
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   175
  bool is_offset_set() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   176
    return (_shorts[low_packed_offset] & FIELDINFO_TAG_MASK) == FIELDINFO_TAG_OFFSET;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   177
  }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   178
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   179
  Symbol* name(constantPoolHandle cp) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   180
    int index = name_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   181
    if (is_internal()) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   182
      return lookup_symbol(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   183
    }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   184
    return cp->symbol_at(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   185
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   186
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   187
  Symbol* signature(constantPoolHandle cp) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   188
    int index = signature_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   189
    if (is_internal()) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   190
      return lookup_symbol(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   191
    }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   192
    return cp->symbol_at(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   193
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   194
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   195
  void set_access_flags(u2 val)                  { _shorts[access_flags_offset] = val;             }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   196
  void set_offset(u4 val)                        {
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   197
    val = val << FIELDINFO_TAG_SIZE; // make room for tag
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   198
    _shorts[low_packed_offset] = extract_low_short_from_int(val) | FIELDINFO_TAG_OFFSET;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   199
    _shorts[high_packed_offset] = extract_high_short_from_int(val);
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   200
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   201
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   202
  void set_allocation_type(int type) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   203
    u2 lo = _shorts[low_packed_offset];
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   204
    switch(lo & FIELDINFO_TAG_MASK) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   205
      case FIELDINFO_TAG_BLANK:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   206
        _shorts[low_packed_offset] = ((type << FIELDINFO_TAG_SIZE)) & 0xFFFF;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   207
        _shorts[low_packed_offset] &= ~FIELDINFO_TAG_MASK;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   208
        _shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_PLAIN;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   209
        return;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   210
#ifndef PRODUCT
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   211
      case FIELDINFO_TAG_TYPE_PLAIN:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   212
      case FIELDINFO_TAG_TYPE_CONTENDED:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   213
      case FIELDINFO_TAG_OFFSET:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   214
        fatal("Setting the field type with overwriting");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   215
#endif
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   216
    }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   217
    ShouldNotReachHere();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   218
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   219
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   220
  void set_contended_group(u2 val) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   221
    u2 lo = _shorts[low_packed_offset];
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   222
    switch(lo & FIELDINFO_TAG_MASK) {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   223
      case FIELDINFO_TAG_TYPE_PLAIN:
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   224
        _shorts[low_packed_offset] |= FIELDINFO_TAG_TYPE_CONTENDED;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   225
        _shorts[high_packed_offset] = val;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   226
        return;
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   227
#ifndef PRODUCT
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   228
      case FIELDINFO_TAG_TYPE_CONTENDED:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   229
        fatal("Overwriting contended group");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   230
      case FIELDINFO_TAG_BLANK:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   231
        fatal("Setting contended group for the blank field");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   232
      case FIELDINFO_TAG_OFFSET:
16370
4b75aa6388ab 8010121: Remove definition of ShouldNotReachHere2(msg)
neliasso
parents: 15193
diff changeset
   233
        fatal("Setting contended group for field with offset");
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   234
#endif
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   235
    }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   236
    ShouldNotReachHere();
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   237
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   238
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   239
  bool is_internal() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   240
    return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   241
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   242
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   243
  Symbol* lookup_symbol(int symbol_index) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   244
    assert(is_internal(), "only internal fields");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   245
    return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   246
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   247
};
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   248
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   249
#endif // SHARE_VM_OOPS_FIELDINFO_HPP