Repository navigation
feat: harden SSA/CFG structuring, DEX SSA web splitting, and R8 recovery (v0.9.0) - #35
Merged
Merged
Conversation
…, and R8 recovery - classparser/decompiler/core: - Fix JVMS 4.10.1.2 reference-array LUB convergence in joinRefClass (frametransfer/frame.go) - Support compatible exception-handler local phi spill types (ssalower/plan.go) - Add reaching-phi convergent store slot splitting and live-across-branch single-use store guards (dataflow.go, code_analyser.go) - Resolve IsThisAlias super.m() invocations cleanly (values/java_value.go, values/expression.go) - Preserve explicit super() anchor when deferred irreducible constructor CFG exists (code_analyser.go) - classparser/decompiler/utils & rewriter: - Upgrade DominateIndex ancestor queries to O(1) Euler-tour intervals (utils/util.go) - Enable post-super() constructor irreducible dispatch via postDelegationConstructorAnchor (rewriter/irreducible_dispatch.go) - Extend NormalizeLoopForms with const-prefix and inverted guard normalization (rewriter/loop_form_normalize.go) - dex2jar & internal/dexparser: - Map read-only incoming DEX parameters (including `this`) directly to JVM parameter slots (lower/method.go) - Add PolyZeroAllocation / demandState constraint solver and companion-slot lowering for zero constants shared across Int/Float/Reference (ir/*, lower/method.go) - Emit JVM IINC for add-int/lit16 and lit8, enable float[] (FASTORE) in filled-new-array, preserve F/J/D LVT debug entries, and accept hiddenapi_class_data (0xf000) in DEX parser - Refresh pinned JAR hashes and improved decompile baselines in dex2jar/testdata/accept/manifest.json - R8 / Android --best-effort recovery & cross-platform contracts: - Propagate RetainUnprovedSource (--best-effort / --retain-unproved) end-to-end across cmd/javajive, javajive.go, classparser/jarwar, dumper.go, static_owner.go, and static_import.go - Keep strict mode unchanged while retaining bytecode-named static targets (including R8 inherited static calls and static-import collisions), non-javac enums, and enclosing-scope fallbacks under analysis/recover mode - Normalize LF attributes (.gitattributes) and add Windows NTFS junction fallback in t23_path_test.go so requiredci runs cleanly on Windows & Linux - Add pure-Go adversarial regression suites covering all fixed SSA, CFG, DEX, and R8 cases and update tools/requiredci/main.go inventory
…t forward regions, and constructor prefix folding
…nd body before hoisting const prefix
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.
Summary
This PR resolves P0 and P1 algorithmic bottlenecks across SSA type lattice merging, core dataflow, multi-exit CFG/constructor/loop structuring, DEX→JAR SSA web splitting & lowering, and R8/Android
--best-effortrecovery, backed by pure-Go adversarial regression suites and real-world Android corpus benchmarks.Phase 1 (P0): SSA Type Lattice, Dominance, Polymorphic-Zero DEX Lowering & Best-Effort Recovery
SSA Type Lattice & Core Dataflow (
classparser/decompiler/core)frametransfer/frame.go: Fixed JVMS §4.10.1.2joinRefClassarray LUB convergence across multi-dimensional arrays and array interfaces (Cloneable,Serializable,Object[],Object).ssalower/plan.go: AddedcompatibleExceptionSpillTypefor exception-handler local phi lattice compatibility.dataflow.go&code_analyser.go: AddedreachingPhiConvergentSameOrSuperStore,singleUseStoreReachesOtherLoad, andsuper()anchor preservation for deferred irreducible constructor CFG (JDEC_CTOR_POST_SUPER_DISPATCH_OFF).values/java_value.go&values/expression.go: ResolvedIsThisAliasso parentinvokespecialcalls render assuper.m(...).CFG, Dominance & Loop/Constructor Structuring (
classparser/decompiler/utils,rewriter)utils/util.go: Replaced chain traversal inDominateIndexwith O(1) Euler-tour entry/exit interval checks.rewriter/irreducible_dispatch.go: AddedpostDelegationConstructorAnchorfor post-super(...)irreducible dispatch.rewriter/loop_form_normalize.go: ExtendedNormalizeLoopForms(doWhileWithConstPrefixAsWhile,isSimpleLoopUpdate,extractDoWhileGuard, gated byJDEC_LOOP_NORM_EXT_OFF).DEX IR & JVM Lowering (
dex2jar,internal/dexparser)const/4 0Solver: Eliminates redundant prologue copies and materializes polymorphic0acrossInt/Float/Reference.iincemission foradd-int/lit16andlit8,float[](FASTORE) infilled-new-array,F/J/Ddebug LVT entries, andhiddenapi_class_data(0xf000) parsing.End-to-End R8 / Android
--best-effortRecovery (cmd/javajive,javajive.go,classparser)RetainUnprovedSourcecleanly without relaxing strictPrecisionmode invariants.Phase 2 (P1 — Next Level): SSA Def-Use Web Splitting, Nested Multi-Exit Forward Regions & Constructor/R8 Edge Recovery
DEX SSA Def-Use Live-Range Web Splitting & Pre-
super()Direct Deferred Stores (dex2jar/lower/webs.go,dex2jar/lower/method.go)assignWebs: Forward reaching-definitions dataflow worklist over DEX CFG blocks (handling entry-blockb == 0loop back-edges and protected-instruction exception handler edges) + Union-Find Def-Use web clustering. Splits overloaded DalvikvNregisters into disjoint JVM local slots, directly uses incoming parameter slots even when overwritten later in another web, deduplicates LVT entries per(slot, start, end), and guards giant methods (Instructions * defs > 100000) to stay well undert25sparse dataflow budgets (JDEC_DEX_WEBSPLIT_OFF).canDirectDeferredStore: Elides temporary synthetic locals on pre-super()field stores when receiver/value registers remain unmodified before delegation (JDEC_DEX_DIRECT_DEFERRED_OFF).classparser/decompiler/core/values/java_value.go: Added nil/typed-nil*JavaRefsafety guards in(*JavaRef).String,(*SlotValue).Type, and(*SlotValue).String.arithmetic.dexdeterministic quality baseline & maximum index2jar/testdata/accept/manifest.json(lines: 45 -> 38,tokens: 94 -> 79,synthetic_vars: 28 -> 14).Nested Multi-Exit Acyclic Forward Region Structuring (
classparser/decompiler/rewriter/)statementWrap.forwardRegionsfrommap[*core.Node]*forwardRegionto ordered[]*forwardRegionstacks acrossforward_region.go,try_rewriter.go,try_if_collection_boundary.go,protected_commit_exit.go, andprotected_normal_exits.go.findCommonForwardJoin(non-mutating viarollbackPending), iterativematerializeForwardRegionExits,closedForwardRegionWithSiblingExits(linearizing parallel sibling joins like MaterialBottomSheetBehavior/AppBarLayout$BaseBehavior), and sequential innermost-to-outermostfinishForwardRegionwrapping (JDEC_NESTED_FORWARD_REGION_OFF).Constructor Prefix Algebraic Folding &
RetainUnprovedSourceBoundary Recovery (classparser/constructor_retain_prefix.go,constructor_source_boundary.go,dumper.go)RetainUnprovedSource(--best-effort), folds pre-delegation Kotlin default-parameter bitmaskifbranches intoTernaryExpression, resolves pre-superparameter mutations viatryFoldEscapingParamIntoDelegate, omits redundantsuper(), or preserves effect-safe prefix statements before/after delegation or via single-arg carrier helper (JDEC_CTOR_RETAIN_PREFIX_OFF). Strictly rejected whenRetainUnprovedSource == false.Checked-Exception Escape Decoupling & R8 Exception Sentinel Recovery (
classparser/checked_escape.go,leaked_exception_sentinel.go)checkedEscapeInheritedNamesunderRetainUnprovedSourceto collect known ancestor names across incomplete external Android/SDK hierarchies.rewriteLeakedSuppressedCloseandstripDeadExceptionSentinelLocalsto reconstruct R8's<Type> varX = Exception; primary.addSuppressed(varX); res.close();try-with-resources close pattern.Pure-Go Adversarial Tests
classparser/decompiler/rewriter/forward_region_nested_test.godex2jar/adversarial_p1_websplit_test.goclassparser/adversarial_p1_next_level_test.gotools/requiredci/main.go.Review Fix: Fail-Closed Loop Constant-Prefix Hoisting Proof (
loop_form_normalize.go)doWhileWithConstPrefixAsWhile(classparser/decompiler/rewriter/loop_form_normalize.go): previously it did not inspect the loop condition for writes (x++ < 1 && i++ < 2) and missed++/--/compound/embedded writes in the body or opaque/aliased statements.varAssignedInStatementswithstatementsMayWriteOrOpaqueLocal+valueMayWriteOrOpaqueLocal+localConflictsInStatements(via shared fail-closedstatementTreeCheckFailClosedover allStatementkinds andvalues.InspectAccess/values.InspectValue), proving bothguard.Condition, normalizedcond,body,remaining, andprevAssign(gated onmakeForLoop != nil) are free of writes, opaque leaves, and scope/spelling collisions before hoisting.evalLoopIntStatements+TestNormalizeLoopFormsConstPrefixBehavioralEquivalenceAndWriteGuardsinclassparser/decompiler/rewriter/loop_form_normalize_test.go(9 subtests proving iteration-count / result preservation).TestAdversarialLoopConstPrefixRejectsCondAndBodyMutationBytecodeinclassparser/adversarial_p0_roundtrip_test.go(pure Go, included inrequiredci -run corpus).TestAdversarialLoopConstPrefixPerIterationResetRoundTripinclassparser/adversarial_loop_const_prefix_roundtrip_test.go.Empirical Benchmark Results (
./cmd/javajive)arithmetic.dex(strict accept)varNvarN)bundletool-app.apkvarN/supercallsuper.onCreate(var1)androguard-tc-debug.apkvarNbundletool-install-time.aab(1,298 classes,--best-effort)bundletool-install-time.aabbundletool-install-time.aabvarNrequiredci -run dexVerification
go vet ./...CGO_ENABLED=0 go build ./...&CGO_ENABLED=0 go build -tags javajive_full_jdk ./...go run ./tools/requiredci -checkgo run ./tools/requiredci -run contractgo run ./tools/requiredci -run corpusgo run ./tools/requiredci -run algorithm(with-race)go run ./tools/requiredci -run dex(with-race+ coverage threshold)JAVAJIVE_EXTERNAL_EVAL=1 go test -v -count=1 ./test/external