This commit is contained in:
Josep Silva 2019-12-09 13:08:53 +00:00
parent 7067525f98
commit 1eb9175286
1 changed files with 7 additions and 6 deletions

View File

@ -191,13 +191,13 @@ This problem cannot be easily solved, as it is a ``dynamic'' one, requiring info
\section{The \texttt{try-catch} statement}
In this section we present an example where the current \deleted{approximation for the}\added{approach used to handle} \texttt{try-catch} statement fails to capture all the correct dependencies \deleted{and excludes}\added{, excluding} from the slice some statements \deleted{which}\added{that} are necessary for a complete slice (both weak and strong). After that, we generalize the set of cases where \deleted{that}\added{the lack of accuracy}\sergio{creo que aqui con ``that" te referias a la precision no?} is a problem and its possible appearances in real-life development. Finally, we propose a solution which properly represent all the dependencies introduced by the \texttt{try-catch}, focusing on producing complete strong slices.
In this section we present an example where the current \deleted{approximation for the}\added{approach used to handle} \texttt{try-catch} statement\josep{s} fails to capture all the correct dependencies \deleted{and excludes}\added{, excluding} from the slice some statements \deleted{which}\added{that} are necessary for a complete slice (both weak and strong). After that, we generalize the set of cases where \deleted{that}\added{the lack of accuracy}\sergio{creo que aqui con ``that" te referias a la precision no?} is a problem and its possible appearances in real-life development. Finally, we propose a solution which\josep{that} properly represent\josep{s} all the dependencies introduced by the \texttt{try-catch}, focusing on producing complete strong slices.
\subsubsection*{The types of control dependence}
\carlos{this subsection snippet could go in another place}
Even though it continues to be used for control dependence, definition~\ref{def:ctrl-dep} does not have the same meaning when applied to conditional instructions and loops as it has when applied to unconditional jumps and other complex structures, such as the \texttt{switch} and \texttt{try-catch} statements.
Even though it continues to be used for control dependence, definition~\ref{def:ctrl-dep} does not have the same meaning when applied to conditional instructions\josep{en todo el documento se debería hablar de statements en lugar de instructions, porque instructions tiene connotación del paradigma imperartivo, mientras que statements engloba el imperartivo y el declarativo} and loops as it has when applied to unconditional jumps and other complex structures, such as the \texttt{switch} and \texttt{try-catch} statements.
Originally, the definition of control dependence signified that the execution of a statement affected whether or not another one executed (or kept executing)\sergio{$\leftarrow$ no se entiende esta frase. Creo que el whether sobra y el parentesis no lo entiendo}. In contrast, unconditional jumps, and \texttt{try-catch} statements' execution do not affect the following instructions; its presence or absence is what generates the control dependency. For those instructions, control dependencies are still generated with the same edges, but require the addition of extra edges to the CFG \cite{BalH93,AllH03}\sergio{estos son los psedo-predicate edges? Si son los falsos podemos referenciarlos dentro de la tesis, no hara falta irse a los articulos, sino parece que sean unos nuevos edges que no existian hasta le momento}.
@ -207,11 +207,11 @@ In the current approximation\sergio{approach?} for exception handling \cite{AllH
The only occasion in which \texttt{catch} blocks generate any kind of control dependency is when there is an exception thrown that is not covered by any of the \texttt{catch} blocks, and the function may exit with an exception. In that case, the instructions after the \texttt{try-catch} block are dependent on an uncaught exception not being thrown.\sergio{aqui hay arcos a todos los catch? Si es asi acabar la frase diciendo que se considera esa instruccion dependiente de todos los catch o algo asi para que quede mas claro.}
But, compared to the treatment of unconditional \added{jumps?,} exceptions does not match\sergio{quien does not match?} the treatment of \texttt{try-catch} statement: unconditional jumps have a non-executable edge to the instruction that would be executed in their absence; \texttt{catch} statements do not.
But, compared to the treatment of unconditional \added{jumps?,} exceptions does\josep{do} not match\sergio{quien does not match?} the treatment of \josep{a} \texttt{try-catch} statement: unconditional jumps have a non-executable edge to the instruction that would be executed in their absence; \texttt{catch} statements do not. \josep{Estos tres parrafos estan escritosa con mucha prisa y no se entienden bien}
\begin{example}[\texttt{catch} statements' outgoing dependencies]
\label{exa:catch-no-dep}
Consider the code shown in figure~\ref{fig:catch-no-dep-code}, which depicts a \texttt{try-catch} where method \texttt{f}, which may throw an exception, is called. The function may throw either a \texttt{ExceptionA}, \texttt{ExceptionB} or \texttt{Exception}-typed exception; and the \texttt{try-catch} considers all three cases, logging the type of exception caught. Additionally, \texttt{f} accesses and modifies a global variable \texttt{x}.
Consider the code shown in figure~\ref{fig:catch-no-dep-code}, which depicts a \texttt{try-catch} where method \texttt{f}, which may throw an exception, is called. The function may throw either a \texttt{ExceptionA}, \texttt{ExceptionB} or \texttt{Exception}-typed exception; and the \texttt{try-catch} considers all three cases, logging the type of exception caught. Additionally, \texttt{f} accesses and modifies a global variable \texttt{x}. \josep{en el codigo no aparece la x. Seria más claro si apareciera}
\begin{figure}[h]
\begin{lstlisting}
@ -263,11 +263,11 @@ void f() throws Exception {
}
\end{lstlisting}
\end{minipage}
\caption{A method that may throw exceptions (\texttt{f}), called twice, once surrounded by a \texttt{try-catch} statement, and another time after it. On the right, the definition of \texttt{f}.}
\caption{A method \josep{\texttt{f}} that may throw exceptions\josep{\deleted{ (\texttt{f})}}, called twice, once surrounded by a \texttt{try-catch} statement, and another time after it. On the right, the definition of \texttt{f}.}
\label{fig:incorrect-try-catch-code}
\end{figure}
Figure~\ref{fig:incorrect-try-catch-graph} displays the program dependence graph for the snippet of code on the left side of figure~\ref{fig:incorrect-try-catch-code}. Data dependencies are shown in red, and summary edges\sergio{esto ya tiene una definicion clara en la seccion del SDG??} in blue. The set of nodes filled in grey represent the slice with respect to \deleted{a}\added{the} slicing criterion \added{$\langle 4, x \rangle$} in method \texttt{f} \deleted{(line 4, \texttt{x})}\sergio{plantearse si poner los SC asi o dejarlo como (line X, variable Y)}. In the slice, both calls to \texttt{f} and its input (\texttt{x\_in = x}) are included, but the \texttt{catch} block is not present. The execution of the slice may not be the same: if no exception is thrown, there is no change; but if \texttt{x} was odd before entering the snippet, an exception \deleted{will}\added{would} be thrown and not caught, exiting the program prematurely.
Figure~\ref{fig:incorrect-try-catch-graph} displays the program dependence graph for the snippet of code on the left side of figure~\ref{fig:incorrect-try-catch-code}. \josep{por que no se incluye el PDG de la parte derecha?}Data dependencies are shown in red, and summary edges\sergio{esto ya tiene una definicion clara en la seccion del SDG??} in blue. The set of nodes filled in grey represent the slice with respect to \deleted{a}\added{the} slicing criterion \added{$\langle 4, x \rangle$} \josep{no usar la misma numeracion en los dos fragmentos de codigo} in method \texttt{f} \deleted{(line 4, \texttt{x})}\sergio{plantearse si poner los SC asi o dejarlo como (line X, variable Y)}. In the slice, both calls to \texttt{f} and its input (\texttt{x\_in = x}) are included, but the \texttt{catch} block is not present. The execution of the slice may not be the same: if no exception is thrown, there is no change; but if \texttt{x} was odd before entering the snippet, an exception \deleted{will}\added{would} be thrown and not caught, exiting the program prematurely.
\begin{figure}[h]
\centering
@ -285,6 +285,7 @@ void f() throws Exception {
Unfortunately, this creates the same behaviour as with unconditional jumps: all the instructions that follow a \texttt{try-catch} structure is dependent on the presence of the \texttt{catch} statements, which in turn are dependent on all the statements that may throw exceptions. In practice, the inclusion of any statement after a \texttt{try-catch} statement would require the slice to include all \texttt{catch} statements, the statements that may throw exceptions, and all the statements required by control or data dependencies. This is a huge number of instructions just for including the \texttt{catch} statements.
\josep{Los tres parrafos que siguen pretenden resumir todo el trabajo y las discusiones que hemos tenido en varias reuniones sobre como tratar el 1 y el 2 para que el catch sea completo y preciso. Evidentemente, en tres parrafos no se puede explicar, y se requiere de una buena explicacion, de un ejemplo, etc. Entiendo que es la falta de tiempo... }
\sergio{Lo que viene a continuacion suena a parche y es una contribucion muy tocha, de hecho es nuestra mejor baza.}Our solution makes slices complete again, but makes them much less correct. \deleted{As a solution for the incorrectness}\added{However, analysing the behaviour of the catch dependencies, we propose a new technique to improve the downgraded accuracy. This technique follow the same basis that the one proposed for unconditional jumps, and consists in the insertion of}\deleted{ we could insert} an additional requirement when including \texttt{catch} blocks: if they are included because of their control dependencies on instructions outside the \texttt{try-catch}, they need to satisfy an additional condition before being in the slice: have a node in the slice which may throw a compatible exception.
\sergio{Esto hay que pulirlo y anyadir un dibujo con los arcos 1 y 2 en verde. El verde no es importante, es solo una senya de identidad en el dibujo. Lo importante es la etiqueta $\rightarrow$ }