The Procedure Abstraction Part I: Basics

Slides:



Advertisements
Similar presentations
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Advertisements

The Procedure Abstraction Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University.
(1) ICS 313: Programming Language Theory Chapter 10: Implementing Subprograms.
The Procedure Abstraction Part III: Allocating Storage & Establishing Addressability Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all.
3/17/2008Prof. Hilfinger CS 164 Lecture 231 Run-time organization Lecture 23.
The Procedure Abstraction Part IV: Run-time Structures for OOLs Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
Run time vs. Compile time
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
The Procedure Abstraction Part II: Symbol Tables, Storage Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled.
7/13/20151 Topic 3: Run-Time Environment Memory Model Activation Record Call Convention Storage Allocation Runtime Stack and Heap Garbage Collection.
System Calls 1.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
Protection and the Kernel: Mode, Space, and Context.
Compiler Construction
CSc 453 Runtime Environments Saumya Debray The University of Arizona Tucson.
The Procedure Abstraction, Part VI: Inheritance in OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled.
The Procedure Abstraction, Part V: Support for OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
1 CIS 461 Compiler Design and Construction Winter 2012 Lecture-Module #16 slides derived from Tevfik Bultan, Keith Cooper, and Linda Torczon.
Run-Time Storage Organization Compiler Design Lecture (03/23/98) Computer Science Rensselaer Polytechnic.
Lecture 19: Control Abstraction (Section )
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Implementing Subprograms
Introduction to Optimization
Name Spaces: ALL versus OOL
Processes and threads.
Implementing Subprograms
Names and Attributes Names are a key programming language feature
Chapter 8: Main Memory.
The Procedure Abstraction Part III: Symbol Tables, Storage
COMPILERS Activation Records
11.1 The Concept of Abstraction
Run-time organization
Introduction to Compilers Tim Teitelbaum
The Procedure Abstraction Part IV: Allocating Storage & Establishing Addressability Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights.
The Procedure Abstraction Part II: Symbol Tables, Storage
CSCI/CMPE 3334 Systems Programming
Chapter 9 :: Subroutines and Control Abstraction
Implementing Subprograms
Introduction to Optimization
Intermediate Representations
Chap. 8 :: Subroutines and Control Abstraction
Chap. 8 :: Subroutines and Control Abstraction
Introduction to Code Generation
Wrapping Up Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit.
Module 2: Computer-System Structures
The Procedure Abstraction Part V: Run-time Structures for OOLs
Code Shape III Booleans, Relationals, & Control flow
Memory Management Tasks
Implementing Subprograms
Intermediate Representations
BIC 10503: COMPUTER ARCHITECTURE
The Last Lecture COMP 512 Rice University Houston, Texas Fall 2003
Code Shape IV Procedure Calls & Dispatch
Lecture 13: The Procedure Abstraction; Run-Time Storage Organisation
Introduction to Optimization
UNIT V Run Time Environments.
Languages and Compilers (SProg og Oversættere)
Chapter 6 Programming the basic computer
Where is all the knowledge we lost with information? T. S. Eliot
Module 2: Computer-System Structures
Procedure Linkages Standard procedure linkage Procedure has
Implementing Subprograms
11.1 The Concept of Abstraction
Chapter 10 Def: The subprogram call and return operations of
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies of these materials for their personal use.

Procedure Abstraction Begins Chapter 6 in EAC The compiler must deal with interface between compile time and run time (static versus dynamic) Most of the tricky issues arise in implementing “procedures” Issues Compile-time versus run-time behavior Finding storage for EVERYTHING, and mapping names to addresses Generating code to compute addresses that the compiler cannot know ! Interfaces with other programs, other languages, and the OS Efficiency of implementation

Where are we? Errors Source Code Middle End Front Machine code Back IR Well understood Engineering The latter half of a compiler contains more open problems, more challenges, and more gray areas than the front half This is “compilation,” as opposed to “parsing” or “translation” Implementing promised behavior What defines the meaning of the program Managing target machine resources Registers, memory, issue slots, locality, power, … These issues determine the quality of the compiler

