8259228: Zero: rewrite (put|get)field from if-else chains to switches

Reviewed-by: aph, coleenp
This commit is contained in:
Aleksey Shipilev 2021-03-05 10:40:43 +00:00
parent 9730266d02
commit 75fb7ccf34

View File

@ -1636,46 +1636,74 @@ run:
if (support_IRIW_for_not_multiple_copy_atomic_cpu) { if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
OrderAccess::fence(); OrderAccess::fence();
} }
if (tos_type == atos) { switch (tos_type) {
VERIFY_OOP(obj->obj_field_acquire(field_offset)); case btos:
SET_STACK_OBJECT(obj->obj_field_acquire(field_offset), -1); case ztos:
} else if (tos_type == itos) { SET_STACK_INT(obj->byte_field_acquire(field_offset), -1);
SET_STACK_INT(obj->int_field_acquire(field_offset), -1); break;
} else if (tos_type == ltos) { case ctos:
SET_STACK_LONG(obj->long_field_acquire(field_offset), 0); SET_STACK_INT(obj->char_field_acquire(field_offset), -1);
MORE_STACK(1); break;
} else if (tos_type == btos || tos_type == ztos) { case stos:
SET_STACK_INT(obj->byte_field_acquire(field_offset), -1); SET_STACK_INT(obj->short_field_acquire(field_offset), -1);
} else if (tos_type == ctos) { break;
SET_STACK_INT(obj->char_field_acquire(field_offset), -1); case itos:
} else if (tos_type == stos) { SET_STACK_INT(obj->int_field_acquire(field_offset), -1);
SET_STACK_INT(obj->short_field_acquire(field_offset), -1); break;
} else if (tos_type == ftos) { case ftos:
SET_STACK_FLOAT(obj->float_field_acquire(field_offset), -1); SET_STACK_FLOAT(obj->float_field_acquire(field_offset), -1);
} else { break;
SET_STACK_DOUBLE(obj->double_field_acquire(field_offset), 0); case ltos:
MORE_STACK(1); SET_STACK_LONG(obj->long_field_acquire(field_offset), 0);
MORE_STACK(1);
break;
case dtos:
SET_STACK_DOUBLE(obj->double_field_acquire(field_offset), 0);
MORE_STACK(1);
break;
case atos: {
oop val = obj->obj_field_acquire(field_offset);
VERIFY_OOP(val);
SET_STACK_OBJECT(val, -1);
break;
}
default:
ShouldNotReachHere();
} }
} else { } else {
if (tos_type == atos) { switch (tos_type) {
VERIFY_OOP(obj->obj_field(field_offset)); case btos:
SET_STACK_OBJECT(obj->obj_field(field_offset), -1); case ztos:
} else if (tos_type == itos) { SET_STACK_INT(obj->byte_field(field_offset), -1);
SET_STACK_INT(obj->int_field(field_offset), -1); break;
} else if (tos_type == ltos) { case ctos:
SET_STACK_LONG(obj->long_field(field_offset), 0); SET_STACK_INT(obj->char_field(field_offset), -1);
MORE_STACK(1); break;
} else if (tos_type == btos || tos_type == ztos) { case stos:
SET_STACK_INT(obj->byte_field(field_offset), -1); SET_STACK_INT(obj->short_field(field_offset), -1);
} else if (tos_type == ctos) { break;
SET_STACK_INT(obj->char_field(field_offset), -1); case itos:
} else if (tos_type == stos) { SET_STACK_INT(obj->int_field(field_offset), -1);
SET_STACK_INT(obj->short_field(field_offset), -1); break;
} else if (tos_type == ftos) { case ftos:
SET_STACK_FLOAT(obj->float_field(field_offset), -1); SET_STACK_FLOAT(obj->float_field(field_offset), -1);
} else { break;
SET_STACK_DOUBLE(obj->double_field(field_offset), 0); case ltos:
MORE_STACK(1); SET_STACK_LONG(obj->long_field(field_offset), 0);
MORE_STACK(1);
break;
case dtos:
SET_STACK_DOUBLE(obj->double_field(field_offset), 0);
MORE_STACK(1);
break;
case atos: {
oop val = obj->obj_field(field_offset);
VERIFY_OOP(val);
SET_STACK_OBJECT(val, -1);
break;
}
default:
ShouldNotReachHere();
} }
} }
@ -1745,49 +1773,75 @@ run:
// //
int field_offset = cache->f2_as_index(); int field_offset = cache->f2_as_index();
if (cache->is_volatile()) { if (cache->is_volatile()) {
if (tos_type == itos) { switch (tos_type) {
obj->release_int_field_put(field_offset, STACK_INT(-1)); case ztos:
} else if (tos_type == atos) { obj->release_byte_field_put(field_offset, (STACK_INT(-1) & 1)); // only store LSB
VERIFY_OOP(STACK_OBJECT(-1)); break;
obj->release_obj_field_put(field_offset, STACK_OBJECT(-1)); case btos:
} else if (tos_type == btos) { obj->release_byte_field_put(field_offset, STACK_INT(-1));
obj->release_byte_field_put(field_offset, STACK_INT(-1)); break;
} else if (tos_type == ztos) { case ctos:
int bool_field = STACK_INT(-1); // only store LSB obj->release_char_field_put(field_offset, STACK_INT(-1));
obj->release_byte_field_put(field_offset, (bool_field & 1)); break;
} else if (tos_type == ltos) { case stos:
obj->release_long_field_put(field_offset, STACK_LONG(-1)); obj->release_short_field_put(field_offset, STACK_INT(-1));
} else if (tos_type == ctos) { break;
obj->release_char_field_put(field_offset, STACK_INT(-1)); case itos:
} else if (tos_type == stos) { obj->release_int_field_put(field_offset, STACK_INT(-1));
obj->release_short_field_put(field_offset, STACK_INT(-1)); break;
} else if (tos_type == ftos) { case ftos:
obj->release_float_field_put(field_offset, STACK_FLOAT(-1)); obj->release_float_field_put(field_offset, STACK_FLOAT(-1));
} else { break;
obj->release_double_field_put(field_offset, STACK_DOUBLE(-1)); case ltos:
obj->release_long_field_put(field_offset, STACK_LONG(-1));
break;
case dtos:
obj->release_double_field_put(field_offset, STACK_DOUBLE(-1));
break;
case atos: {
oop val = STACK_OBJECT(-1);
VERIFY_OOP(val);
obj->release_obj_field_put(field_offset, val);
break;
}
default:
ShouldNotReachHere();
} }
OrderAccess::storeload(); OrderAccess::storeload();
} else { } else {
if (tos_type == itos) { switch (tos_type) {
obj->int_field_put(field_offset, STACK_INT(-1)); case ztos:
} else if (tos_type == atos) { obj->byte_field_put(field_offset, (STACK_INT(-1) & 1)); // only store LSB
VERIFY_OOP(STACK_OBJECT(-1)); break;
obj->obj_field_put(field_offset, STACK_OBJECT(-1)); case btos:
} else if (tos_type == btos) { obj->byte_field_put(field_offset, STACK_INT(-1));
obj->byte_field_put(field_offset, STACK_INT(-1)); break;
} else if (tos_type == ztos) { case ctos:
int bool_field = STACK_INT(-1); // only store LSB obj->char_field_put(field_offset, STACK_INT(-1));
obj->byte_field_put(field_offset, (bool_field & 1)); break;
} else if (tos_type == ltos) { case stos:
obj->long_field_put(field_offset, STACK_LONG(-1)); obj->short_field_put(field_offset, STACK_INT(-1));
} else if (tos_type == ctos) { break;
obj->char_field_put(field_offset, STACK_INT(-1)); case itos:
} else if (tos_type == stos) { obj->int_field_put(field_offset, STACK_INT(-1));
obj->short_field_put(field_offset, STACK_INT(-1)); break;
} else if (tos_type == ftos) { case ftos:
obj->float_field_put(field_offset, STACK_FLOAT(-1)); obj->float_field_put(field_offset, STACK_FLOAT(-1));
} else { break;
obj->double_field_put(field_offset, STACK_DOUBLE(-1)); case ltos:
obj->long_field_put(field_offset, STACK_LONG(-1));
break;
case dtos:
obj->double_field_put(field_offset, STACK_DOUBLE(-1));
break;
case atos: {
oop val = STACK_OBJECT(-1);
VERIFY_OOP(val);
obj->obj_field_put(field_offset, val);
break;
}
default:
ShouldNotReachHere();
} }
} }