compiler interpreter and_bootstrapping
TRANSCRIPT
![Page 1: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/1.jpg)
01/04/15 1
Submitted to:-Sandeep Manzhi
TECHNOCRATS INSTITUTEOF TECHNOLOGY & SCIENCE
Bootstrapping
![Page 2: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/2.jpg)
2
Bootstrapping
• a number of techniques which rely on partial/inefficient compiler version to create a full/better version
• often compiling a translator expressed in its own language
![Page 3: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/3.jpg)
3
Full Bootstrapping
• A full bootstrap is necessary when we are building a new compiler from scratch.
• Example:• We want to implement an Ada
compiler for machine M. We don’t currently have access to any Ada compiler (not on M, nor on any other machine).
• Idea: Ada is very large, we will implement the compiler in a subset of Ada and bootstrap it from a subset of Ada compiler in another language. (e.g. C)
![Page 4: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/4.jpg)
4
Full Bootstrapping continued
• Step 1: build a compiler for Ada-S in another language
Ada-S ->M
C
v1
Ada-S ->M
C
v1
Step 1a: build a compiler (v1) for Ada-S in another language.
![Page 5: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/5.jpg)
5
Full bootstrapping
Ada-S ->M
C
v1
Ada-S->M
v1
Step 1b: Compile v1 compiler on M
M
C->M
MThis compiler can be used for bootstrapping on machine M but we do not want to rely on it permanently!
![Page 6: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/6.jpg)
6
Full Bootstrapping continued
Ada-S ->M
Ada-S
v2
Step 2a: Implement v2 of Ada-S compiler in Ada-S
Ada-S ->M
Ada-S
v2
M
M
Ada-S->M
v2
Step 2b: Compile v2 compiler with v1 compiler
Ada-S ->M
M
v1
We are now no longer dependent on the availability of
a C compiler!
![Page 7: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/7.jpg)
7
Full Bootstrapping continued
Step 3a: Build a full Ada compiler in Ada-S
Ada->M
Ada-S
v3
Step 3b: Compile with v2 compiler
M
Ada->M
v3
Ada-S ->MM
v2Ada->M
Ada-S
v3
M
From this point on we can maintain the compiler in Ada. Subsequent versions v4,v5,... of the compiler in Ada and compile each with the the previous version.
![Page 8: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/8.jpg)
8
Half BootstrappingWe discussed full bootstrapping which is required when we have no access to a compiler for our language at all.
Q: What if we have access to an compiler for our language on a different machine HM but want to develop one for TM ?
Ada->HMHM
Ada->HMAda
Ada->TMTM
We have We want
Idea: we can use cross compilation from HM to TM to
bootstrap the TM compiler
![Page 9: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/9.jpg)
Cross compiler:
running on HM but emits
TM code
9
Half Bootstrapping continued
Step 1: Implement Ada->TM compiler in Ada
Ada->TMAda
Step 2: Compile on HM
Ada->TMAda
HM
Ada->HMHM
Ada->TM
HM
![Page 10: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/10.jpg)
10
Half Bootstrapping continued
Step 3: Cross compile our TM compiler.
Ada->TMAda Ada-
>TMHM
HM
DONE!
TM
From now on we can develop subsequent versions of the compiler completely on TM
Ada->TM
![Page 11: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/11.jpg)
11
Bootstrap to improve efficiency
The efficiency of programs and compilers:Efficiency of programs:
- memory usage- runtime
Efficiency of compilers: - Efficiency of the compiler itself- Efficiency of the emitted code
Idea: We start from a simple compiler (generating inefficient code) and develop more sophisticated version of it. We can then use bootstrapping to improve performance of the compiler.
![Page 12: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/12.jpg)
12
Bootstrap to improve efficiency
Ada->MslowAda
Ada-> MslowMslow
Ada->MfastAda
Ada->Mfast
Ada
M
Ada->MfastMslow
Step 1
Ada-> MslowMslow
We have We want
![Page 13: Compiler interpreter and_bootstrapping](https://reader038.vdocuments.site/reader038/viewer/2022100501/55a6acdc1a28abf4018b48c9/html5/thumbnails/13.jpg)
13
Bootstrap to improve efficiency
Step 2Ada->MfastAda
M
Ada->MfastMfastAda->
MfastMslow
Fast compiler that emits fast
code!