Skip to content

Convert JS magic numbers to struct_info symbols (Part 8/9): libwebgl. NFC - #28266

Open
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:magic_numbers_8_libwebgl
Open

sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:magic_numbers_8_libwebgl

Conversation

@sbc100

@sbc100 sbc100 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Replace hardcoded magic numbers in the WebGL libraries with symbolic constants exposed via struct_info (using {{{ cDefs.* }}} macro keys where needed to avoid Closure code size regressions).

This is part 8 of a 9-part series replacing hardcoded numeric constants across JS libraries and runtime code. Across the full series, 938 new defines are added to struct_info (534 -> 1,472), adding ~22 ms (~2.7%) to an uncached hello-world link (0 ms on cached builds).

Split out from #28199

@sbc100
sbc100 requested a review from kripken November 14, 2026 06:07

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces raw hexadecimal values representing WebGL/OpenGL constants with named constant definitions (such as GL_BYTE, GL_INVALID_OPERATION, and GL_TEXTURE_2D) across src/lib/libwebgl.js and src/lib/libwebgl2.js to improve code readability and maintainability. To support these constants, src/struct_info.json has been updated with the new definitions, and the generated files src/struct_info_generated.json and src/struct_info_generated_wasm64.json have been rebuilt accordingly. There are no review comments, and I have no feedback to provide.

…and libwebgl2. NFC

Replace hardcoded magic numbers in the WebGL libraries with symbolic
constants exposed via `struct_info` (using `{{{ cDefs.* }}}` macro keys
where needed to avoid Closure code size regressions). Stacked on
`magic_numbers_4_libglemu`; adds 138 defines.

This is part 8 of a 9-part series replacing hardcoded numeric constants
across JS libraries and runtime code. Across the full series, 938 new
defines are added to `struct_info` (534 -> 1,472), adding ~22 ms (~2.7%)
to an uncached hello-world link (0 ms on cached builds).

Split out from emscripten-core#28199
@sbc100
sbc100 force-pushed the magic_numbers_8_libwebgl branch from dcdbf10 to 0d60f23 Compare November 14, 2026 06:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant