@@ -650,36 +650,20 @@ public static MyLogger dumpStatistics(JumpSolver checker, Set<Statement> soundly
650650
651651 log .info ("### Calculating statistics ###" );
652652
653- Set <Statement > unreachableJumpNodes = checker .getUnreachableJumps ();
653+ Set <Statement > unreachableJumpNodes = checker .getUnreachableJumps (); // LN: BOTTOM
654654
655- int resolvedJumps = 0 ;
656- int definitelyUnreachable = 0 ;
657- int maybeUnreachable = 0 ;
658- int unsoundJumps = 0 ;
659- int maybeUnsoundJumps = 0 ; // checker.getMaybeUnsoundJumps().size();
660-
661- boolean allJumpAreSound = true ;
655+ int resolved = 0 ; // LN: RESOLVED
656+ int unreachable = 0 ; // LN: UNREACHABLE
657+ int bottom = unreachableJumpNodes .size (); // LN: BOTTOM
658+ int conservative = 0 ; // LN: CONSERVATIVE
659+ final int maybeUnsoundJumps = 0 ; // checker.getMaybeUnsoundJumps().size();
662660
663661 if (cfg .getEntrypoints ().stream ().findAny ().isEmpty ()) {
664662 log .warn ("There are no entrypoints." );
665663 return null ;
666664 }
667665
668666 Statement entryPoint = cfg .getEntrypoints ().stream ().findAny ().get ();
669- Set <Statement > pushedJumps = cfg .getAllPushedJumps ();
670-
671- if (!JumpSolver .getLinkUnsoundJumpsToAllJumpdest ())
672- for (Statement jumpNode : cfg .getAllJumps ()) {
673- if (pushedJumps .contains (jumpNode ))
674- continue ;
675-
676- Set <StackElement > topStackValuesPerJump = checker .getTopStackValuesPerJump (jumpNode );
677-
678- if (topStackValuesPerJump != null && topStackValuesPerJump .contains (StackElement .NUMERIC_TOP )) {
679- allJumpAreSound = false ;
680- break ;
681- }
682- }
683667
684668 // we are safe supposing that we have a single entry point
685669 for (Statement jumpNode : cfg .getAllJumps ()) {
@@ -696,65 +680,44 @@ public static MyLogger dumpStatistics(JumpSolver checker, Set<Statement> soundly
696680 }
697681
698682 Set <StackElement > topStackValuesPerJump = checker .getTopStackValuesPerJump (jumpNode );
699-
700- if (pushedJumps .contains (jumpNode )) {
701- resolvedJumps ++;
702- continue ;
703- }
704- if (reachableFrom && unreachableJumpNodes .contains (jumpNode )) {
705- definitelyUnreachable ++;
706- continue ;
707- }
708- if (!reachableFrom ) {
709- if (allJumpAreSound )
710- definitelyUnreachable ++;
683+
684+ if (cfg .getAllPushedJumps ().contains (jumpNode ))
685+ resolved ++;
686+ else if (checker .getMaybeUnsoundJumps ().contains (jumpNode ))
687+ conservative ++;
688+ else if (checker .getUnreachableJumps ().contains (jumpNode ) || !reachableFrom || topStackValuesPerJump .isEmpty ())
689+ unreachable ++;
690+ else {
691+ boolean allBot = true , oneTop = false ;
692+ for (StackElement e : topStackValuesPerJump ) {
693+ allBot &= e .isBottom ();
694+ oneTop |= e .isTop ();
695+ }
696+
697+ if (allBot )
698+ bottom ++;
699+ else if (oneTop )
700+ conservative ++;
711701 else
712- maybeUnreachable ++;
713- continue ;
714- }
715- if (topStackValuesPerJump == null ) {
716- // If all stacks are bottom, then we have a
717- // maybeFakeMissedJump
718- definitelyUnreachable ++;
719- continue ;
702+ resolved ++;
720703 }
721- if (!topStackValuesPerJump .contains (StackElement .NUMERIC_TOP )) {
722- // If the elements at the top of the stacks are all
723- // different from NUMERIC_TOP, then we are sure that it
724- // is definitelyFakeMissedJumps
725- resolvedJumps ++;
726- continue ;
727- }
728- if (soundlySolved != null && !soundlySolved .contains (jumpNode )) {
729- unsoundJumps ++;
730- log .error ("{} not solved" , jumpNode );
731- log .error ("getTopStackValuesPerJump: {}" , topStackValuesPerJump );
732- continue ;
733- }
734- if (checker .getMaybeUnsoundJumps ().contains (jumpNode )) {
735- maybeUnsoundJumps ++;
736- continue ;
737- }
738-
739- resolvedJumps ++;
740704 }
741705 }
742706
743707 log .info ("Total opcodes: {}" , cfg .getOpcodeCount ());
744708 log .info ("Total jumps: {}" , cfg .getAllJumps ().size ());
745- log .info ("Resolved jumps: {}" , resolvedJumps );
746- log .info ("Definitely unreachable jumps: {}" , definitelyUnreachable );
747- log .info ("Maybe unreachable jumps: {}" , maybeUnreachable );
748- log .info ("Unsound jumps: {}" , unsoundJumps );
749- log .info ("Maybe unsound jumps: {}" , maybeUnsoundJumps );
709+ log .info ("Resolved jumps: {}" , resolved );
710+ log .info ("Unreachable jumps: {}" , unreachable );
711+ log .info ("Bottom jumps: {}" , bottom );
712+ log .info ("Conservative jumps: {}" , conservative );
750713
751714 return MyLogger .newLogger ()
752715 .opcodes (cfg .getOpcodeCount ())
753716 .jumps (cfg .getAllJumps ().size ())
754- .preciselyResolvedJumps (resolvedJumps )
755- .definitelyUnreachableJumps (definitelyUnreachable )
756- .maybeUnreachableJumps (maybeUnreachable )
757- .unsoundJumps (unsoundJumps )
717+ .preciselyResolvedJumps (resolved )
718+ .definitelyUnreachableJumps (unreachable )
719+ .maybeUnreachableJumps (bottom )
720+ .unsoundJumps (conservative )
758721 .maybeUnsoundJumps (maybeUnsoundJumps );
759722 }
760723
0 commit comments