2626#ifndef CPU_ZERO_BYTECODEINTERPRETER_ZERO_INLINE_HPP
2727#define CPU_ZERO_BYTECODEINTERPRETER_ZERO_INLINE_HPP
2828
29+ #include " sanitizers/ub.hpp"
30+
2931// Inline interpreter functions for zero
3032
3133inline jfloat BytecodeInterpreter::VMfloatAdd (jfloat op1, jfloat op2) {
@@ -40,6 +42,7 @@ inline jfloat BytecodeInterpreter::VMfloatMul(jfloat op1, jfloat op2) {
4042 return op1 * op2;
4143}
4244
45+ ATTRIBUTE_NO_UBSAN // IEEE-754 division by zero is well-defined
4346inline jfloat BytecodeInterpreter::VMfloatDiv (jfloat op1, jfloat op2) {
4447 return op1 / op2;
4548}
@@ -68,7 +71,7 @@ inline void BytecodeInterpreter::VMmemCopy64(uint32_t to[2],
6871}
6972
7073inline jlong BytecodeInterpreter::VMlongAdd (jlong op1, jlong op2) {
71- return op1 + op2;
74+ return java_add ( op1, op2) ;
7275}
7376
7477inline jlong BytecodeInterpreter::VMlongAnd (jlong op1, jlong op2) {
@@ -82,15 +85,15 @@ inline jlong BytecodeInterpreter::VMlongDiv(jlong op1, jlong op2) {
8285}
8386
8487inline jlong BytecodeInterpreter::VMlongMul (jlong op1, jlong op2) {
85- return op1 * op2;
88+ return java_multiply ( op1, op2) ;
8689}
8790
8891inline jlong BytecodeInterpreter::VMlongOr (jlong op1, jlong op2) {
8992 return op1 | op2;
9093}
9194
9295inline jlong BytecodeInterpreter::VMlongSub (jlong op1, jlong op2) {
93- return op1 - op2;
96+ return java_subtract ( op1, op2) ;
9497}
9598
9699inline jlong BytecodeInterpreter::VMlongXor (jlong op1, jlong op2) {
@@ -104,19 +107,19 @@ inline jlong BytecodeInterpreter::VMlongRem(jlong op1, jlong op2) {
104107}
105108
106109inline jlong BytecodeInterpreter::VMlongUshr (jlong op1, jint op2) {
107- return (( unsigned long long ) op1) >> ( op2 & 0x3F );
110+ return java_shift_right_unsigned ( op1, op2);
108111}
109112
110113inline jlong BytecodeInterpreter::VMlongShr (jlong op1, jint op2) {
111- return op1 >> ( op2 & 0x3F );
114+ return java_shift_right ( op1, op2);
112115}
113116
114117inline jlong BytecodeInterpreter::VMlongShl (jlong op1, jint op2) {
115- return op1 << ( op2 & 0x3F );
118+ return java_shift_left ( op1, op2);
116119}
117120
118121inline jlong BytecodeInterpreter::VMlongNeg (jlong op) {
119- return -op ;
122+ return java_negate (op) ;
120123}
121124
122125inline jlong BytecodeInterpreter::VMlongNot (jlong op) {
@@ -183,8 +186,8 @@ inline jdouble BytecodeInterpreter::VMdoubleAdd(jdouble op1, jdouble op2) {
183186 return op1 + op2;
184187}
185188
189+ ATTRIBUTE_NO_UBSAN // IEEE-754 division by zero is well-defined
186190inline jdouble BytecodeInterpreter::VMdoubleDiv (jdouble op1, jdouble op2) {
187- // Divide by zero... QQQ
188191 return op1 / op2;
189192}
190193
@@ -228,7 +231,7 @@ inline jdouble BytecodeInterpreter::VMfloat2Double(jfloat op) {
228231// Integer Arithmetic
229232
230233inline jint BytecodeInterpreter::VMintAdd (jint op1, jint op2) {
231- return op1 + op2;
234+ return java_add ( op1, op2) ;
232235}
233236
234237inline jint BytecodeInterpreter::VMintAnd (jint op1, jint op2) {
@@ -242,11 +245,11 @@ inline jint BytecodeInterpreter::VMintDiv(jint op1, jint op2) {
242245}
243246
244247inline jint BytecodeInterpreter::VMintMul (jint op1, jint op2) {
245- return op1 * op2;
248+ return java_multiply ( op1, op2) ;
246249}
247250
248251inline jint BytecodeInterpreter::VMintNeg (jint op) {
249- return -op ;
252+ return java_negate (op) ;
250253}
251254
252255inline jint BytecodeInterpreter::VMintOr (jint op1, jint op2) {
@@ -260,19 +263,19 @@ inline jint BytecodeInterpreter::VMintRem(jint op1, jint op2) {
260263}
261264
262265inline jint BytecodeInterpreter::VMintShl (jint op1, jint op2) {
263- return op1 << ( op2 & 0x1F );
266+ return java_shift_left ( op1, op2);
264267}
265268
266269inline jint BytecodeInterpreter::VMintShr (jint op1, jint op2) {
267- return op1 >> ( op2 & 0x1F );
270+ return java_shift_right ( op1, op2);
268271}
269272
270273inline jint BytecodeInterpreter::VMintSub (jint op1, jint op2) {
271- return op1 - op2;
274+ return java_subtract ( op1, op2) ;
272275}
273276
274277inline juint BytecodeInterpreter::VMintUshr (jint op1, jint op2) {
275- return ((juint) op1) >> ( op2 & 0x1F );
278+ return java_shift_right_unsigned ( op1, op2);
276279}
277280
278281inline jint BytecodeInterpreter::VMintXor (jint op1, jint op2) {
0 commit comments