Repository navigation
[VFDLIBM-139] Assert the width, no FMA and no call in the C2 code of exp's arms - #141
Merged
Merged
Conversation
added 9 commits
November 22, 2026 23:28
…exp's arms dev/hsdis-build.sh builds hsdis into target/hsdis from two pinned files of jdk-25-ga against Capstone 5 (built from a pinned release when the system's is older) and checks that HotSpot disassembles with it. hsdis is a tool: its source and binary are never committed. ExpAsmProbe runs each exp arm in a loop, one JVM per width, under -Xbatch with the body forced inline and CompileCommand=print; AsmCheck parses the last standard C2 nmethod and holds the rules (every byte decoded, packed-double arithmetic on the width's registers, no FMA, no call but uncommon traps and the entry barrier, no StrictMath frame). ExpAsmTest applies them at each width, skipping with its reason without hsdis; AsmCheckSelfTest shows each rule failing. CI's x86 rows build hsdis and require the check. SKILLS.md holds the rules, the lessons and the laptop's census. Part of #139. Generated-by: Claude Code (Opus 5.5)
…dis, cached hsdis in CI Generated-by: Claude Code (Opus 5.5)
…ion arguments, rewrap Generated-by: Claude Code (Opus 5.5)
…n, key the cache on the image, skip on a JDK's own hsdis Generated-by: Claude Code (Opus 5.5)
… reads, refuse a JDK's own hsdis in the script Generated-by: Claude Code (Opus 5.5)
…is in the JDK too, name a missing JDK Generated-by: Claude Code (Opus 5.5)
Generated-by: Claude Code (Opus 5.5)
… dump is not read, cache the library alone Generated-by: Claude Code (Opus 5.5)
…es; correct the C1 note Generated-by: Claude Code (Opus 5.5)
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.
What changes were proposed in this pull request?
Part of #139: step 1 for
exp, and the census of step 2 forexp.dev/hsdis-build.shbuilds hsdis intotarget/hsdisfrom two files of the jdk-25-ga tag (hsdis-capstone.c,hsdis.h), fetched alone with pinned SHA-256s, against Capstone 5; it builds the pinned Capstone 5.0.7 from source when the system's is not 5, and passes only if HotSpot then prints a real[Disassembly](and no hsdis of the JDK's own shadows it).ExpAsmProberuns eachexparm (finish and blended, unmasked and masked, andexpRarewithexpCore) in anExpBenchmark-shaped loop, one JVM perVectorWidth, under-Xbatch, the row's-XXoptions, the forced inline andCompileCommand=printon its loops.AsmCheckparses the last standard C2 nmethod of each loop, from entry point to stubs, in Intel syntax, and holds the rules: every byte and line read; packed-double arithmetic on the width's registers only and no scalar double arithmetic; no FMA of any form; no call but uncommon traps and the entry barrier; noStrictMathorFdLibmframe.ExpAsmTestapplies them at 128, 256, 512 bits and the preferred species, and prints the census as Markdown rows; at 128 bits on x86 the call rule is not asserted, since no two-lane mask lowers there and the arms run the Java fallback.The test skips with its reason when the host is not Linux x86-64, when no hsdis is found, when the JDK has one of its own, and when one is found but HotSpot printed no disassembly;
VFDLIBM_ASM_REQUIRED=trueturns the last three into failures.AsmCheckSelfTestfeeds crafted disassembly in HotSpot's real line shapes: a clean body passes, and an FMA, a narrow or scalar body, a call, undecoded bytes, an unread line and aStrictMathframe each fail their rule; a hex dump, a C1 compile and an OSR compile parse to nothing.ci.yml: the three x86 rows ofbuildrundev/hsdis-build.shon every run, no cache, and setVFDLIBM_ASM_REQUIRED=true; the Arm row skips the check.SKILLS.md, "The assembly check": the rules, what was learned, and the census per arm, width and AVX level from the laptop;AGENTS.mdgets a Build-and-test entry.Nits left from review, not fixed:
dev/hsdis-build.sh --checkdisassembles a trivial int method, so it passes a Capstone 4 hsdis; the test then fails on its undecoded bytes, with a message naming Capstone.VFDLIBM_HSDIS_DIRpointed at a binutils hsdis runs the rules on a format they were not written for (unread lines would mostly report it).-XXoptions that stop C2 (TieredStopAtLevel=1) reach the probe too; the test then fails with "no standard C2 compile", naming the options.StrictMath.exp's inlined wrapper and a call intoFdLibm; they are not read, and only a failure prints their tail.Why are the changes needed?
Nothing read the instructions C2 emits: no FMA was a promise and the vector width was inferred from allocation.
The check found a real case on its first run: a loop calling
expCorethenexpRareon one vector callsexpRare(refused forNodeCountInliningCutoff) and boxes;ExpBenchmark's order,expRarefirst, inlines both.Ubuntu 24.04's Capstone 4.0.2, which
ubuntu-latesthas, printed exp's AVX-512 bodies with.byte 0x62and garbage including acall, which is why the script builds Capstone 5 and the check fails on undecoded bytes.Does this PR introduce any user-facing change?
No.
How was this patch tested?
mvn -B verifyon the laptop (AVX-512).mvn -q test -Dtest='ExpAsmTest,AsmCheckSelfTest'with-Dvfdlibm.test.jvmArgsempty,-XX:UseAVX=2 -XX:MaxVectorSize=32and-XX:MaxVectorSize=16: every arm passes at every width; no FMA in any arm.The skip paths by hand:
VFDLIBM_HSDIS_DIRat an empty directory (not found), at a file that is not a library (found but not loaded), and the latter withVFDLIBM_ASM_REQUIRED=true(fails).In an
ubuntu:24.04container:dev/hsdis-build.shbuilt Capstone 5.0.7 and hsdis, and the probe's counts matched the laptop's; hsdis on the system's Capstone 4.0.2 gave 19 to 43 undecoded lines per arm, which the new rule reports.The branch passed seven
code-reviewrounds at high; the last commit before the rebase (no hsdis cache, comment lines before the first instruction, a doc fix) and the rebase onto main were not reviewed before this pull request was opened.No timing claim: the census is instruction counts on the laptop, not a headline.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5.5)