RFR: 8299721: [Vector API] assert in switch-default of LibraryCallKit::arch_supports_vector_rotate is too weak to catch bugs
Jatin Bhateja
jbhateja at openjdk.org
Fri Jan 6 08:16:49 UTC 2023
On Fri, 6 Jan 2023 07:53:27 GMT, Jie Fu <jiefu at openjdk.org> wrote:
> Hi all,
>
> The switch-default path of LibraryCallKit::arch_supports_vector_rotate means runtime error.
> This is because `lshiftopc`@Line136 and `rshiftopc`@Line137 would be undefined if the switch-default path is taken.
>
>
> 115 int lshiftopc, rshiftopc;
> 116 switch(elem_bt) {
> 117 case T_BYTE:
> 118 lshiftopc = Op_LShiftI;
> 119 rshiftopc = Op_URShiftB;
> 120 break;
> 121 case T_SHORT:
> 122 lshiftopc = Op_LShiftI;
> 123 rshiftopc = Op_URShiftS;
> 124 break;
> 125 case T_INT:
> 126 lshiftopc = Op_LShiftI;
> 127 rshiftopc = Op_URShiftI;
> 128 break;
> 129 case T_LONG:
> 130 lshiftopc = Op_LShiftL;
> 131 rshiftopc = Op_URShiftL;
> 132 break;
> 133 default:
> 134 assert(false, "Unexpected type");
> 135 }
> 136 int lshiftvopc = VectorNode::opcode(lshiftopc, elem_bt); <--- lshiftopc is undefine with the default path
> 137 int rshiftvopc = VectorNode::opcode(rshiftopc, elem_bt); <--- rshiftopc is undefine with the default path
>
>
> So to prevent potential bugs, it would be better to stop and print an error msg even with release VMs, which is done by other switch-default statements in the file.
>
> Thanks.
> Best regards,
> Jie
Rotate operation only works on integral type vectors. But its good to add a fatal msg.
Thanks!
-------------
Marked as reviewed by jbhateja (Reviewer).
PR: https://git.openjdk.org/jdk/pull/11877
More information about the hotspot-compiler-dev
mailing list