From 147c27b96ef54fda0dac1df91bbf273618424811 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 27 Aug 2022 01:51:56 +0600 Subject: [PATCH] voodoo_codegen_x86*: Remove bounds checking for block_pos Block sizes are sufficiently large enough to ensure no buffer overrun as block_pos is initialized to 0 every time a block is requested. It should cause a good performance increase on x86 and x86-64. --- src/include/86box/vid_voodoo_codegen_x86-64.h | 8 -------- src/include/86box/vid_voodoo_codegen_x86.h | 8 -------- 2 files changed, 16 deletions(-) diff --git a/src/include/86box/vid_voodoo_codegen_x86-64.h b/src/include/86box/vid_voodoo_codegen_x86-64.h index bd992e1d0..4999f38c5 100644 --- a/src/include/86box/vid_voodoo_codegen_x86-64.h +++ b/src/include/86box/vid_voodoo_codegen_x86-64.h @@ -46,32 +46,24 @@ static int next_block_to_write[4] = { 0, 0 }; #define addbyte(val) \ do { \ code_block[block_pos++] = val; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) #define addword(val) \ do { \ *(uint16_t *) &code_block[block_pos] = val; \ block_pos += 2; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) #define addlong(val) \ do { \ *(uint32_t *) &code_block[block_pos] = val; \ block_pos += 4; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) #define addquad(val) \ do { \ *(uint64_t *) &code_block[block_pos] = val; \ block_pos += 8; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) static __m128i xmm_01_w; // = 0x0001000100010001ull; diff --git a/src/include/86box/vid_voodoo_codegen_x86.h b/src/include/86box/vid_voodoo_codegen_x86.h index f9685344f..9432fa3b3 100644 --- a/src/include/86box/vid_voodoo_codegen_x86.h +++ b/src/include/86box/vid_voodoo_codegen_x86.h @@ -44,32 +44,24 @@ static int next_block_to_write[4] = { 0, 0 }; #define addbyte(val) \ do { \ code_block[block_pos++] = val; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) #define addword(val) \ do { \ *(uint16_t *) &code_block[block_pos] = val; \ block_pos += 2; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) #define addlong(val) \ do { \ *(uint32_t *) &code_block[block_pos] = val; \ block_pos += 4; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) #define addquad(val) \ do { \ *(uint64_t *) &code_block[block_pos] = val; \ block_pos += 8; \ - if (block_pos >= BLOCK_SIZE) \ - fatal("Over!\n"); \ } while (0) static __m128i xmm_01_w; // = 0x0001000100010001ull;