hotspot/src/share/vm/oops/fieldStreams.hpp
author johnc
Tue, 18 Jun 2013 12:31:07 -0700
changeset 18091 ddde9f0f414d
parent 15193 8e6b5694267f
child 20017 81eba62e9048
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_FIELDSTREAMS_HPP
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    26
#define SHARE_VM_OOPS_FIELDSTREAMS_HPP
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    27
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    28
#include "oops/instanceKlass.hpp"
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    29
#include "oops/fieldInfo.hpp"
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    30
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    31
// The is the base class for iteration over the fields array
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    32
// describing the declared fields in the class.  Several subclasses
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    33
// are provided depending on the kind of iteration required.  The
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    34
// JavaFieldStream is for iterating over regular Java fields and it
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    35
// generally the preferred iterator.  InternalFieldStream only
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    36
// iterates over fields that have been injected by the JVM.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    37
// AllFieldStream exposes all fields and should only be used in rare
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    38
// cases.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    39
class FieldStreamBase : public StackObj {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    40
 protected:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    41
  Array<u2>*          _fields;
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    42
  constantPoolHandle  _constants;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    43
  int                 _index;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    44
  int                 _limit;
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    45
  int                 _generic_signature_slot;
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    46
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    47
  FieldInfo* field() const { return FieldInfo::from_field_array(_fields, _index); }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    48
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    49
  int init_generic_signature_start_slot() {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    50
    int length = _fields->length();
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    51
    int num_fields = 0;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    52
    int skipped_generic_signature_slots = 0;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    53
    FieldInfo* fi;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    54
    AccessFlags flags;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    55
    /* Scan from 0 to the current _index. Count the number of generic
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    56
       signature slots for field[0] to field[_index - 1]. */
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    57
    for (int i = 0; i < _index; i++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    58
      fi = FieldInfo::from_field_array(_fields, i);
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    59
      flags.set_flags(fi->access_flags());
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    60
      if (flags.field_has_generic_signature()) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    61
        length --;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    62
        skipped_generic_signature_slots ++;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    63
      }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    64
    }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    65
    /* Scan from the current _index. */
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    66
    for (int i = _index; i*FieldInfo::field_slots < length; i++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    67
      fi = FieldInfo::from_field_array(_fields, i);
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    68
      flags.set_flags(fi->access_flags());
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    69
      if (flags.field_has_generic_signature()) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    70
        length --;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    71
      }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    72
      num_fields ++;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    73
    }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    74
    _generic_signature_slot = length + skipped_generic_signature_slots;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    75
    assert(_generic_signature_slot <= _fields->length(), "");
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    76
    return num_fields;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    77
  }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    78
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    79
  FieldStreamBase(Array<u2>* fields, constantPoolHandle constants, int start, int limit) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    80
    _fields = fields;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    81
    _constants = constants;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    82
    _index = start;
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    83
    int num_fields = init_generic_signature_start_slot();
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    84
    if (limit < start) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    85
      _limit = num_fields;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    86
    } else {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    87
      _limit = limit;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    88
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    89
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    90
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    91
  FieldStreamBase(Array<u2>* fields, constantPoolHandle constants) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    92
    _fields = fields;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    93
    _constants = constants;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    94
    _index = 0;
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    95
    _limit = init_generic_signature_start_slot();
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    96
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    97
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    98
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    99
  FieldStreamBase(InstanceKlass* klass) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   100
    _fields = klass->fields();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   101
    _constants = klass->constants();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   102
    _index = 0;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   103
    _limit = klass->java_fields_count();
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   104
    init_generic_signature_start_slot();
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   105
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   106
  FieldStreamBase(instanceKlassHandle klass) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   107
    _fields = klass->fields();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   108
    _constants = klass->constants();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   109
    _index = 0;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   110
    _limit = klass->java_fields_count();
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   111
    init_generic_signature_start_slot();
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   112
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   113
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   114
  // accessors
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   115
  int index() const                 { return _index; }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   116
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   117
  void next() {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   118
    if (access_flags().field_has_generic_signature()) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   119
      _generic_signature_slot ++;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   120
      assert(_generic_signature_slot <= _fields->length(), "");
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   121
    }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   122
    _index += 1;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   123
  }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   124
  bool done() const { return _index >= _limit; }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   125
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   126
  // Accessors for current field
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   127
  AccessFlags access_flags() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   128
    AccessFlags flags;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   129
    flags.set_flags(field()->access_flags());
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   130
    return flags;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   131
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   132
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   133
  void set_access_flags(u2 flags) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   134
    field()->set_access_flags(flags);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   135
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   136
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   137
  void set_access_flags(AccessFlags flags) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   138
    set_access_flags(flags.as_short());
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   139
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   140
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   141
  Symbol* name() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   142
    return field()->name(_constants);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   143
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   144
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   145
  Symbol* signature() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   146
    return field()->signature(_constants);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   147
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   148
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   149
  Symbol* generic_signature() const {
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   150
    if (access_flags().field_has_generic_signature()) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   151
      assert(_generic_signature_slot < _fields->length(), "out of bounds");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   152
      int index = _fields->at(_generic_signature_slot);
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   153
      return _constants->symbol_at(index);
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   154
    } else {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   155
      return NULL;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   156
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   157
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   158
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   159
  int offset() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   160
    return field()->offset();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   161
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   162
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   163
  int allocation_type() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   164
    return field()->allocation_type();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   165
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   166
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   167
  void set_offset(int offset) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   168
    field()->set_offset(offset);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   169
  }
