Merged
Conversation
…-binary deploy feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
i64 integer optimization for global variables
Summary
findI64EligibleVariablesto identifyconst/letglobals with integer literal initializers that can stay as nativei64instead ofdoublegenerateGlobalVariableDeclarationsso eligible globals are declared as@name = global i64 0instead of@name = global double 0.0i64store path in the global variable initializer to useensureI64coercionfuncBody.statementswasn't generating a GEP becausefuncBody(fromfunc.body || {...}) was an opaquei8*— changed tofunc.body ? func.body.statements : []to preserve the struct type chain||opaque pointer crash pattern in rules.mdDetails
Integer optimization already worked inside functions (
alloca i64,add i64,icmp eq i64), but top-level globals were alwaysdouble, forcingsitofp i64 → doubleconversions. Nowconst LIMIT = 100compiles to@LIMIT = global i64 0with native integer operations.The analysis is conservative — only integer literals qualify. Variables reassigned with non-integer expressions are demoted back to
double. Binary expressions likeLIMIT + STEPdon't qualify because operand tracking across variables isn't implemented yet.The main debugging challenge was an intermittent SIGSEGV in the native compiler's
findI64EligibleVariables. GDB revealedraxcontained ASCII string bytes ("block\0re") being dereferenced as a struct — the function was receiving aBlockStatement*instead of anObjectArray*for the statements parameter. Root cause:func.body || { statements: [] }produces an opaquei8*in the native compiler, and.statementson an opaque pointer doesn't generate a GEP.Test plan
tests/fixtures/globals/integer-globals.tstests const/let integer globals, arithmetic, and comparisonnpm test— 244/244 passnpm run verify— full 3-stage self-hosting passes@LIMIT = global i64 0and@STEP = global i64 0for const integer globals