lec23 - CS415 Compilers Procedure Abstraction These slides...

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

View Full Document Right Arrow Icon
CS415 Compilers Procedure Abstraction These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture 23 2 cs415, spring 10 Establishing Addressability Using access links ( static links ) Each AR has a pointer to AR of lexical ancestor Lexical ancestor need not be the caller Reference to < p,16 > runs up access link chain to p Cost of access is proportional to lexical distance parameters register save area return value return address access link caller’s ARP local variables A R P parameters register save area return value return address access link caller’s ARP local variables parameters register save area return value return address access link caller’s ARP local variables Some setup cost on each call
Background image of page 2
Lecture 23 3 cs415, spring 10 Establishing Addressability Using access links Access & maintenance cost varies with level All accesses are relative to ARP (r 0 ) Assume Current lexical level is 2 Access link is at ARP -4 Maintaining access link Calling level k +1 ( k is current level) Use current ARP as link in new AR Calling level j < Find ARP for j –1 Use that ARP as link in new AR SC Generated Code < 2,8 > loadAI r 0 , 8 r 2 < 1,12 > loadAI r 0 , -4 r 1 loadAI r 1 , 12 r 2 < 0,16 > loadAI r 0 , -4 r 1 loadAI r 1 , -4 r 1 loadAI r 1 , 16 r 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Lecture 23 4 cs415, spring 10 Establishing Addressability Using a display Global array of pointer to nameable AR s Needed ARP is an array access away Reference to < p,16 > looks up p’s ARP in display & adds 16 Cost of access is constant ( ARP + offset) ARP parameters register save area return value return address saved ptr. caller’s ARP local variables parameters register save area return value return address saved ptr. caller’s ARP local variables level 0 level 1 level 2 level 3 Display parameters register save area return value return address saved ptr.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

lec23 - CS415 Compilers Procedure Abstraction These slides...

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

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