{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Winter 2013 uw cse 401 michael ringenburg 8 constant

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: do we figure out which method to call based on the run- 9me type of an object? Winter 2013 UW CSE 401 (Michael Ringenburg) 7 Seman9c Analysis CSE341: Programming CSE341: •  Main tasks: Programming Languages Languages –  Extract types and other informa9on from the program Lecture 1 Lecture 1 –  Check language rules that go beyond the context- free grammar Course Mechanics –  Resolve nCourse Mechanics ames ML Variable Bindings •  Relate declara9ons and uses of each variable ML Variable Bindings –  “Understand” the program well enough for synthesis Dan Grossman •  E.g., sizes, layouts of classes/structs Dan Grossman F •  Key data structure: all 2011 tables all 2011 F Symbol –  Map each iden9fier in the program to informa9on about it (kind, type, etc.) •  This is typically considered the final part of the “front end” of the compiler (once complete, know whether or not program is legal). Winter 2013 UW CSE 401 (Michael Ringenburg) 8 Constant Folding C s a simple op9miza9on CSE341: Programming Languages that •  Constant folding iSE341: Programming Languages computes at compile- 9me the results of opera9ons Lecture 1 Lecture 1 whose operands are all constants (e.g., integer literals) Course Course Mechanics Mechanics ML Variable Bindings •  It is ojen aL Variable Bindingsuring compila9on, as M pplied many 9mes d certain other op9miza9ons may reveal addi9onal Dan Grossman folding opportuni9es Dan Grossman Fall 2011 Fall 2011 –  E.g., constant propaga0on may cause a variable access to be replaced with a constant. •  Many compilers perform the first pass during the front end seman9c analysis phase. –  Can be done via a depth- first traversal of the AST. Winter 2013 9 UW CSE 401 (Michael Ringenburg) Example: AST and depth- first folding traversal CSE341: Programming CSE341: Programming Languages Languages x = 1 + 2; Lecture 1 Lecture 1 … Course y= Course Mechanics Mechanics(2*5 + 5)/x; ML Variable Bindings ML Variable Bindings Dan Grossman Fall 2011 Dan Grossman Fall 2011 During later optimization/analysis phases, we may be able to prove that x does not change between the two statements, in which case we could propagate the folded constant value of x forward to it’s usage in the computation of y’s value. After...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online