src/hotspot/share/oops/annotations.hpp
author coleenp
Wed, 22 Aug 2018 07:51:07 -0400
changeset 51486 67b55f3c45eb
parent 49480 d7df2dd501ce
child 52645 74cf02d5f6e2
permissions -rw-r--r--
8208172: SIGSEGV when owner of invokedynamic bootstrap method throws an exception - Symbol::increment_refcount()+0x0 Summary: table for resolution errors always expect non-null message string. Reviewed-by: dholmes, iklam
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     1
/*
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     4
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     8
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    13
 * accompanied this code).
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    14
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    18
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    21
 * questions.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    22
 *
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    23
 */
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    24
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    25
#ifndef SHARE_VM_OOPS_ANNOTATIONS_HPP
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    26
#define SHARE_VM_OOPS_ANNOTATIONS_HPP
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    27
46448
b5350a83520b 8153646: Move vm/utilities/array.hpp to vm/oops
hseigel
parents: 15601
diff changeset
    28
#include "oops/array.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    29
#include "oops/metadata.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    30
#include "utilities/exceptions.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    31
#include "utilities/globalDefinitions.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    32
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    33
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    34
class ClassLoaderData;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    35
class outputStream;
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    36
class KlassSizeStats;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    37
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    38
typedef Array<u1> AnnotationArray;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    39
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    40
// Class to hold the various types of annotations. The only metadata that points
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    41
// to this is InstanceKlass, or another Annotations instance if this is a
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    42
// a type_annotation instance.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    43
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    44
class Annotations: public MetaspaceObj {
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    45
  // If you add a new field that points to any metaspace object, you
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    46
  // must add this field to Annotations::metaspace_pointers_do().
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    47
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    48
  // Annotations for this class, or null if none.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    49
  AnnotationArray*             _class_annotations;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    50
  // Annotation objects (byte arrays) for fields, or null if no annotations.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    51
  // Indices correspond to entries (not indices) in fields array.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    52
  Array<AnnotationArray*>*     _fields_annotations;
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    53
  // Type annotations for this class, or null if none.
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    54
  AnnotationArray*             _class_type_annotations;
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    55
  Array<AnnotationArray*>*     _fields_type_annotations;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    56
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    57
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    58
  // Allocate instance of this class
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    59
  static Annotations* allocate(ClassLoaderData* loader_data, TRAPS);
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    60
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    61
  static void free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    62
  void deallocate_contents(ClassLoaderData* loader_data);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    63
  DEBUG_ONLY(bool on_stack() { return false; })  // for template
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    64
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    65
  // Sizing (in words)
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    66
  static int size()    { return sizeof(Annotations) / wordSize; }
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    67
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    68
  // Annotations should be stored in the read-only region of CDS archive.
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    69
  static bool is_read_only_by_default() { return true; }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    70
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    71
#if INCLUDE_SERVICES
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    72
  void collect_statistics(KlassSizeStats *sz) const;
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    73
#endif
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    74
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    75
  // Constructor to initialize to null
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    76
  Annotations() : _class_annotations(NULL),
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    77
                  _fields_annotations(NULL),
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    78
                  _class_type_annotations(NULL),
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    79
                  _fields_type_annotations(NULL) {}
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    80
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    81
  AnnotationArray* class_annotations() const                       { return _class_annotations; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    82
  Array<AnnotationArray*>* fields_annotations() const              { return _fields_annotations; }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    83
  AnnotationArray* class_type_annotations() const                  { return _class_type_annotations; }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    84
  Array<AnnotationArray*>* fields_type_annotations() const         { return _fields_type_annotations; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    85
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    86
  void set_class_annotations(AnnotationArray* md)                     { _class_annotations = md; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    87
  void set_fields_annotations(Array<AnnotationArray*>* md)            { _fields_annotations = md; }
15601
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    88
  void set_class_type_annotations(AnnotationArray* cta)               { _class_type_annotations = cta; }
df8faef6efaf 8007320: NPG: move method annotations
coleenp
parents: 15437
diff changeset
    89
  void set_fields_type_annotations(Array<AnnotationArray*>* fta)      { _fields_type_annotations = fta; }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    90
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    91
  // Turn metadata annotations into a Java heap object (oop)
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    92
  static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    93
15097
9db149412e0e 8004823: Add VM support for type annotation reflection
stefank
parents: 13728
diff changeset
    94
  bool is_klass() const { return false; }
46746
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    95
  void metaspace_pointers_do(MetaspaceClosure* it);
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    96
  MetaspaceObj::Type type() const { return AnnotationsType; }
ea379ebb9447 8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents: 46448
diff changeset
    97
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
    98
 private:
15437
eabd4555d072 6479360: PrintClassHistogram improvements
acorn
parents: 15097
diff changeset
    99
  static julong count_bytes(Array<AnnotationArray*>* p);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   100
 public:
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   101
  const char* internal_name() const { return "{constant pool}"; }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   102
#ifndef PRODUCT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   103
  void print_on(outputStream* st) const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   104
#endif
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   105
  void print_value_on(outputStream* st) const;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   106
};
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff changeset
   107
#endif // SHARE_VM_OOPS_ANNOTATIONS_HPP