author | jwilhelm |
Sun, 25 Feb 2018 04:59:43 +0100 | |
changeset 49067 | c153e9daadce |
parent 47216 | 71c04702a3d5 |
child 49480 | d7df2dd501ce |
permissions | -rw-r--r-- |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
1 |
/* |
46448 | 2 |
* Copyright (c) 2012, 2017, 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 | 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 "runtime/handles.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
31 |
#include "utilities/exceptions.hpp" |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
32 |
#include "utilities/globalDefinitions.hpp" |
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 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
35 |
class ClassLoaderData; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
36 |
class outputStream; |
15437 | 37 |
class KlassSizeStats; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
38 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
39 |
typedef Array<u1> AnnotationArray; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
40 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
41 |
// 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
|
42 |
// 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
|
43 |
// a type_annotation instance. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
44 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
45 |
class Annotations: public MetaspaceObj { |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46448
diff
changeset
|
46 |
// 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
|
47 |
// 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
|
48 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
49 |
// Annotations for this class, or null if none. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
50 |
AnnotationArray* _class_annotations; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
51 |
// 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
|
52 |
// Indices correspond to entries (not indices) in fields array. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
53 |
Array<AnnotationArray*>* _fields_annotations; |
15097
9db149412e0e
8004823: Add VM support for type annotation reflection
stefank
parents:
13728
diff
changeset
|
54 |
// Type annotations for this class, or null if none. |
15601 | 55 |
AnnotationArray* _class_type_annotations; |
56 |
Array<AnnotationArray*>* _fields_type_annotations; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
57 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
58 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
59 |
// Allocate instance of this class |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
60 |
static Annotations* allocate(ClassLoaderData* loader_data, TRAPS); |
15601 | 61 |
|
62 |
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
|
63 |
void deallocate_contents(ClassLoaderData* loader_data); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
64 |
DEBUG_ONLY(bool on_stack() { return false; }) // for template |
15437 | 65 |
|
66 |
// Sizing (in words) |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
67 |
static int size() { return sizeof(Annotations) / wordSize; } |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46448
diff
changeset
|
68 |
|
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46448
diff
changeset
|
69 |
// 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
|
70 |
static bool is_read_only_by_default() { return true; } |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46448
diff
changeset
|
71 |
|
15437 | 72 |
#if INCLUDE_SERVICES |
73 |
void collect_statistics(KlassSizeStats *sz) const; |
|
74 |
#endif |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
75 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
76 |
// Constructor to initialize to null |
15097
9db149412e0e
8004823: Add VM support for type annotation reflection
stefank
parents:
13728
diff
changeset
|
77 |
Annotations() : _class_annotations(NULL), |
9db149412e0e
8004823: Add VM support for type annotation reflection
stefank
parents:
13728
diff
changeset
|
78 |
_fields_annotations(NULL), |
15601 | 79 |
_class_type_annotations(NULL), |
80 |
_fields_type_annotations(NULL) {} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
81 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
82 |
AnnotationArray* class_annotations() const { return _class_annotations; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
83 |
Array<AnnotationArray*>* fields_annotations() const { return _fields_annotations; } |
15601 | 84 |
AnnotationArray* class_type_annotations() const { return _class_type_annotations; } |
85 |
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
|
86 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
87 |
void set_class_annotations(AnnotationArray* md) { _class_annotations = md; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
88 |
void set_fields_annotations(Array<AnnotationArray*>* md) { _fields_annotations = md; } |
15601 | 89 |
void set_class_type_annotations(AnnotationArray* cta) { _class_type_annotations = cta; } |
90 |
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
|
91 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
92 |
// Turn metadata annotations into a Java heap object (oop) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
93 |
static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
94 |
|
15097
9db149412e0e
8004823: Add VM support for type annotation reflection
stefank
parents:
13728
diff
changeset
|
95 |
bool is_klass() const { return false; } |
46746
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46448
diff
changeset
|
96 |
void metaspace_pointers_do(MetaspaceClosure* it); |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46448
diff
changeset
|
97 |
MetaspaceObj::Type type() const { return AnnotationsType; } |
ea379ebb9447
8072061: Automatically determine optimal sizes for the CDS regions
iklam
parents:
46448
diff
changeset
|
98 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
99 |
private: |
15437 | 100 |
static julong count_bytes(Array<AnnotationArray*>* p); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
101 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
102 |
const char* internal_name() const { return "{constant pool}"; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
103 |
#ifndef PRODUCT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
104 |
void print_on(outputStream* st) const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
105 |
#endif |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
106 |
void print_value_on(outputStream* st) const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
107 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
diff
changeset
|
108 |
#endif // SHARE_VM_OOPS_ANNOTATIONS_HPP |