@@ -1430,23 +1430,28 @@ term bif_erlang_float_1(Context *ctx, uint32_t fail_label, int live, term arg1)
1430
1430
1431
1431
typedef int64_t (* bitwise_op )(int64_t a , int64_t b );
1432
1432
1433
- static inline term bitwise_helper (Context * ctx , uint32_t fail_label , int live , term arg1 , term arg2 , bitwise_op op )
1433
+ static inline term bitwise_helper (
1434
+ Context * ctx , uint32_t fail_label , int live , term arg1 , term arg2 , bitwise_op op )
1434
1435
{
1435
- UNUSED (live );
1436
+ if (LIKELY (term_is_any_integer (arg1 ) && term_is_any_integer (arg2 ))) {
1437
+ size_t arg1_size = term_is_integer (arg1 ) ? 0 : term_boxed_size (arg1 );
1438
+ size_t arg2_size = term_is_integer (arg2 ) ? 0 : term_boxed_size (arg2 );
1439
+ if (MAX (arg1_size , arg2_size ) <= BOXED_TERMS_REQUIRED_FOR_INT64 ) {
1440
+ int64_t a = term_maybe_unbox_int64 (arg1 );
1441
+ int64_t b = term_maybe_unbox_int64 (arg2 );
1442
+ int64_t result = op (a , b );
1436
1443
1437
- if (UNLIKELY (!term_is_any_integer (arg1 ) || !term_is_any_integer (arg2 ))) {
1444
+ #if BOXED_TERMS_REQUIRED_FOR_INT64 > 1
1445
+ return make_maybe_boxed_int64 (ctx , fail_label , live , result );
1446
+ #else
1447
+ return make_maybe_boxed_int (ctx , fail_label , live , result );
1448
+ #endif
1449
+ } else {
1450
+ abort ();
1451
+ }
1452
+ } else {
1438
1453
RAISE_ERROR_BIF (fail_label , BADARITH_ATOM );
1439
1454
}
1440
-
1441
- int64_t a = term_maybe_unbox_int64 (arg1 );
1442
- int64_t b = term_maybe_unbox_int64 (arg2 );
1443
- int64_t result = op (a , b );
1444
-
1445
- #if BOXED_TERMS_REQUIRED_FOR_INT64 > 1
1446
- return make_maybe_boxed_int64 (ctx , fail_label , live , result );
1447
- #else
1448
- return make_maybe_boxed_int (ctx , fail_label , live , result );
1449
- #endif
1450
1455
}
1451
1456
1452
1457
static inline int64_t bor (int64_t a , int64_t b )
0 commit comments