Skip to content

Instantly share code, notes, and snippets.

View ShanonJackson's full-sized avatar

Shanon Jackson ShanonJackson

  • Spark
  • New Zealand
View GitHub Profile
@ShanonJackson
ShanonJackson / lexer.c
Last active July 22, 2026 23:40
x86_64 AMD ZEN 3 Lexing JS at 5-7GB/S (Just boundary finding + tokenization) - Purposely excludes some things for demonstration purposes.
/*
* SIMD JavaScript/TypeScript lexer for x86-64 AVX2, tuned for AMD Zen 3 <<< IMPORTANT
*
* CccLex L = {0};
* uint8_t *buf = ccc_source_alloc(n); // 64-byte aligned, 64B zero-padded
* memcpy(buf, bytes, n);
* size_t ntok = ccc_lex(&L, buf, n); // tokens: L.starts[i], L.kinds[i]
* ccc_source_free(buf);
* ccc_free(&L);
*