hotspot/src/share/vm/oops/fieldInfo.hpp
author coleenp
Sat, 01 Sep 2012 13:25:18 -0400
changeset 13728 882756847a04
parent 12772 d317e5e08194
child 15193 8e6b5694267f
permissions -rw-r--r--
6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    46
  // as an array of 7 shorts
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    47
  enum FieldOffset {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    48
    access_flags_offset      = 0,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    49
    name_index_offset        = 1,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    50
    signature_index_offset   = 2,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    51
    initval_index_offset     = 3,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    52
    low_offset               = 4,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    53
    high_offset              = 5,
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    54
    field_slots              = 6
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    55
  };
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    56
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    57
 private:
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    58
  u2 _shorts[field_slots];
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    59
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    60
  void set_name_index(u2 val)                    { _shorts[name_index_offset] = val;         }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    61
  void set_signature_index(u2 val)               { _shorts[signature_index_offset] = val;    }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    62
  void set_initval_index(u2 val)                 { _shorts[initval_index_offset] = val;      }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    63
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    64
  u2 name_index() const                          { return _shorts[name_index_offset];        }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    65
  u2 signature_index() const                     { return _shorts[signature_index_offset];   }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    66
  u2 initval_index() const                       { return _shorts[initval_index_offset];     }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    67
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    68
 public:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12772
diff changeset
    69
  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
    70
    return ((FieldInfo*)fields->adr_at(index * field_slots));
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    71
  }
12772
d317e5e08194 7168280: Eliminate the generic signature index slot from field array for field without generic signature.
jiangli
parents: 10546
diff changeset
    72
  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
    73
    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
    74
  }
10546
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    75
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    76
  void initialize(u2 access_flags,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    77
                  u2 name_index,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    78
                  u2 signature_index,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    79
                  u2 initval_index,
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    80
                  u4 offset) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    81
    _shorts[access_flags_offset] = access_flags;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    82
    _shorts[name_index_offset] = name_index;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    83
    _shorts[signature_index_offset] = signature_index;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    84
    _shorts[initval_index_offset] = initval_index;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    85
    set_offset(offset);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    86
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    87
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    88
  u2 access_flags() const                        { return _shorts[access_flags_offset];            }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    89
  u4 offset() const                              { return build_int_from_shorts(_shorts[low_offset], _shorts[high_offset]); }
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
  Symbol* name(constantPoolHandle cp) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    92
    int index = name_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    93
    if (is_internal()) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    94
      return lookup_symbol(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    95
    }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    96
    return cp->symbol_at(index);
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
    99
  Symbol* signature(constantPoolHandle cp) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   100
    int index = signature_index();
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   101
    if (is_internal()) {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   102
      return lookup_symbol(index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   103
    }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   104
    return cp->symbol_at(index);
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
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   107
  void set_access_flags(u2 val)                  { _shorts[access_flags_offset] = val;             }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   108
  void set_offset(u4 val)                        {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   109
    _shorts[low_offset] = extract_low_short_from_int(val);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   110
    _shorts[high_offset] = extract_high_short_from_int(val);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   111
  }
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
  bool is_internal() const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   114
    return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0;
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   115
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   116
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   117
  Symbol* lookup_symbol(int symbol_index) const {
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   118
    assert(is_internal(), "only internal fields");
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   119
    return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   120
  }
e79347eebbc5 7086585: make Java field injection more flexible
never
parents:
diff changeset
   121
};
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
#endif // SHARE_VM_OOPS_FIELDINFO_HPP