src/hotspot/share/oops/fieldStreams.hpp
author coleenp
Wed, 24 Jul 2019 10:22:11 -0400
changeset 57511 00ae3b739184
parent 53244 9807daeb47c4
child 59056 15936b142f86
permissions -rw-r--r--
8228485: JVM crashes when bootstrap method for condy triggers loading of class whose static initializer throws exception Summary: Add case for JVM_CONSTANT_Dynamic in error_message function. Reviewed-by: dholmes, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2011, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    25
#ifndef SHARE_OOPS_FIELDSTREAMS_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#define SHARE_OOPS_FIELDSTREAMS_HPP
10546
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"
20017
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
    30
#include "runtime/fieldDescriptor.hpp"
10546
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
// The is the base class for iteration over the fields array
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    33
// describing the declared fields in the class.  Several subclasses
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    34
// are provided depending on the kind of iteration required.  The
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    35
// JavaFieldStream is for iterating over regular Java fields and it
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    36
// generally the preferred iterator.  InternalFieldStream only
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    37
// iterates over fields that have been injected by the JVM.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    38
// AllFieldStream exposes all fields and should only be used in rare
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    39
// cases.
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    40
class FieldStreamBase : public StackObj {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    41
 protected:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    42
  Array<u2>*          _fields;
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    43
  constantPoolHandle  _constants;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    44
  int                 _index;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    45
  int                 _limit;
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    46
  int                 _generic_signature_slot;
20017
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
    47
  fieldDescriptor     _fd_buf;
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    48
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    49
  FieldInfo* field() const { return FieldInfo::from_field_array(_fields, _index); }
20017
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
    50
  InstanceKlass* field_holder() const { return _constants->pool_holder(); }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    51
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    52
  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
    53
    int length = _fields->length();
28396
7fe4347e6792 6700100: optimize inline_native_clone() for small objects with exact klass
roland
parents: 20017
diff changeset
    54
    int num_fields = _index;
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    55
    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
    56
    FieldInfo* fi;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    57
    AccessFlags flags;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    58
    /* 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
    59
       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
    60
    for (int i = 0; i < _index; i++) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    61
      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
    62
      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
    63
      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
    64
        length --;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    65
        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
    66
      }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    67
    }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    68
    /* 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
    69
    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
    70
      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
    71
      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
    72
      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
    73
        length --;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    74
      }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    75
      num_fields ++;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    76
    }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    77
    _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
    78
    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
    79
    return num_fields;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    80
  }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    81
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 28396
diff changeset
    82
  FieldStreamBase(Array<u2>* fields, const constantPoolHandle& constants, int start, int limit) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    83
    _fields = fields;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    84
    _constants = constants;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    85
    _index = start;
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    86
    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
    87
    if (limit < start) {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    88
      _limit = num_fields;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    89
    } else {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    90
      _limit = limit;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    91
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    92
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    93
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 28396
diff changeset
    94
  FieldStreamBase(Array<u2>* fields, const constantPoolHandle& constants) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    95
    _fields = fields;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    96
    _constants = constants;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    97
    _index = 0;
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    98
    _limit = init_generic_signature_start_slot();
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    99
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   100
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   101
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   102
  FieldStreamBase(InstanceKlass* klass) {
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   103
    _fields = klass->fields();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   104
    _constants = klass->constants();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   105
    _index = 0;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   106
    _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
   107
    init_generic_signature_start_slot();
20017
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
   108
    assert(klass == field_holder(), "");
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   109
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   110
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   111
  // accessors
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   112
  int index() const                 { return _index; }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   113
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   114
  void next() {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   115
    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
   116
      _generic_signature_slot ++;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   117
      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
   118
    }
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   119
    _index += 1;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   120
  }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   121
  bool done() const { return _index >= _limit; }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   122
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   123
  // Accessors for current field
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   124
  AccessFlags access_flags() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   125
    AccessFlags flags;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   126
    flags.set_flags(field()->access_flags());
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   127
    return flags;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   128
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   129
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   130
  void set_access_flags(u2 flags) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   131
    field()->set_access_flags(flags);
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   134
  void set_access_flags(AccessFlags flags) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   135
    set_access_flags(flags.as_short());
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   138
  Symbol* name() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   139
    return field()->name(_constants);
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   142
  Symbol* signature() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   143
    return field()->signature(_constants);
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   146
  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
   147
    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
   148
      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
   149
      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
   150
      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
   151
    } else {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   152
      return NULL;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   153
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   154
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   155
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   156
  int offset() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   157
    return field()->offset();
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
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   160
  int allocation_type() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   161
    return field()->allocation_type();
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   162
  }
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   163
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   164
  void set_offset(int offset) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   165
    field()->set_offset(offset);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   166
  }
15193
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   167
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   168
  bool is_offset_set() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   169
    return field()->is_offset_set();
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
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   172
  bool is_contended() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   173
    return field()->is_contended();
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
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   176
  int contended_group() const {
8e6b5694267f 8003985: Support @Contended Annotation - JEP 142
jwilhelm
parents: 13728
diff changeset
   177
    return field()->contended_group();
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
20017
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
   180
  // bridge to a heavier API:
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
   181
  fieldDescriptor& field_descriptor() const {
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
   182
    fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf);
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
   183
    field.reinitialize(field_holder(), _index);
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
   184
    return field;
81eba62e9048 8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents: 15193
diff changeset
   185
  }
10546
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   188
// Iterate over only the internal fields
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   189
class JavaFieldStream : public FieldStreamBase {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   190
 public:
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 33593
diff changeset
   191
  JavaFieldStream(const InstanceKlass* k): FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {}
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   192
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   193
  int name_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   194
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   195
    return field()->name_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   196
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   197
  void set_name_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   198
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   199
    field()->set_name_index(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   200
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   201
  int signature_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   202
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   203
    return field()->signature_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   204
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   205
  void set_signature_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   206
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   207
    field()->set_signature_index(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   208
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   209
  int generic_signature_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   210
    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
   211
    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
   212
      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
   213
      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
   214
    } else {
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   215
      return 0;
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
   216
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   217
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   218
  void set_generic_signature_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   219
    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
   220
    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
   221
      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
   222
      _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
   223
    }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   224
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   225
  int initval_index() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   226
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   227
    return field()->initval_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   228
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   229
  void set_initval_index(int index) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   230
    assert(!field()->is_internal(), "regular only");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   231
    return field()->set_initval_index(index);
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
};
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   234
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   235
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   236
// Iterate over only the internal fields
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   237
class InternalFieldStream : public FieldStreamBase {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   238
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   239
  InternalFieldStream(InstanceKlass* k):      FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), 0) {}
10546
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
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
class AllFieldStream : public FieldStreamBase {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   244
 public:
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 28396
diff changeset
   245
  AllFieldStream(Array<u2>* fields, const constantPoolHandle& constants): FieldStreamBase(fields, constants) {}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
   246
  AllFieldStream(InstanceKlass* k):      FieldStreamBase(k->fields(), k->constants()) {}
10546
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
   249
#endif // SHARE_OOPS_FIELDSTREAMS_HPP