jagomart
digital resources
picture1_Compiler Construction Pdf 187732 | Lect02 2x2


 186x       Filetype PDF       File size 0.09 MB       Source: www.cse.chalmers.se


File: Compiler Construction Pdf 187732 | Lect02 2x2
software engineering for compilers josef svenningsson testing compilers compiler construction spring 2014 trusting the compiler establishing compiler correctness bugs alternatives whenndingabug gotogreatlengthstonditinourowncode proving the correctness of a compiler is prohibitively ...

icon picture PDF Filetype PDF | Posted on 02 Feb 2023 | 2 years ago
Partial capture of text on file.
                              Software Engineering for Compilers
                                        Josef Svenningsson                                              Testing compilers
                                  Compiler Construction, Spring 2014
                  Trusting the compiler                                            Establishing Compiler Correctness
                      Bugs                                                             Alternatives
                      Whenfindingabug,gotogreatlengthstofinditinourowncode.                 Proving the correctness of a compiler is prohibitively
                          Most programmers trust the compiler to generate correct code    expensive
                          Themostimportant task of the compiler is to generate correct    (however, see the CompCert project)
                          code                                                            Testing is the only viable option
                       Testing compilers                                                               Randomtesting
                               Most compilers use unit testing
                               They have a big collection of example programs which are                    Randomtesting
                               used for testing the compiler                                                   Generating random inputs and check correctness of output
                               For each program the expected output is stored in the test                      Usedbye.g.QuickCheck
                               suite
                               Wheneveranewbugisfound,anewexampleprogramis
                               added to the test suite. This is known as regression testing.
                       RandomTesting For Compilers                                                     Project
                               Testing compilers using random testing means generating
                               programs in the source language.
                               Writing good random test generators for a language is very
                               difficult
                               Different parts of the compiler might need different generators:            Remembertotestyourcompiler!
                                    Theparser needs random strings, but they need to be skewed                 Usetheprovided test suite!
                                    towards syntactically correct programs in order to be useful.              Write your own tests!
                                    Thetype checker needs a generator which can generate type
                                    correct programs (with high probablity)
                               It can be hard to know what the correct execution of a
                               program is.
                               Weneedanothercompilerorinterpreter to test againts.
                               Whatif the generated program doesn’t terminate, or takes a
                               very long time?
                               Using random testing for compilers is a lot of work.
                                                                                                 Areal language
                                                                                                     Somepeoplesay:
                                          Compiler Bootstrapping                                     Aprogramminglanguageisn’t real until it has a self-hosting
                                                                                                     compiler
                      Aself-hosting compiler                                                     Thechicken and egg problem
                                                                                                     If we want to write a compiler for the language X in the language X,
                                                                                                     howdoesthefirstcompiler get written?
                         If you’re designed an awesome programming language you would                Solutions
                         probably want to program in it.                                                  Write an interpreter for language X in language Y.
                         In particular, you would want to write the compiler in this language.            Write another compiler for language X in language Y.
                                                                                                          Write the compiler in a subset of X which is possible to
                                                                                                          compiler with an existing compiler.
                                                                                                          Hand-compile the first compiler.
                       Porting to new architectures
                            Arelated problem
                            Howtoportacompilertoanewhardwarearchitecture.
                            Solution: Cross-compilation                                                                              Writing Makefiles
                            Let the compiler emit code for the new architecture while still
                            running on an old architecture.
                       Make                                                                               Rules
                                                                                                              AMakefileconsists of rules which specifies:
                                                                                                                   Which target file will be generated
                                                                                                                   Howthesefilesaregenerated.
                            Theutility make is very handy for compiling large projects
                            It can help to track which files have been edited and recompile                    General structure of rules
                            object files and programs where necessary.                                         target: dependencies .....
                                                                                                                   shell commands specifying how to generate target
                                                                                                              Concrete example
                                                                                                              module.o : module.c
                                                                                                                   gcc -c module.c -o module.o
The words contained in this file might help you see if this file matches what you are looking for:

...Software engineering for compilers josef svenningsson testing compiler construction spring trusting the establishing correctness bugs alternatives whenndingabug gotogreatlengthstonditinourowncode proving of a is prohibitively most programmers trust to generate correct code expensive themostimportant task however see compcert project only viable option randomtesting use unit they have big collection example programs which are used generating random inputs and check output each program expected stored in test usedbye g quickcheck suite wheneveranewbugisfound anewexampleprogramis added this known as regression using means source language writing good generators very difcult different parts might need remembertotestyourcompiler theparser needs strings but be skewed usetheprovided towards syntactically order useful write your own tests thetype checker generator can type with high probablity it hard know what execution weneedanothercompilerorinterpreter againts whatif generated doesn t termi...

no reviews yet
Please Login to review.