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 Types and gcc stackframe 1Plan for Today Symbol Table Implementation– how type information is represented with SymTable and Type datastructures Stackframes– gcc stackframe– next time: MiniJava stackframeCS453 Lecture Types and gcc stackframe 2Type implementation in the MiniJava compiler Only one instance of the type object per atomic type and class type– to determine if types are equal just compare references– Type class does not know about inheritancepublic class Type { public static final Type ARRAY = new Type(); public static final Type BOOL = new Type(); public static final Type INT = new Type(); // class type map (key: class name, value: type) private static final HashMap<String, Type> classTypes = new HashMap<String, Type>();CS453 Lecture Types and gcc stackframe 3MiniJava Types for ExampleCS453 Lecture Types and gcc stackframe 4Plan for Learning about Stack Frames Typical C stack frame– gcc calling convention described in A.5 and A.6 in appendix on assemblycode and MIPS Stack frame the MiniJava compiler will generate– Need to match the Wisconsin C-- compiler to implement garbage collection General stack frame concept– agreement amongst programmers, procedure call convention– each agreement has to answer a set of questions– handling nested procedures– handling first class functionsCS453 Intro and PA1 2CS453 Lecture Types and gcc stackframe 5Mapping out the stack frame for the fact exampleCS453 Lecture Types and gcc stackframe 6gcc calling convention Various rules– $sp must stay at 8 byte boundaries– $sp could be pointing to useful data– minimum frame size is 24 bytes– four argument registers, $ra, pad to double word boundary– first four arguments passed in $a0-$a3– arguments after first four passed on stack, pushed in reverse order– before a call the caller must save any caller-saved registers that it is using– at beginning of function, callee must save any callee-saved registers that itwill be using– return value should be in $v0CS453 Lecture Types and gcc stackframe 7A possible implementation of the gcc convention Caller1. Put first four arguments in $a0-$a32. Push later arguments in reverse order (how do we maintain 8 byte boundary?)3. Save caller-saved registers that are in use4. Execute a jal Callee1. Allocate memory for the frame: 24 + pad[(# params passed over four)*4 + (space for callee-saved regs and caller-saved registers ) + ( space for locals andtemps )]2. Save callee-saved registers at highest addresses in the frame3. Set up frame pointer to point to highest address in the frame4. Compute ...5. Put return value in $v06. Restore all callee-saved registers7. Pop stack frame by adding size of frame8. Return by using the return address register,


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?