DOC PREVIEW
CSU CS 453 - LECTURE NOTES

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS453 Intro and PA1 1CS453 Lecture MiniJava Compiler - Frame class 1Plan for Today PA6: Stack frame (Variable placement)– testing and grading– the Frame class– the ClassSTE class– the MethodSTE class– the Temp packageCS453 Lecture MiniJava Compiler - Frame class 2Structure of the MiniJava Compiler“sentences”Synthesisinstruction selectionIR code generationTreeAnalysischaracter streamlexical analysis“words”tokenssemantic analysissyntactic analysisASTAST and symbol tablecode generationMIPSPA2PA3 and PA4PA5 and PA6PA7PA8PA8Assem/MIPSoptimizationCS453 Lecture MiniJava Compiler - Frame class 3Frame class implements Factory design patternFrameFrame newFrame()MipsFrameFrame newFrame()MipsFrameCS453 Lecture MiniJava Compiler - Frame class 4What, why, and where? What?– one instance of the MipsFrame will generate other instances Why?– need a Frame instance for each function and want to avoid calling theMipsFrame constructor everywhere Where?// FrameLayout.java! Frame.Frame frame = new Mips.MipsFrame();! BuildSymTable buildSTvisitor = new BuildSymTable(linesToNodes, frame);! // BuildSymTable::inAMethodDecl...Frame.Frame methodFrame = mFrame.newFrame(! new Temp.Label(mCurrentClass.getName()+"$"+node.getName().getText()), formalEscapeList);CS453 Intro and PA1 2CS453 Lecture MiniJava Compiler - Frame class 5Interface to Frame Three main responsibilities– provide a factory interface for generating machine-specific frames– Frame newFrame(Label name, List<Boolean> formals)– answer queries that are machine-specific, but not method specific– int wordSize()– Temp FP(), coming to an interface near you in PA7– store method-specific information about frame layout– Label name– List<Access> formals– Access allocLocal(boolean escape) Access classpublic abstract class Access {! public abstract String toString();! ! //public abstract Tree.Exp exp(Tree.Exp e);!}!CS453 Lecture MiniJava Compiler - Frame class 6When do parameters and/or locals escape? Nesting of classes and methods When the variable may have its address taken When the language uses pass-by-referenceint foo(int x){ int baz(int y) { return x+y; } int bar() { return baz(2); } return bar();}int main() { printf(“%f\n”, foo(3));}int addressFunc(int x){ int z; return blah(&x, &z);}FORTRANsubroutinefoo(x,y)double precision xdouble precision yy=x*2end subroutinesubroutine head()double precision a, bcall foo(a,b)end


View Full Document

CSU CS 453 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?