@@ -65,6 +65,8 @@ BasicType VectorSupport::klass2bt(InstanceKlass* ik) {
65
65
66
66
if (is_vector_shuffle (ik)) {
67
67
return T_BYTE;
68
+ } else if (is_vector_mask (ik)) {
69
+ return T_BOOLEAN;
68
70
} else { // vector and mask
69
71
oop value = ik->java_mirror ()->obj_field (fd.offset ());
70
72
BasicType elem_bt = java_lang_Class::as_BasicType (value);
@@ -86,48 +88,34 @@ jint VectorSupport::klass2length(InstanceKlass* ik) {
86
88
return vlen;
87
89
}
88
90
89
- void VectorSupport::init_payload_element (typeArrayOop arr, bool is_mask, BasicType elem_bt, int index, address addr) {
90
- if (is_mask) {
91
- // Masks require special handling: when boxed they are packed and stored in boolean
92
- // arrays, but in scalarized form they have the same size as corresponding vectors.
93
- // For example, Int512Mask is represented in memory as boolean[16], but
94
- // occupies the whole 512-bit vector register when scalarized.
95
- // (In generated code, the conversion is performed by VectorStoreMask.)
96
- //
97
- // TODO: revisit when predicate registers are fully supported.
98
- switch (elem_bt) {
99
- case T_BYTE: arr->bool_at_put (index , (*(jbyte*)addr) != 0 ); break ;
100
- case T_SHORT: arr->bool_at_put (index , (*(jshort*)addr) != 0 ); break ;
101
- case T_INT: // fall-through
102
- case T_FLOAT: arr->bool_at_put (index , (*(jint*)addr) != 0 ); break ;
103
- case T_LONG: // fall-through
104
- case T_DOUBLE: arr->bool_at_put (index , (*(jlong*)addr) != 0 ); break ;
105
-
106
- default : fatal (" unsupported: %s" , type2name (elem_bt));
107
- }
108
- } else {
109
- switch (elem_bt) {
110
- case T_BYTE: arr-> byte_at_put (index , *(jbyte*)addr); break ;
111
- case T_SHORT: arr-> short_at_put (index , *(jshort*)addr); break ;
112
- case T_INT: arr-> int_at_put (index , *(jint*)addr); break ;
113
- case T_FLOAT: arr-> float_at_put (index , *(jfloat*)addr); break ;
114
- case T_LONG: arr-> long_at_put (index , *(jlong*)addr); break ;
115
- case T_DOUBLE: arr->double_at_put (index , *(jdouble*)addr); break ;
116
-
117
- default : fatal (" unsupported: %s" , type2name (elem_bt));
118
- }
91
+ // Masks require special handling: when boxed they are packed and stored in boolean
92
+ // arrays, but in scalarized form they have the same size as corresponding vectors.
93
+ // For example, Int512Mask is represented in memory as boolean[16], but
94
+ // occupies the whole 512-bit vector register when scalarized.
95
+ // During scalarization inserting a VectorStoreMask node between mask
96
+ // and safepoint node always ensures the existence of masks in a boolean array.
97
+
98
+ void VectorSupport::init_payload_element (typeArrayOop arr, BasicType elem_bt, int index, address addr) {
99
+ switch (elem_bt) {
100
+ case T_BOOLEAN: arr-> byte_at_put (index , *(jboolean*)addr); break ;
101
+ case T_BYTE: arr-> byte_at_put (index , *(jbyte*)addr); break ;
102
+ case T_SHORT: arr-> short_at_put (index , *(jshort*)addr); break ;
103
+ case T_INT: arr-> int_at_put (index , *(jint*)addr); break ;
104
+ case T_FLOAT: arr-> float_at_put (index , *(jfloat*)addr); break ;
105
+ case T_LONG: arr-> long_at_put (index , *(jlong*)addr); break ;
106
+ case T_DOUBLE: arr->double_at_put (index , *(jdouble*)addr); break ;
107
+
108
+ default : fatal (" unsupported: %s" , type2name (elem_bt));
119
109
}
120
110
}
121
111
122
112
Handle VectorSupport::allocate_vector_payload_helper (InstanceKlass* ik, frame* fr, RegisterMap* reg_map, Location location, TRAPS) {
123
- bool is_mask = is_vector_mask (ik);
124
-
125
113
int num_elem = klass2length (ik);
126
114
BasicType elem_bt = klass2bt (ik);
127
115
int elem_size = type2aelembytes (elem_bt);
128
116
129
117
// On-heap vector values are represented as primitive arrays.
130
- TypeArrayKlass* tak = TypeArrayKlass::cast (Universe::typeArrayKlassObj (is_mask ? T_BOOLEAN : elem_bt));
118
+ TypeArrayKlass* tak = TypeArrayKlass::cast (Universe::typeArrayKlassObj (elem_bt));
131
119
132
120
typeArrayOop arr = tak->allocate (num_elem, CHECK_NH); // safepoint
133
121
@@ -140,13 +128,13 @@ Handle VectorSupport::allocate_vector_payload_helper(InstanceKlass* ik, frame* f
140
128
int off = (i * elem_size) % VMRegImpl::stack_slot_size;
141
129
142
130
address elem_addr = reg_map->location (vreg, vslot) + off; // assumes little endian element order
143
- init_payload_element (arr, is_mask, elem_bt, i, elem_addr);
131
+ init_payload_element (arr, elem_bt, i, elem_addr);
144
132
}
145
133
} else {
146
134
// Value was directly saved on the stack.
147
135
address base_addr = ((address)fr->unextended_sp ()) + location.stack_offset ();
148
136
for (int i = 0 ; i < num_elem; i++) {
149
- init_payload_element (arr, is_mask, elem_bt, i, base_addr + i * elem_size);
137
+ init_payload_element (arr, elem_bt, i, base_addr + i * elem_size);
150
138
}
151
139
}
152
140
return Handle (THREAD, arr);
0 commit comments