% -*- mode: latex; auto-revert-interval: 0.5 -*- \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto, node distance=4em, very thin,font={\scriptsize\bf}] % =================== % global declarations % =================== \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground} \tikzstyle{basic-block} = [draw=black!50, fill=white, rectangle, minimum width=12.5em] \ifthenelse{\boolean{preview}} {\tikzstyle{block} = [basic-block]} {\tikzstyle{block} = [basic-block, drop shadow]} \tikzstyle{enter} = [block, ellipse, fill=red!20] \tikzstyle{guard} = [block, fill=yellow!20] \tikzstyle{newguard} = [block, fill=green!20] \tikzstyle{lbl} = [font={\scriptsize\it}, minimum width=0em] \provideboolean{loop-virtuals-step1} \provideboolean{loop-virtuals-step2} \provideboolean{loop-virtuals-step3} %\setboolean{loop-virtuals-step1}{true} \ifthenelse{\boolean{loop-virtuals-step1} \or \boolean{loop-virtuals-step2}} { \clip (-3.9, 1.7) rectangle (2.7,-7.6); } {} \ifthenelse{\boolean{loop-virtuals-step3}} { \clip (-2.7, 0.5) rectangle (10.4,-7.4); } {} % ========================================= % unoptimized trace (only in step 1) % ========================================= \ifthenelse{\boolean{loop-virtuals-step1}} { \node[enter, name=start] {loop($obj_0$)} ; \node[guard, name=block1, below of=start] { \begin{tabular}{c} guard\_class($obj_0$, \texttt{W\_Int}) \\ $val_0$ = getfield\_gc($obj_0$, \texttt{val}) \\ $nextval_0$ = int\_sub($val_0$, $1$) \\ \end{tabular} }; \node[guard, name=block2, below of=block1, node distance=4em] { \begin{tabular}{c} $obj_1$ = new\_with\_vtable(\texttt{W\_Int}) \\ setfield\_gc($obj_1$, $nextval_0$, \texttt{val}) \\ \end{tabular} }; \node[guard, name=block3, below of=block2, node distance=5em] { \begin{tabular}{c} guard\_class($obj_1$, \texttt{W\_Int}) \\ $val_1$ = getfield\_gc($obj_1$, \texttt{val}) \\ $t_0$ = int\_gt($val_1$, 0) \\ guard\_true($t_0$) \\ jump($obj_1$) \end{tabular} }; \path (start.south) edge (block1.north) ; \path (block1.south) edge (block2.north) ; \path (block2.south) edge (block3.north) ; \path (block3.south) edge[out distance=19em, in distance=19em, out=230, in=130] (start.north) ; } {} % end if % ========================================= % entry bridge (only in step 3) % ========================================= \ifthenelse{\boolean{loop-virtuals-step3}} { \node[enter, name=start, fill=blue!20] {entry\_bridge($obj_0$)} ; \node[guard, name=block1, below of=start] { \begin{tabular}{c} guard\_class($obj_0$, \texttt{W\_Int}) \\ $val_0$ = getfield\_gc($obj_0$, \texttt{val}) \\ $nextval_0$ = int\_sub($val_0$, $1$) \\ \end{tabular} }; \node[guard, name=block2, below=2em of block1] { \begin{tabular}{c} $t_0$ = int\_gt($nextval_0$, 0) \\ guard\_true($t_0$) \\ \end{tabular} }; \node[guard, name=block3, below=2em of block2] { \begin{tabular}{c} jump($nextval_0$) \end{tabular} }; \path (start.south) edge (block1.north) ; \path (block1.south) edge (block2.north) ; \path (block2.south) edge (block3.north) ; } {} % end if % ========================================= % optimized trace (only in steps 2 and 3) % ========================================= \ifthenelse{\boolean{loop-virtuals-step2}} { \node[enter, name=start_opt] {loop($obj\_val_0$)} ; } {} \ifthenelse{\boolean{loop-virtuals-step3}} { % in step 3, we want the loop to start below the entry bridge \node[enter, name=start_opt, below right=4em and 7em of start] {loop($obj\_val_0$)} ; } \ifthenelse{\boolean{loop-virtuals-step2} \or \boolean{loop-virtuals-step3}} { \node[guard, name=block_opt1, below of=start_opt] { \begin{tabular}{c} $obj\_val_1$ = int\_sub($obj\_val_0$, $1$) \\ \end{tabular} }; \node[guard, name=block_opt2, below of=block_opt1, node distance=4em] { \begin{tabular}{c} $t_1$ = int\_gt($obj\_val_1$, 0) \\ guard\_true($t_1$) \\ jump($obj\_val_1$) \end{tabular} }; \path (start_opt.south) edge (block_opt1.north) ; \path (block_opt1.south) edge (block_opt2.north) ; } {} \ifthenelse{\boolean{loop-virtuals-step2}} { \path (block_opt2.south) edge[out distance=17em, in distance=17em, out=230, in=130] (start_opt.north) ; } {} \ifthenelse{\boolean{loop-virtuals-step3}} { \path (block_opt2.south) edge[out distance=17em, in distance=17em, out=310, in=50] (start_opt.north) ; } {} % ========================================= % step 3: entry bridge --> optimized loop % ========================================= \ifthenelse{\boolean{loop-virtuals-step3}} { \path (block3.south) edge[out distance=19em, in distance=19em, out=320, in=130] (start_opt.north); } {} \end{tikzpicture}