The Procedure: Three Abstractions Control Abstraction Well defined entries & exits Mechanism to return control to caller Some notion of parameterization (usually) Clean Name Space Clean slate for writing locally visible names Local names may obscure identical, non-local names Local names cannot be seen outside External Interface Access is by procedure name & parameters Clear protection for both caller & callee Invoked procedure can ignore calling context Procedures permit a critical separation of concerns

The Procedure (Realist’s View) Procedures are the key to building large systems Requires system-wide compact Conventions on memory layout, protection, resource allocation calling sequences, & error handling Must involve architecture (ISA), OS, & compiler Provides shared access to system-wide facilities Storage management, flow of control, interrupts Interface to input/output devices, protection facilities, timers, synchronization flags, counters, … Establishes a private context Create private storage for each procedure invocation Encapsulate information about control flow & data abstractions

The Procedure (Realist’s View) Procedures allow us to use separate compilation Separate compilation allows us to build non-trivial programs Keeps compile times reasonable Lets multiple programmers collaborate Requires independent procedures Without separate compilation, we would not build large systems The procedure linkage convention Ensures that each procedure inherits a valid run-time environment and that the callers environment is restored on return The compiler must generate code to ensure this happens according to conventions established by the system

The Procedure (More Abstract View) A procedure is an abstract structure constructed via software Underlying hardware directly supports little of the abstraction—it understands bits, bytes, integers, reals, and addresses, but not: Entries and exits Interfaces Call and return mechanisms may be a special instruction to save context at point of call Name space Nested scopes All these are established by a carefully-crafted system of mechanisms provided by compiler, run-time system, linkage editor and loader, and OS

Run Time versus Compile Time These concepts are often confusing to the newcomer Linkages execute at run time Code for the linkage is emitted at compile time The linkage is designed long before either of these “This issue (compile time versus run time) confuses students more than any other issue in Comp 412”—Keith Cooper

The Procedure as a Control Abstraction Procedures have well-defined control-flow The Algol-60 procedure call Invoked at a call site, with some set of actual parameters Control returns to call site, immediately after invocation

The Procedure as a Control Abstraction Procedures have well-defined control-flow The Algol-60 procedure call Invoked at a call site, with some set of actual parameters Control returns to call site, immediately after invocation int p(a,b,c) int a, b, c; { int d; d = q(c,b); ... } … s = p(10,t,u);

The Procedure as a Control Abstraction Procedures have well-defined control-flow The Algol-60 procedure call Invoked at a call site, with some set of actual parameters Control returns to call site, immediately after invocation int p(a,b,c) int a, b, c; { int d; d = q(c,b); ... } int q(x,y) int x,y; { return x + y; } … s = p(10,t,u);

The Procedure as a Control Abstraction Procedures have well-defined control-flow The Algol-60 procedure call Invoked at a call site, with some set of actual parameters Control returns to call site, immediately after invocation int p(a,b,c) int a, b, c; { int d; d = q(c,b); ... } int q(x,y) int x,y; { return x + y; } … s = p(10,t,u);

The Procedure as a Control Abstraction Procedures have well-defined control-flow The Algol-60 procedure call Invoked at a call site, with some set of actual parameters Control returns to call site, immediately after invocation int p(a,b,c) int a, b, c; { int d; d = q(c,b); ... } int q(x,y) int x,y; { return x + y; } … s = p(10,t,u);

The Procedure as a Control Abstraction Procedures have well-defined control-flow The Algol-60 procedure call Invoked at a call site, with some set of actual parameters Control returns to call site, immediately after invocation Most languages allow recursion int p(a,b,c) int a, b, c; { int d; d = q(c,b); ... } int q(x,y) int x,y; { return x + y; } … s = p(10,t,u);