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_VALUEKLASS_HPP
26 #define SHARE_VM_OOPS_VALUEKLASS_HPP
27
28 #include "oops/instanceKlass.hpp"
29 #include "oops/method.hpp"
30 #include "oops/oop.inline.hpp"
31
32 // A ValueKlass is a specialized InstanceKlass for value types.
33
34
35 class ValueKlass: public InstanceKlass {
36 friend class VMStructs;
37 friend class InstanceKlass;
38
39 private:
40
41 // Constructor
42 ValueKlass(const ClassFileParser& parser)
43 : InstanceKlass(parser, InstanceKlass::_misc_kind_value_type) {
44 set_has_vcc_klass();
45 }
46
47 // static Klass* array_klass_impl(InstanceKlass* this_k, bool or_null, int n, TRAPS);
48 protected:
49 // Returns the array class for the n'th dimension
50 Klass* array_klass_impl(bool or_null, int n, TRAPS);
51
52 // Returns the array class with this class as element type
53 Klass* array_klass_impl(bool or_null, TRAPS);
54
55 public:
56 // Type testing
57 bool is_value_slow() const { return true; }
58
59 // Casting from Klass*
60 static ValueKlass* cast(Klass* k) {
61 assert(k->is_value(), "cast to ValueKlass");
62 return (ValueKlass*) k;
63 }
64
65 // Use this to return the size of an instance in heap words
66 // Implementation is currently simple because all value types are allocated
67 // in Java heap like Java objects.
128 void value_store(void* src, void* dst, bool dst_is_heap, bool dst_uninitialized) {
129 value_store(src, dst, nonstatic_field_size() << LogBytesPerHeapOop, dst_is_heap, dst_uninitialized);
130 }
131
132 // store the value of this klass contained with src into dst, raw data ptr
133 void value_store(void* src, void* dst, size_t raw_byte_size, bool dst_is_heap, bool dst_uninitialized);
134
135 oop unbox(Handle src, InstanceKlass* target_klass, TRAPS);
136 oop box(Handle src, InstanceKlass* target_klass, TRAPS);
137
138 // GC support...
139
140 // oop iterate raw value type data pointer (where oop_addr may not be an oop, but backing/array-element)
141 template <bool nv, typename T, class OopClosureType>
142 inline void oop_iterate_specialized(const address oop_addr, OopClosureType* closure);
143
144 template <bool nv, typename T, class OopClosureType>
145 inline void oop_iterate_specialized_bounded(const address oop_addr, OopClosureType* closure, void* lo, void* hi);
146
147 // calling convention support
148 GrowableArray<SigEntry> collect_fields(int base_off = 0) const;
149 GrowableArray<SigEntry> return_convention(VMRegPair*& regs, int& nb_fields) const;
150 void save_oop_fields(const GrowableArray<SigEntry>& sig_vk, RegisterMap& map, const VMRegPair* regs, GrowableArray<Handle>& handles, int nb_fields) const;
151 bool save_oop_results(RegisterMap& map, GrowableArray<Handle>& handles) const;
152 void restore_oop_results(RegisterMap& map, GrowableArray<Handle>& handles) const;
153 oop realloc_result(const GrowableArray<SigEntry>& sig_vk, const RegisterMap& reg_map, const VMRegPair* regs, const GrowableArray<Handle>& handles, int nb_fields, TRAPS);
154 static ValueKlass* returned_value_type(const RegisterMap& reg_map);
155 };
156
157 #endif /* SHARE_VM_OOPS_VALUEKLASS_HPP */
|
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_VALUEKLASS_HPP
26 #define SHARE_VM_OOPS_VALUEKLASS_HPP
27
28 #include "oops/instanceKlass.hpp"
29 #include "oops/method.hpp"
30 #include "oops/oop.inline.hpp"
31
32 // A ValueKlass is a specialized InstanceKlass for value types.
33
34
35 class ValueKlass: public InstanceKlass {
36 friend class VMStructs;
37 friend class InstanceKlass;
38
39 private:
40
41 // Constructor
42 ValueKlass(const ClassFileParser& parser)
43 : InstanceKlass(parser, InstanceKlass::_misc_kind_value_type) {
44 set_has_vcc_klass();
45 }
46
47 address adr_extended_sig() const {
48 address adr_vcc = adr_vcc_klass();
49 if (adr_vcc == NULL) {
50 address adr_jf = adr_value_fields_klasses();
51 if (adr_jf != NULL) {
52 return adr_jf + this->java_fields_count() * sizeof(Klass*);
53 }
54
55 address adr_fing = adr_fingerprint();
56 if (adr_fing != NULL) {
57 return adr_fingerprint() + sizeof(u8);
58 }
59
60 InstanceKlass** adr_host = adr_host_klass();
61 if (adr_host != NULL) {
62 return (address)(adr_host + 1);
63 }
64
65 Klass** adr_impl = adr_implementor();
66 if (adr_impl != NULL) {
67 return (address)(adr_impl + 1);
68 }
69
70 return (address)end_of_nonstatic_oop_maps();
71 } else {
72 return adr_vcc + sizeof(Klass*);
73 }
74 }
75
76 address adr_return_regs() const {
77 return adr_extended_sig() + sizeof(intptr_t);
78 }
79
80 // static Klass* array_klass_impl(InstanceKlass* this_k, bool or_null, int n, TRAPS);
81
82 GrowableArray<SigEntry> collect_fields(int base_off = 0) const;
83
84 protected:
85 // Returns the array class for the n'th dimension
86 Klass* array_klass_impl(bool or_null, int n, TRAPS);
87
88 // Returns the array class with this class as element type
89 Klass* array_klass_impl(bool or_null, TRAPS);
90
91 public:
92 // Type testing
93 bool is_value_slow() const { return true; }
94
95 // Casting from Klass*
96 static ValueKlass* cast(Klass* k) {
97 assert(k->is_value(), "cast to ValueKlass");
98 return (ValueKlass*) k;
99 }
100
101 // Use this to return the size of an instance in heap words
102 // Implementation is currently simple because all value types are allocated
103 // in Java heap like Java objects.
164 void value_store(void* src, void* dst, bool dst_is_heap, bool dst_uninitialized) {
165 value_store(src, dst, nonstatic_field_size() << LogBytesPerHeapOop, dst_is_heap, dst_uninitialized);
166 }
167
168 // store the value of this klass contained with src into dst, raw data ptr
169 void value_store(void* src, void* dst, size_t raw_byte_size, bool dst_is_heap, bool dst_uninitialized);
170
171 oop unbox(Handle src, InstanceKlass* target_klass, TRAPS);
172 oop box(Handle src, InstanceKlass* target_klass, TRAPS);
173
174 // GC support...
175
176 // oop iterate raw value type data pointer (where oop_addr may not be an oop, but backing/array-element)
177 template <bool nv, typename T, class OopClosureType>
178 inline void oop_iterate_specialized(const address oop_addr, OopClosureType* closure);
179
180 template <bool nv, typename T, class OopClosureType>
181 inline void oop_iterate_specialized_bounded(const address oop_addr, OopClosureType* closure, void* lo, void* hi);
182
183 // calling convention support
184 void initialize_calling_convention();
185 const Array<SigEntry>* extended_sig() const {
186 assert(this != SystemDictionary::___Value_klass(), "make no sense for __Value");
187 return *((Array<SigEntry>**)adr_extended_sig());
188 }
189 const Array<VMRegPair>* return_regs() const {
190 assert(this != SystemDictionary::___Value_klass(), "make no sense for __Value");
191 return *((Array<VMRegPair>**)adr_return_regs());
192 }
193 void save_oop_fields(const RegisterMap& map, GrowableArray<Handle>& handles) const;
194 bool save_oop_results(RegisterMap& map, GrowableArray<Handle>& handles) const;
195 void restore_oop_results(RegisterMap& map, GrowableArray<Handle>& handles) const;
196 oop realloc_result(const RegisterMap& reg_map, const GrowableArray<Handle>& handles, TRAPS);
197 static ValueKlass* returned_value_type(const RegisterMap& reg_map);
198 };
199
200 #endif /* SHARE_VM_OOPS_VALUEKLASS_HPP */
|