cs160-lec15 - CMPSC 160 Translation of Programming...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPSC 160 Translation of Programming Languages Lectures 15: Memory Allocation
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Memory Layout Placing run time data structures Alignment and padding Machines have alignment restrictions 32-bit floating point numbers and integers should begin on a full-word boundary (32-bit boundary) Place values with identical restrictions next to each other Assign offsets from most restrictive to least If needed, insert padding (space left unused due to alignment restrictions) to match restrictions C o d e S G t l a o t b i a c l H e a p S t a c k 0 high Stack and heap share free space Fixed-size areas together For compiler, this is the entire picture
Background image of page 2
Memory Allocation P D D D; D D id : T T char | int | float | array[num] of T | pointer T Attributes: T.type, T.width Basic types: char width 4, integer width 4, float width 8 Type constructors: array(size,type) width is size * (width of type) pointer(type) width is 4 Enter the variables to the symbol table with their type and memory location: enter(name, type, location) Set the type attribute T.type and calculate the width (T.width) for each type Layout the storage for variables Calculate the offset for each local variable and enter it to the symbol table
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/19/2012 for the course ENGR 361 taught by Professor Drexel during the Spring '12 term at Bloomsburg.

Page1 / 9

cs160-lec15 - CMPSC 160 Translation of Programming...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online