Topic
  • 2 replies
  • Latest Post - ‏2013-10-16T18:49:36Z by markboyd
markboyd
markboyd
7 Posts

Pinned topic How does RAA define or calculate dead code?

‏2013-10-16T01:51:00Z |

How does RAA define dead code, or how is code determined to be "dead."  How is the actual "calculation" done?

Thank you.

  • jcdelmo
    jcdelmo
    348 Posts
    ACCEPTED ANSWER

    Re: How does RAA define or calculate dead code?

    ‏2013-10-16T15:13:45Z  

    RAA defines dead code as statements that are 'unreachable' from any entry point.   It does not determine 'unreferenced data'.

    The process starts by assuming all statements are unreachable.  Than a graph is built of all the statements in a COBOL program's procedure division.   Each entry point and CICS HANDLE ABEND is queued up as a starting point.   Control flow graph is walked from these entry statements until a termination statement is reached, stacking PERFORM to be resolved.  As each statement is reached, it is marked.

    There are optimizations for reaching the same sub-graph multiple times, for simple IF...END-IF ranges and for structural issues (like PERFORM range violations)

    Once all Entry Point to termination statement graphs are walked, the statements not marked are consider unreachable (dead).

    There are some known issues (for example, accommodating non-returning control transfers) -- but in general that is how it is done.

    This process is invoked when Code Review is run,  Control Flow Graph is requested or view dead code action is selected.  The results are persisted to optimize for the 2nd...nth time it is requested.

    Does that help, or do you need more detail?

  • jcdelmo
    jcdelmo
    348 Posts

    Re: How does RAA define or calculate dead code?

    ‏2013-10-16T15:13:45Z  

    RAA defines dead code as statements that are 'unreachable' from any entry point.   It does not determine 'unreferenced data'.

    The process starts by assuming all statements are unreachable.  Than a graph is built of all the statements in a COBOL program's procedure division.   Each entry point and CICS HANDLE ABEND is queued up as a starting point.   Control flow graph is walked from these entry statements until a termination statement is reached, stacking PERFORM to be resolved.  As each statement is reached, it is marked.

    There are optimizations for reaching the same sub-graph multiple times, for simple IF...END-IF ranges and for structural issues (like PERFORM range violations)

    Once all Entry Point to termination statement graphs are walked, the statements not marked are consider unreachable (dead).

    There are some known issues (for example, accommodating non-returning control transfers) -- but in general that is how it is done.

    This process is invoked when Code Review is run,  Control Flow Graph is requested or view dead code action is selected.  The results are persisted to optimize for the 2nd...nth time it is requested.

    Does that help, or do you need more detail?

  • markboyd
    markboyd
    7 Posts

    Re: How does RAA define or calculate dead code?

    ‏2013-10-16T18:49:36Z  
    • jcdelmo
    • ‏2013-10-16T15:13:45Z

    RAA defines dead code as statements that are 'unreachable' from any entry point.   It does not determine 'unreferenced data'.

    The process starts by assuming all statements are unreachable.  Than a graph is built of all the statements in a COBOL program's procedure division.   Each entry point and CICS HANDLE ABEND is queued up as a starting point.   Control flow graph is walked from these entry statements until a termination statement is reached, stacking PERFORM to be resolved.  As each statement is reached, it is marked.

    There are optimizations for reaching the same sub-graph multiple times, for simple IF...END-IF ranges and for structural issues (like PERFORM range violations)

    Once all Entry Point to termination statement graphs are walked, the statements not marked are consider unreachable (dead).

    There are some known issues (for example, accommodating non-returning control transfers) -- but in general that is how it is done.

    This process is invoked when Code Review is run,  Control Flow Graph is requested or view dead code action is selected.  The results are persisted to optimize for the 2nd...nth time it is requested.

    Does that help, or do you need more detail?

    That's exactly what I needed. THANKS John!