@@ -77,259 +77,11 @@ bool VectorSupport::is_vector_payload_mf(Klass* klass) {
77
77
return klass->is_subclass_of (vmClasses::vector_VectorPayloadMF_klass ());
78
78
}
79
79
80
- bool VectorSupport::is_vector_mask (Klass* klass) {
81
- return klass->is_subclass_of (vmClasses::vector_VectorMask_klass ());
82
- }
83
-
84
80
bool VectorSupport::skip_value_scalarization (Klass* klass) {
85
81
return VectorSupport::is_vector (klass) ||
86
82
VectorSupport::is_vector_payload_mf (klass);
87
83
}
88
84
89
- BasicType VectorSupport::klass2bt (InstanceKlass* ik) {
90
- assert (ik->is_subclass_of (vmClasses::vector_VectorPayload_klass ()), " %s not a VectorPayload" , ik->name ()->as_C_string ());
91
- fieldDescriptor fd; // find_field initializes fd if found
92
- // static final Class<?> ETYPE;
93
- Klass* holder = ik->find_field (vmSymbols::ETYPE_name (), vmSymbols::class_signature (), &fd);
94
-
95
- assert (holder != nullptr , " sanity" );
96
- assert (fd.is_static (), " " );
97
- assert (fd.offset () > 0 , " " );
98
-
99
- if (is_vector_mask (ik)) {
100
- return T_BOOLEAN;
101
- } else { // vector and mask
102
- oop value = ik->java_mirror ()->obj_field (fd.offset ());
103
- BasicType elem_bt = java_lang_Class::as_BasicType (value);
104
- return elem_bt;
105
- }
106
- }
107
-
108
- jint VectorSupport::klass2length (InstanceKlass* ik) {
109
- fieldDescriptor fd; // find_field initializes fd if found
110
- // static final int VLENGTH;
111
- Klass* holder = ik->find_field (vmSymbols::VLENGTH_name (), vmSymbols::int_signature (), &fd);
112
-
113
- assert (holder != nullptr , " sanity" );
114
- assert (fd.is_static (), " " );
115
- assert (fd.offset () > 0 , " " );
116
-
117
- jint vlen = ik->java_mirror ()->int_field (fd.offset ());
118
- assert (vlen > 0 , " " );
119
- return vlen;
120
- }
121
-
122
- #ifdef COMPILER2
123
- Handle VectorSupport::allocate_vector_payload_helper (InstanceKlass* ik, int num_elem, BasicType elem_bt, int larval, TRAPS) {
124
- assert (ik->is_inline_klass (), " " );
125
- instanceOop obj = InlineKlass::cast (ik)->allocate_instance (THREAD);
126
- if (larval) obj->set_mark (obj->mark ().enter_larval_state ());
127
-
128
- fieldDescriptor fd;
129
- Klass* def = ik->find_field (vmSymbols::mfield_name (), vmSymbols::type_signature (elem_bt), false , &fd);
130
- assert (fd.is_multifield_base () && fd.secondary_fields_count (fd.index ()) == num_elem, " " );
131
- return Handle (THREAD, obj);
132
- }
133
-
134
- Symbol* VectorSupport::get_vector_payload_field_signature (BasicType elem_bt, int num_elem) {
135
- switch (elem_bt) {
136
- case T_BOOLEAN:
137
- switch (num_elem) {
138
- case 1 : return vmSymbols::vector_VectorPayloadMF8Z_signature ();
139
- case 2 : return vmSymbols::vector_VectorPayloadMF16Z_signature ();
140
- case 4 : return vmSymbols::vector_VectorPayloadMF32Z_signature ();
141
- case 8 : return vmSymbols::vector_VectorPayloadMF64Z_signature ();
142
- case 16 : return vmSymbols::vector_VectorPayloadMF128Z_signature ();
143
- case 32 : return vmSymbols::vector_VectorPayloadMF256Z_signature ();
144
- case 64 : return vmSymbols::vector_VectorPayloadMF512Z_signature ();
145
- default : ShouldNotReachHere ();
146
- } break ;
147
- case T_BYTE:
148
- switch (num_elem) {
149
- case 1 : return vmSymbols::vector_VectorPayloadMF8B_signature ();
150
- case 2 : return vmSymbols::vector_VectorPayloadMF16B_signature ();
151
- case 4 : return vmSymbols::vector_VectorPayloadMF32B_signature ();
152
- case 8 : return vmSymbols::vector_VectorPayloadMF64B_signature ();
153
- case 16 : return vmSymbols::vector_VectorPayloadMF128B_signature ();
154
- case 32 : return vmSymbols::vector_VectorPayloadMF256B_signature ();
155
- case 64 : return vmSymbols::vector_VectorPayloadMF512B_signature ();
156
- default : ShouldNotReachHere ();
157
- } break ;
158
- case T_SHORT:
159
- switch (num_elem) {
160
- case 4 : return vmSymbols::vector_VectorPayloadMF64S_signature ();
161
- case 8 : return vmSymbols::vector_VectorPayloadMF128S_signature ();
162
- case 16 : return vmSymbols::vector_VectorPayloadMF256S_signature ();
163
- case 32 : return vmSymbols::vector_VectorPayloadMF512S_signature ();
164
- default : ShouldNotReachHere ();
165
- } break ;
166
- case T_INT:
167
- switch (num_elem) {
168
- case 2 : return vmSymbols::vector_VectorPayloadMF64I_signature ();
169
- case 4 : return vmSymbols::vector_VectorPayloadMF128I_signature ();
170
- case 8 : return vmSymbols::vector_VectorPayloadMF256I_signature ();
171
- case 16 : return vmSymbols::vector_VectorPayloadMF512I_signature ();
172
- default : ShouldNotReachHere ();
173
- } break ;
174
- case T_LONG:
175
- switch (num_elem) {
176
- case 1 : return vmSymbols::vector_VectorPayloadMF64L_signature ();
177
- case 2 : return vmSymbols::vector_VectorPayloadMF128L_signature ();
178
- case 4 : return vmSymbols::vector_VectorPayloadMF256L_signature ();
179
- case 8 : return vmSymbols::vector_VectorPayloadMF512L_signature ();
180
- default : ShouldNotReachHere ();
181
- } break ;
182
- case T_FLOAT:
183
- switch (num_elem) {
184
- case 2 : return vmSymbols::vector_VectorPayloadMF64F_signature ();
185
- case 4 : return vmSymbols::vector_VectorPayloadMF128F_signature ();
186
- case 8 : return vmSymbols::vector_VectorPayloadMF256F_signature ();
187
- case 16 : return vmSymbols::vector_VectorPayloadMF512F_signature ();
188
- default : ShouldNotReachHere ();
189
- } break ;
190
- case T_DOUBLE:
191
- switch (num_elem) {
192
- case 1 : return vmSymbols::vector_VectorPayloadMF64D_signature ();
193
- case 2 : return vmSymbols::vector_VectorPayloadMF128D_signature ();
194
- case 4 : return vmSymbols::vector_VectorPayloadMF256D_signature ();
195
- case 8 : return vmSymbols::vector_VectorPayloadMF512D_signature ();
196
- default : ShouldNotReachHere ();
197
- } break ;
198
- default :
199
- ShouldNotReachHere ();
200
- }
201
- return NULL ;
202
- }
203
-
204
- InstanceKlass* VectorSupport::get_vector_payload_klass (BasicType elem_bt, int num_elem) {
205
- switch (elem_bt) {
206
- case T_BOOLEAN:
207
- switch (num_elem) {
208
- case 1 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF8Z_klass));
209
- case 2 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF16Z_klass));
210
- case 4 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF32Z_klass));
211
- case 8 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF64Z_klass));
212
- case 16 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF128Z_klass));
213
- case 32 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF256Z_klass));
214
- case 64 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF512Z_klass));
215
- default : ShouldNotReachHere ();
216
- } break ;
217
- case T_BYTE:
218
- switch (num_elem) {
219
- case 1 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF8B_klass));
220
- case 2 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF16B_klass));
221
- case 4 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF32B_klass));
222
- case 8 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF64B_klass));
223
- case 16 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF128B_klass));
224
- case 32 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF256B_klass));
225
- case 64 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF512B_klass));
226
- default : ShouldNotReachHere ();
227
- } break ;
228
- case T_SHORT:
229
- switch (num_elem) {
230
- case 4 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF64S_klass));
231
- case 8 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF128S_klass));
232
- case 16 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF256S_klass));
233
- case 32 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF512S_klass));
234
- default : ShouldNotReachHere ();
235
- } break ;
236
- case T_INT:
237
- switch (num_elem) {
238
- case 2 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF64I_klass));
239
- case 4 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF128I_klass));
240
- case 8 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF256I_klass));
241
- case 16 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF512I_klass));
242
- default : ShouldNotReachHere ();
243
- } break ;
244
- case T_LONG:
245
- switch (num_elem) {
246
- case 1 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF64L_klass));
247
- case 2 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF128L_klass));
248
- case 4 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF256L_klass));
249
- case 8 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF512L_klass));
250
- default : ShouldNotReachHere ();
251
- } break ;
252
- case T_FLOAT:
253
- switch (num_elem) {
254
- case 2 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF64F_klass));
255
- case 4 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF128F_klass));
256
- case 8 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF256F_klass));
257
- case 16 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF512F_klass));
258
- default : ShouldNotReachHere ();
259
- } break ;
260
- case T_DOUBLE:
261
- switch (num_elem) {
262
- case 1 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF64D_klass));
263
- case 2 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF128D_klass));
264
- case 4 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF256D_klass));
265
- case 8 : return vmClasses::klass_at (VM_CLASS_ID (vector_VectorPayloadMF512D_klass));
266
- default : ShouldNotReachHere ();
267
- } break ;
268
- default :
269
- ShouldNotReachHere ();
270
- }
271
- return NULL ;
272
- }
273
-
274
- Handle VectorSupport::allocate_vector_payload (InstanceKlass* ik, int num_elem, BasicType elem_bt, frame* fr, RegisterMap* reg_map, ObjectValue* ov, TRAPS) {
275
- intptr_t is_larval = StackValue::create_stack_value (fr, reg_map, ov->is_larval ())->get_int ();
276
- jint larval = (jint)*((jint*)&is_larval);
277
- // Vector payload value in an aligned adjacent tuple (8, 16, 32 or 64 bytes).
278
- return allocate_vector_payload_helper (ik, num_elem, elem_bt, larval, THREAD); // safepoint
279
- }
280
-
281
- instanceOop VectorSupport::allocate_vector_payload (InstanceKlass* ik, frame* fr, RegisterMap* reg_map, ObjectValue* ov, TRAPS) {
282
- assert (is_vector_payload_mf (ik), " %s not a vector payload" , ik->name ()->as_C_string ());
283
- assert (ik->is_inline_klass (), " " );
284
-
285
- int num_elem = 0 ;
286
- BasicType elem_bt = T_ILLEGAL;
287
- for (JavaFieldStream fs (ik); !fs.done (); fs.next ()) {
288
- fieldDescriptor& fd = fs.field_descriptor ();
289
- if (fd.is_multifield_base ()) {
290
- elem_bt = fd.field_type ();
291
- num_elem = fd.secondary_fields_count (fd.index ());
292
- break ;
293
- }
294
- }
295
- assert (num_elem != 0 , " " );
296
- Handle payload_instance = VectorSupport::allocate_vector_payload (ik, num_elem, elem_bt, fr, reg_map, ov, CHECK_NULL);
297
- return (instanceOop)payload_instance ();
298
- }
299
-
300
- instanceOop VectorSupport::allocate_vector (InstanceKlass* ik, frame* fr, RegisterMap* reg_map, ObjectValue* ov, TRAPS) {
301
- assert (is_vector (ik), " %s not a vector" , ik->name ()->as_C_string ());
302
- assert (ik->is_inline_klass (), " " );
303
-
304
- int num_elem = klass2length (ik);
305
- BasicType elem_bt = klass2bt (ik);
306
-
307
- // On-heap vector values are represented as primitive class instances with a multi-field payload.
308
- InstanceKlass* payload_class = get_vector_payload_klass (elem_bt, num_elem);
309
- assert (payload_class->is_inline_klass (), " " );
310
-
311
- Handle payload_instance = VectorSupport::allocate_vector_payload (payload_class, num_elem, elem_bt, fr, reg_map, ov, CHECK_NULL);
312
-
313
- Deoptimization::reassign_fields_by_klass (payload_class, fr, reg_map, ov, 0 , payload_instance (), true , 0 , CHECK_NULL);
314
-
315
- instanceOop vbox = ik->allocate_instance (THREAD);
316
- Handle vbox_h = Handle (THREAD, vbox);
317
-
318
- fieldDescriptor fd;
319
- Symbol* payload_sig = VectorSupport::get_vector_payload_field_signature (elem_bt, num_elem);
320
- Klass* def = ik->find_field (vmSymbols::payload_name (), payload_sig, false , &fd);
321
- assert (def != NULL , " " );
322
-
323
- if (fd.is_inlined ()) {
324
- InlineKlass* field_ik = InlineKlass::cast (ik->get_inline_type_field_klass (fd.index ()));
325
- field_ik->write_inlined_field (vbox_h (), fd.offset (), payload_instance (), THREAD);
326
- } else {
327
- vbox_h ()->obj_field_put (fd.offset (), payload_instance ());
328
- }
329
- return vbox;
330
- }
331
- #endif // COMPILER2
332
-
333
85
#ifdef COMPILER2
334
86
int VectorSupport::vop2ideal (jint id, BasicType bt) {
335
87
VectorOperation vop = (VectorOperation)id;
0 commit comments