15193
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
  bool is_offset_set() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   172
    return field()->is_offset_set();
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_contended() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   176
    return field()->is_contended();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   177
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   178
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   179
  int contended_group() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   180
    return field()->contended_group();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   181
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   182
10546
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   185
// Iterate over only the internal fields
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   186
class JavaFieldStream : public FieldStreamBase {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   187
 public:
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   188
  JavaFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {}
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   189
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   190
  int name_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   191
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   192
    return field()->name_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
  void set_name_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   195
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   196
    field()->set_name_index(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   197
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   198
  int signature_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   199
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   200
    return field()->signature_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   201
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   202
  void set_signature_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   203
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   204
    field()->set_signature_index(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   205
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   206
  int generic_signature_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   207
    assert(!field()->is_internal(), "regular only");
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   208
    if (access_flags().field_has_generic_signature()) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   209
      assert(_generic_signature_slot < _fields->length(), "out of bounds");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   210
      return _fields->at(_generic_signature_slot);
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   211
    } else {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   212
      return 0;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   213
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   214
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   215
  void set_generic_signature_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   216
    assert(!field()->is_internal(), "regular only");
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   217
    if (access_flags().field_has_generic_signature()) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   218
      assert(_generic_signature_slot < _fields->length(), "out of bounds");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   219
      _fields->at_put(_generic_signature_slot, index);
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   220
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   221
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   222
  int initval_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   223
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   224
    return field()->initval_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   225
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   226
  void set_initval_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   227
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   228
    return field()->set_initval_index(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   229
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   230
};
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   231
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   232
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   233
// Iterate over only the internal fields
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   234
class InternalFieldStream : public FieldStreamBase {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   235
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   236
  InternalFieldStream(InstanceKlass* k):      FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {}
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   237
  InternalFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {}
10546
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   240
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   241
class AllFieldStream : public FieldStreamBase {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   242
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   243
  AllFieldStream(Array<u2>* fields, constantPoolHandle constants): FieldStreamBase(fields, constants) {}
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   244
  AllFieldStream(InstanceKlass* k):      FieldStreamBase(k->fields(), k->constants()) {}
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   245
  AllFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants()) {}
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
#endif // SHARE_VM_OOPS_FIELDSTREAMS_HPP