Skip to content

Commit 7ed0e8c

Browse files
mvogttechclaude
andcommitted
fix: add SAFE_VZEROUPPER macro to ws_base64_asm.asm to fix NASM build
The VBMI2 path used SAFE_VZEROUPPER but the macro was never defined in this file. NASM parsed it as a bare non-local label, breaking local label scope so .avx512vbmi_path/.avx2_path/.sse2_path/.scalar_path became unreachable from the dispatch code under ws_base64_encode. Also converts remaining bare vzeroupper calls in the VBMI and AVX2 tail paths to use the macro for AMD consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3c5bd2e commit 7ed0e8c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ubuntu-latest, windows-latest, macos-latest]
17+
os: [ubuntu-latest, windows-latest]
1818
node: [20, 22, 24]
1919

2020
steps:

src/ws_base64_asm.asm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ DEFAULT REL
107107
extern cpu_tier
108108
extern cpu_features
109109

110+
; Skip vzeroupper on AMD (no SSE/AVX transition penalty on Zen).
111+
%macro SAFE_VZEROUPPER 0
112+
test dword [cpu_features], (1 << 5)
113+
jnz %%skip
114+
vzeroupper
115+
%%skip:
116+
%endmacro
117+
110118
; ============================================================================
111119
; .data — lookup tables and broadcast constant vectors
112120
; ============================================================================
@@ -370,7 +378,7 @@ ws_base64_encode:
370378
jmp .avx512vbmi_loop
371379

372380
.avx512vbmi_tail:
373-
vzeroupper
381+
SAFE_VZEROUPPER
374382
jmp .scalar_path
375383

376384

@@ -476,7 +484,7 @@ ws_base64_encode:
476484
; Clear upper YMM state before using legacy SSE or scalar instructions.
477485
; Required to avoid AVX-SSE transition penalties and for correctness when
478486
; mixing VEX-encoded and non-VEX-encoded instructions.
479-
vzeroupper
487+
SAFE_VZEROUPPER
480488
jmp .scalar_path ; handle remaining < 24 bytes
481489

482490

0 commit comments

Comments
 (0)