Changeset 3194


Ignore:
Timestamp:
Apr 28, 2013, 4:20:54 PM (4 years ago)
Author:
tranquil
Message:

more on the role of the stack in the back end pass.
moved mauro.tex as an include of paolo.tex

Location:
Deliverables/D4.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.4/mauro.tex

    r3127 r3194  
    1 \documentclass[11pt, epsf, a4wide]{article}
    2 
    3 \usepackage{../style/cerco}
    4 
    5 \usepackage{amsfonts}
    6 \usepackage{amsmath}
    7 \usepackage{amssymb}
    8 \usepackage[english]{babel}
    9 \usepackage{graphicx}
    10 \usepackage[utf8x]{inputenc}
    11 \usepackage{listings}
    12 \usepackage[all]{xy}
    13 
    14 \newcommand{\unif}{\ensuremath{\stackrel{\scriptscriptstyle ?}{\equiv}}}
    15 \newcommand{\founif}{\ensuremath{\stackrel{\scriptscriptstyle ?}{=}}}
    16 \newcommand{\vect}[1]{\ensuremath{\stackrel{\to}{#1}}}
    17 \newcommand{\sem}[1]{\ensuremath{[\![#1]\!]}}
    18 \newcommand{\bsem}[2]{\ensuremath{[\![#1;\;#2]\!]}}
    19 
    20 \renewcommand{\verb}{\lstinline}
    21 \def\lstlanguagefiles{lst-grafite.tex}
    22 \lstset{language=Grafite}
    23 
    24 \usepackage{lscape}
    25 \usepackage{stmaryrd}
    26 \usepackage{threeparttable}
    27 \usepackage{url}
    28 \title{
    29 INFORMATION AND COMMUNICATION TECHNOLOGIES\\
    30 (ICT)\\
    31 PROGRAMME\\
    32 \vspace*{1cm}Project FP7-ICT-2009-C-243881 \cerco{}}
    33 
    34 \lstdefinelanguage{matita-ocaml}
    35   {keywords={definition,coercion,lemma,theorem,remark,inductive,record,qed,let,in,rec,match,return,with,Type,try},
    36    morekeywords={[2]whd,normalize,elim,cases,destruct},
    37    morekeywords={[3]type,of},
    38    mathescape=true,
    39   }
    40 
    41 \lstset{language=matita-ocaml,basicstyle=\small\tt,columns=flexible,breaklines=false,
    42         keywordstyle=\color{red}\bfseries,
    43         keywordstyle=[2]\color{blue},
    44         keywordstyle=[3]\color{blue}\bfseries,
    45         commentstyle=\color{green},
    46         stringstyle=\color{blue},
    47         showspaces=false,showstringspaces=false}
    48 
    49 \lstset{extendedchars=false}
    50 \lstset{inputencoding=utf8x}
    51 \DeclareUnicodeCharacter{8797}{:=}
    52 \DeclareUnicodeCharacter{10746}{++}
    53 \DeclareUnicodeCharacter{9001}{\ensuremath{\langle}}
    54 \DeclareUnicodeCharacter{9002}{\ensuremath{\rangle}}
    55 
    56 \date{}
    57 \author{}
    58 
    59 \begin{document}
    60 
    61 \thispagestyle{empty}
    62 
    63 \vspace*{-1cm}
    64 \begin{center}
    65 \includegraphics[width=0.6\textwidth]{../style/cerco_logo.png}
    66 \end{center}
    67 
    68 \begin{minipage}{\textwidth}
    69 \maketitle
    70 \end{minipage}
    71 
    72 \vspace*{0.5cm}
    73 \begin{center}
    74 \begin{LARGE}
    75 \textbf{
    76 Report n. D4.4\\
    77 ??????????????
    78 }
    79 \end{LARGE}
    80 \end{center}
    81 
    82 \vspace*{2cm}
    83 \begin{center}
    84 \begin{large}
    85 Version 1.1
    86 \end{large}
    87 \end{center}
    88 
    89 \vspace*{0.5cm}
    90 \begin{center}
    91 \begin{large}
    92 Main Authors:\\
    93 ????????????
    94 \end{large}
    95 \end{center}
    96 
    97 \vspace*{\fill}
    98 
    99 \noindent
    100 Project Acronym: \cerco{}\\
    101 Project full title: Certified Complexity\\
    102 Proposal/Contract no.: FP7-ICT-2009-C-243881 \cerco{}\\
    103 
    104 \clearpage
    105 \pagestyle{myheadings}
    106 \markright{\cerco{}, FP7-ICT-2009-C-243881}
    107 
    108 \newpage
    109 
    110 \vspace*{7cm}
    111 \paragraph{Abstract}
    112 BLA BLA BLA
    113 \newpage
    114 
    115 \tableofcontents
    116 
    117 \newpage
    118 
    119 \section{A modular approach to the correctness of each Compiler's Backend Pass}
     1\section{A modular approach to the correctness of the graph passes}
    1202
    1213An instance of the record \verb=sem_graph_params= contains all common information about
     
    956838The module formalizing the formal machienary we described in this document consists of about 3000 lines of
    957839Matita code. We stress the fact that this machienary proves general properties that do not depend on the
    958 specific backend compiler pass. Without this layer one would have to prove these properties each specific
    959 pass multiplying the number of Matita's lines by $n$ where $n$ is the number of backend pass.
    960 
    961 
    962 
    963 
    964 
    965 
    966 \end{document}
     840specific backend graph compiler pass.
  • Deliverables/D4.4/paolo.tex

    r3180 r3194  
    3333\usepackage{caption,subcaption}
    3434\usepackage{url}
     35\usepackage{tikz}
     36\usetikzlibrary{positioning,calc,patterns}
    3537\title{
    3638INFORMATION AND COMMUNICATION TECHNOLOGIES\\
     
    169171to relate the states in the two languages.
    170172
    171 \subsection{A common invariant.} This block of traces with properties is recurrent enough to merit the
     173\subsection{A common invariant} This block of traces with properties is recurrent enough to merit the
    172174\s{matita} definition in \autoref{fig:ft_and_tlr}. We rely on the fact
    173175that all semantics from \s{RTLabs} down to object code can be expressed
     
    202204(cf.~\cite{?}).
    203205
    204 \subsection{The statement.}
     206\subsection{The statement}
    205207The back-end correctness theorem proves the \s{matita} statement in
    206208\autoref{fig:statement}. The output of the a proof is
     
    268270actually the initial state).
    269271
    270 \section{From an unbounded to a bounded stack}
     272\section{Dealing with the stack}
     273Setting apart the extensional details of the proofs, a delicate point is how
     274we deal with stack.
     275
     276A first minor issue is that the information we have about stack usage of
     277each function call evolves along the back-end passes:
     278\begin{itemize}
     279 \item in \s{RTL} we must allocate some stack for what where referenced
     280 local variables (including local arrays) in source code;
     281 \item in \s{ERTL} we add up the stack used to pass parameters that overflow
     282 the hardware registers available for the task;
     283 \item finally in \s{LTL} we add the space necessary for spilled
     284 pseudo-registers, and the stack usage of functions is finally fixed.
     285\end{itemize}
     286
     287Another issue that we already mentioned above is that somewhere during the
     288back-end pass we must pass from a semantics with no stack overflow error to
     289one that can fail.
     290
     291In the following we describe the approach we have taken to these issues.
     292
     293\subsection{An evolving stack usage}
     294\label{subsec:evolvingstack}
     295The stack size we know each function must at least have is written in
     296a field of \verb+joint+ internal functions (called \verb+joint_if_stacksize+),
     297and as already said
     298evolves during the back-end pass. The \emph{naïve} approach to defining
     299semantics of these languages is to allocate the minimal necessary space for
     300each function call, reading it from this syntactic field. The drawback is
     301that then at each update of the stack size we must remap the data pointers
     302in memory, moreover in a way that is dependent on the call stack. This is
     303exemplified by the picture in \autoref{subfig:stacktight}.
     304\begin{figure}
     305\begin{subfigure}{.475\linewidth}
     306\centering
     307$
     308\begin{tikzpicture}[thick, line cap=round,
     309    m/.style = {execute at begin node=$, execute at end node=$}]
     310\begin{scope}[every node/.style={draw, rectangle,
     311    minimum width=1.25cm, m}, every label/.style={minimum width=0, draw=none}]
     312    \node (main src) [minimum height=.5cm]
     313        [label=left:main] {};
     314    \node (f1 src) [above=-1pt of main src,minimum height=1cm]
     315        [label=left:f] {};
     316    \node (g src) [above=-1pt of f1 src,minimum height=.75cm]
     317        [label=left:g] {};
     318    \node (f2 src) [above=-1pt of g src,minimum height=1cm]
     319        [label=left:f] {};
     320
     321    \node (main tgt) at ([xshift=2cm]main src.south east) [anchor=south west,minimum height=1cm]
     322        [label=right:main] {};
     323    \node (f1 tgt) [above=-1pt of main tgt,minimum height=1.25cm]
     324        [label=right:f] {};
     325    \node (g tgt) [above=-1pt of f1 tgt,minimum height=1.5cm]
     326        [label=right:g] {};
     327    \node (f2 tgt) [above=-1pt of g tgt,minimum height=1.25cm]
     328        [label=right:f] {};
     329
     330\end{scope}
     331\foreach \x/\off in {main/.5, f1/1, g/.75, f2/1} {
     332    \draw [densely dashed, semithick]
     333        ([yshift=1pt]\x\space src.south east) --
     334        ([yshift=1pt]\x\space tgt.south west);
     335    \draw [densely dashed, semithick] (\x\space src.north east) --
     336        ([yshift=\off cm]\x\space tgt.south west) coordinate (tmp)
     337        -- (tmp-|\x\space tgt.east);
     338    \fill [pattern=dots, opacity=.5] (tmp) |- (\x\space tgt.north east) |- (tmp);
     339    \path (\x\space src.east) -- node [sloped] {$\hookrightarrow$}
     340        ($(\x\space tgt.south west)!.5!(tmp)$);
     341}
     342\node (heading tgt) [above=.125cm of f2 tgt] {target stack};
     343\node (heading src) at (heading tgt-|f2 src) {source stack};
     344
     345\draw [|->] (heading src) -- (heading tgt);
     346\end{tikzpicture}
     347$
     348\caption{How stack is remapped if we use tight stack spaces for each language.
     349Dotted areas are the new parts of the local stacks.}
     350\label{subfig:stacktight}
     351\end{subfigure}
     352\hfill
     353\begin{subfigure}{.475\linewidth}
     354\centering
     355$
     356\begin{tikzpicture}[thick, line cap=round,
     357    m/.style = {execute at begin node=$, execute at end node=$}]
     358\begin{scope}[every node/.style={draw, rectangle,
     359    minimum width=1.25cm, m}, every label/.style={minimum width=0, draw=none}]
     360    \node (main src) [minimum height=1.25cm]
     361        [label=left:main] {};
     362    \node (f1 src) [above=-1pt of main src,minimum height=1.75cm]
     363        [label=left:f] {};
     364    \node (g src) [above=-1pt of f1 src,minimum height=1.75cm]
     365        [label=left:g] {};
     366    \node (f2 src) [above=-1pt of g src,minimum height=1.75cm]
     367        [label=left:f] {};
     368
     369    \node (main tgt) at ([xshift=2cm]main src.south east) [anchor=south west,minimum height=1.25cm]
     370        [label=right:main] {};
     371    \node (f1 tgt) [above=-1pt of main tgt,minimum height=1.75cm]
     372        [label=right:f] {};
     373    \node (g tgt) [above=-1pt of f1 tgt,minimum height=1.75cm]
     374        [label=right:g] {};
     375    \node (f2 tgt) [above=-1pt of g tgt,minimum height=1.75cm]
     376        [label=right:f] {};
     377
     378\end{scope}
     379\foreach \x/\off/\o in {main/.5/1, f1/1/1.25, g/.75/1.5, f2/1/1.25} {
     380    \draw [densely dashed, semithick]
     381        ([yshift=1pt]\x\space src.south east) --
     382        ([yshift=1pt]\x\space tgt.south west);
     383    \draw [densely dashed, semithick]
     384        ([yshift=\off cm]\x\space src.south west) --
     385        ([yshift=\off cm]\x\space tgt.south west) coordinate (tmp)
     386        -- (tmp-|\x\space tgt.east);
     387    \fill [pattern=dots, opacity=.5] (tmp) --
     388        ([yshift=\o cm]\x\space tgt.south west) coordinate (tmp2) -| (tmp-|\x\space tgt.east) -- (tmp);
     389    \draw [densely dashed] (tmp2) -- (tmp2-|\x\space tgt.east);
     390    \fill [pattern=north east lines, opacity=.5]
     391        (tmp2) |- (\x\space tgt.north east) |- (tmp2);
     392    \path ($(\x\space src.south east)!.5!(\x\space src.east|-tmp)$) --
     393        node {$\hookrightarrow$}
     394        ($(\x\space tgt.south west)!.5!(tmp)$);
     395    \fill [pattern=north east lines, opacity=.5]
     396        (\x\space src.west|-tmp) coordinate (tmp) |- (\x\space src.north east) |- (tmp);
     397}
     398\node (heading tgt) [above=.125cm of f2 tgt] {target stack};
     399\node (heading src) at (heading tgt-|f2 src) {source stack};
     400
     401\draw [|->] (heading src) -- (heading tgt);
     402\end{tikzpicture}
     403$
     404\caption{Constant stack usage taken as a semantic parameter across languages.
     405Shaded areas are unused parts of the stack.}
     406\label{subfig:stacksame}
     407\end{subfigure}
     408\caption{Comparison between using tight stack sizes across langauges, i.e.\
     409reading how much stack is required from the function, and using the same
     410stack sizes provided as a parameter to the semantics. We suppose the call stack
     411is $main, f, g, f$.}
     412\label{fig:stacktightsame}
     413\end{figure}
     414
     415We decided to take another approach, where stack sizes of each function call
     416are a parameter to the semantics, and all passes are proved correct for the
     417same stack sizes in source and target language, possibly with a hypothesis
     418on these ``semantic'' stack sizes to be greater than the ``syntactic'' ones
     419(but not all passes require it). The picture becomes thus the one in
     420\autoref{subfig:stacksame}. The advantage is that now the data in memory does
     421not change along the evolving of stack usage, apart from the first time we
     422pass from separate independent stack spaces and a unique one, a situation
     423we describe in the next subsection.
     424
     425\subsection{From an unbounded to a bounded stack}
    271426The way the \verb+ft_and_tlr+ is propagated is almost everwhere by means of
    272427the proof of existence of a special relation between states that is a simulation
     
    279434is delicate for two reasons. Firstly, while usually we can assure forward simulation
    280435of an execution step by simply depending on that step not producing an error,
    281 here is no more the case, as the stack overflow must start happening somewhere in
     436here is no more the case, as the stack overflow error must start happening somewhere in
    282437the back-end. Secondly, merging the stack spaces of the function calls requires
    283438mapping the pointer values contained in memory.
     
    289444
    290445The first one, called \verb+RTL_semantics_separate+, mimics how stack is modelled
    291 in \s{RTLabs}: each function gets allocated upon call an independent stack space.
     446in \s{RTLabs}: each function call gets allocated an independent stack space.
    292447Passing from \s{RTLabs} to this semantics involves the usual simulation relation.
    293 A peculiarity is that data pointers need not change.
    294 
    295 The middle, second one, is very similar to the two above. Called
    296 \verb+RTL_semantics_separate_overflow+, it has separate allocated stack spaces
    297 just as \verb+RTL_semantics_separate+. However the execution is defined
     448A peculiarity is that data pointers in memory need not change.
     449
     450The middle, second one, is called
     451\verb+RTL_semantics_separate_overflow+, and it has separate allocated stack spaces
     452just as above. However the execution is defined
    298453so that if the call stack as a whole uses more space than (later) physically
    299 available, an error is issued. The actual states are identical,
     454available (as provided by a parameter), an error is issued. The actual states are identical,
    300455and the simulation is an almost trivial 1-to-1, where the stack correctness
    301456inherited from \verb+back_end_preconditions+ can be easily put to use even
     
    306461a single, bounded stack space, where moreover memory has already been granted to
    307462globals too. From this semantics down to \s{LIN}, all data in memory excluding
    308 pieces of program counters remain the same. However in order to show a
     463pieces of program counters remain the same, as specified in \autoref{subsec:evolvingstack}.
     464However in order to show a
    309465forwarding simulation from \verb+RTL_semantics_separate_overflow+, one needs to
    310466remap data pointers. No further hypothesis on stack usage needs to be employed,
    311467as it is integrated in the fact that the execution step does not fail.
    312468
     469\include{mauro}
    313470\end{document}
  • Deliverables/D4.4/report.tex

    r3143 r3194  
    117117
    118118\includepdf[pages={-}]{itp2013.pdf}
    119 \includepdf[pages={-}]{mauro.pdf}
     119\includepdf[pages={-}]{paolo.pdf}
    120120\includepdf[pages={-}]{cpp-2012-asm.pdf}
    121121\includepdf[pages={-}]{cpp-2012-policy.pdf}
Note: See TracChangeset for help on using the changeset viewer.