author | coleenp |
Sat, 01 Sep 2012 13:25:18 -0400 | |
changeset 13728 | 882756847a04 |
parent 12772 | d317e5e08194 |
child 15193 | 8e6b5694267f |
permissions | -rw-r--r-- |
10546 | 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 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
#ifndef SHARE_VM_OOPS_FIELDINFO_HPP |
|
26 |
#define SHARE_VM_OOPS_FIELDINFO_HPP |
|
27 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12772
diff
changeset
|
28 |
#include "oops/constantPool.hpp" |
10546 | 29 |
#include "oops/typeArrayOop.hpp" |
30 |
#include "classfile/vmSymbols.hpp" |
|
31 |
||
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 | 34 |
// Java shorts but in the future it could simply be used as a real |
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 | 37 |
// the various FieldStreams. |
38 |
class FieldInfo VALUE_OBJ_CLASS_SPEC { |
|
39 |
friend class fieldDescriptor; |
|
40 |
friend class JavaFieldStream; |
|
41 |
friend class ClassFileParser; |
|
42 |
||
43 |
public: |
|
44 |
// fields |
|
45 |
// Field info extracted from the class file and stored |
|
46 |
// as an array of 7 shorts |
|
47 |
enum FieldOffset { |
|
48 |
access_flags_offset = 0, |
|
49 |
name_index_offset = 1, |
|
50 |
signature_index_offset = 2, |
|
51 |
initval_index_offset = 3, |
|
52 |
low_offset = 4, |
|
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 | 55 |
}; |
56 |
||
57 |
private: |
|
58 |
u2 _shorts[field_slots]; |
|
59 |
||
60 |
void set_name_index(u2 val) { _shorts[name_index_offset] = val; } |
|
61 |
void set_signature_index(u2 val) { _shorts[signature_index_offset] = val; } |
|
62 |
void set_initval_index(u2 val) { _shorts[initval_index_offset] = val; } |
|
63 |
||
64 |
u2 name_index() const { return _shorts[name_index_offset]; } |
|
65 |
u2 signature_index() const { return _shorts[signature_index_offset]; } |
|
66 |
u2 initval_index() const { return _shorts[initval_index_offset]; } |
|
67 |
||
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 | 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 | 75 |
|
76 |
void initialize(u2 access_flags, |
|
77 |
u2 name_index, |
|
78 |
u2 signature_index, |
|
79 |
u2 initval_index, |
|
80 |
u4 offset) { |
|
81 |
_shorts[access_flags_offset] = access_flags; |
|
82 |
_shorts[name_index_offset] = name_index; |
|
83 |
_shorts[signature_index_offset] = signature_index; |
|
84 |
_shorts[initval_index_offset] = initval_index; |
|
85 |
set_offset(offset); |
|
86 |
} |
|
87 |
||
88 |
u2 access_flags() const { return _shorts[access_flags_offset]; } |
|
89 |
u4 offset() const { return build_int_from_shorts(_shorts[low_offset], _shorts[high_offset]); } |
|
90 |
||
91 |
Symbol* name(constantPoolHandle cp) const { |
|
92 |
int index = name_index(); |
|
93 |
if (is_internal()) { |
|
94 |
return lookup_symbol(index); |
|
95 |
} |
|
96 |
return cp->symbol_at(index); |
|
97 |
} |
|
98 |
||
99 |
Symbol* signature(constantPoolHandle cp) const { |
|
100 |
int index = signature_index(); |
|
101 |
if (is_internal()) { |
|
102 |
return lookup_symbol(index); |
|
103 |
} |
|
104 |
return cp->symbol_at(index); |
|
105 |
} |
|
106 |
||
107 |
void set_access_flags(u2 val) { _shorts[access_flags_offset] = val; } |
|
108 |
void set_offset(u4 val) { |
|
109 |
_shorts[low_offset] = extract_low_short_from_int(val); |
|
110 |
_shorts[high_offset] = extract_high_short_from_int(val); |
|
111 |
} |
|
112 |
||
113 |
bool is_internal() const { |
|
114 |
return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0; |
|
115 |
} |
|
116 |
||
117 |
Symbol* lookup_symbol(int symbol_index) const { |
|
118 |
assert(is_internal(), "only internal fields"); |
|
119 |
return vmSymbols::symbol_at((vmSymbols::SID)symbol_index); |
|
120 |
} |
|
121 |
}; |
|
122 |
||
123 |
#endif // SHARE_VM_OOPS_FIELDINFO_HPP |