type systems for optimizing stack-based code
DESCRIPTION
optimization of stack based codeTRANSCRIPT
![Page 1: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/1.jpg)
Type Systems for Optimizing Stack-based Code
Presented by:- Nebiyou Enbakom
1Compiler Design, AAIT
![Page 2: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/2.jpg)
IntroductionDead Code EliminationStore/Load+ EliminationRelated WorkConclusionReview
Compiler Design ,AAIT 2
![Page 3: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/3.jpg)
3Compiler Design ,AAIT
Optimizing bytecode directly offers challenges not present in high orintermediate-level program optimizations. The following reasons can be outlined
Expressions and statements are not explicit. In a naive approach, a reconstruction of expression trees from instructions would be required for many optimizations.
:
![Page 4: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/4.jpg)
Compiler Design ,AAIT 4
Related instructions are not necessarily next to each other. A value could be put on the stack, a number of other instructions executed and only then the value used and popped. This means that related instructions, for example those that put a value on a stack, and those that consume it, can be arbitrarily far apart. Links between them need to be found during the analysis.
A single expression can span several different basic blocks. The Java Virtual Machine specification does not require zero stack depth at control flow junctions, so an expression used in a basic block can be partially computed in other basic blocks.
![Page 5: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/5.jpg)
Compiler Design ,AAIT 5
The analyses and optimizations in this paper address dead stores load-pop pairs duplicating loads and store-load pairs, which are typical optimization situations in stack-based code.
![Page 6: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/6.jpg)
6Compiler Design ,AAIT
![Page 7: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/7.jpg)
Dead code elimination Dead Code elimination optimization
removes program statements that do not affect the values of variables that are live at the end of the program.
For example the program x := z + y could be compiled into
0, load z 1, load y 2, add 3, store x 4.
![Page 8: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/8.jpg)
8Compiler Design ,AAIT
![Page 9: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/9.jpg)
If the analysis shows that x is dead, then in the intermediate code, the assignment to x can be deleted. In the stack-based code however, not only the store instruction on line 3, but also lines 0-2 should be deleted.
In stack-based code optimizations statements and expression can span several basic blocks.
![Page 10: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/10.jpg)
10Compiler Design ,AAIT
![Page 11: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/11.jpg)
11Compiler Design ,AAIT
![Page 12: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/12.jpg)
Compiler Design ,AAIT 12
![Page 13: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/13.jpg)
13Compiler Design ,AAIT
![Page 14: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/14.jpg)
14Compiler Design ,AAIT
![Page 15: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/15.jpg)
15Compiler Design ,AAIT
![Page 16: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/16.jpg)
Compiler Design ,AAIT 16
![Page 17: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/17.jpg)
17Compiler Design ,AAIT
![Page 18: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/18.jpg)
18Compiler Design ,AAIT
![Page 19: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/19.jpg)
19Compiler Design ,AAIT
![Page 20: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/20.jpg)
Compiler Design ,AAIT 20
![Page 21: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/21.jpg)
21Compiler Design ,AAIT
![Page 22: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/22.jpg)
22Compiler Design ,AAIT
![Page 23: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/23.jpg)
23Compiler Design ,AAIT
![Page 24: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/24.jpg)
Compiler Design ,AAIT 24
![Page 25: Type Systems for Optimizing Stack-based Code](https://reader033.vdocuments.us/reader033/viewer/2022042905/577cc7391a28aba711a0580b/html5/thumbnails/25.jpg)
THANK YOU!
25Compiler Design ,AAIT