1 Binding Time and Storage Allocation (Section 3.1-3.2) CSCI 431 Programming Languages Fall 2003 A modification of slides developed by Felix Hernandez-Campos.

Slides:



Advertisements
Similar presentations
Chapt.2 Machine Architecture Impact of languages –Support – faster, more secure Primitive Operations –e.g. nested subroutine calls »Subroutines implemented.
Advertisements

Programming Languages and Paradigms
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
Names and Bindings.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
1 Object-Oriented Programming (Section ) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
Names, Bindings, Type Checking, and Scopes
Chapter 10 Storage management
1 Names, Scopes and Bindings. 2 Names Kinds of names Kinds of names Variables, functions, classes, types, labels, blocks, operators, tasks, etc. Variables,
Chapter 10 Storage Management Implementation details beyond programmer’s control Storage/CPU time trade-off Binding times to storage.
Run-Time Storage Organization
Run time vs. Compile time
The Concept of Variables
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 9: Subprogram Control
Chapter 5: Memory Management Dhamdhere: Operating Systems— A Concept-Based Approach Slide No: 1 Copyright ©2005 Memory Management Chapter 5.
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
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.
Names and Bindings Introduction Names Variables The concept of binding Chapter 5-a.
1 Contents. 2 Run-Time Storage Organization 3 Static Allocation In many early languages, notably assembly and FORTRAN, all storage allocation is static.
Programming Languages and Paradigms Object-Oriented Programming.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
COP4020 Programming Languages
Name Binding and Object Lifetimes Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Concepts Lecture.
CS3012: Formal Languages and Compilers The Runtime Environment After the analysis phases are complete, the compiler must generate executable code. The.
CS 403: Programming Languages Lecture 2 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 Chapter 5 Names Bindings Type Checking Scope. 2 High-Level Programming Languages Two main goals:Two main goals: –Machine independence –Ease of programming.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
1 Names, Scopes and Bindings Aaron Bloomfield CS 415 Fall
Chapter 7 Runtime Environments. Relationships between names and data objects As execution proceeds, the same name can denote different data objects Procedures,
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
The Procedure Abstraction, Part V: Support for OOLs Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
1 Scope Rules (Section 3.3) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael Scott.
Basic Semantics Associating meaning with language entities.
1 Control Abstraction (Section ) CSCI 431 Programming Languages Fall 2003 A compilation of material developed by Felix Hernandez-Campos and Michael.
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Xin Yuan.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 9.
COMP3190: Principle of Programming Languages
RUN-Time Organization Compiler phase— Before writing a code generator, we must decide how to marshal the resources of the target machine (instructions,
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
1 Lecture 22: Object Lifetime and Garbage Collection (Section 10.3 & 7.7) CSCI 431 Programming Languages Fall 2002 A modification of slides developed by.
Lecture 19: Control Abstraction (Section )
Programming Languages and Design Lecture 6 Names, Scopes and Binding Instructor: Li Ma Department of Computer Science Texas Southern University, Houston.
CS 330 Programming Languages 10 / 23 / 2007 Instructor: Michael Eckmann.
LECTURE 13 Names, Scopes, and Bindings: Memory Management Schemes.
Names, Scope, and Bindings Programming Languages and Paradigms.
Code Generation Instruction Selection Higher level instruction -> Low level instruction Register Allocation Which register to assign to hold which items?
Object Lifetime and Pointers
Storage Allocation Mechanisms
Data Types In Text: Chapter 6.
Names and Attributes Names are a key programming language feature
CS 326 Programming Languages, Concepts and Implementation
CS 326 Programming Languages, Concepts and Implementation
CS 3304 Comparative Languages
Names, Binding, and Scope
Memory Management Overview
Binding Times Binding is an association between two things Examples:
Programming Languages
Names and Binding In Text: Chapter 5.
Dynamic Memory.
Name Binding and Object Lifetimes
point when a program element is bound to a characteristic or property
Run-time environments
Presentation transcript:

1 Binding Time and Storage Allocation (Section ) CSCI 431 Programming Languages Fall 2003 A modification of slides developed by Felix Hernandez-Campos at UNC Chapel Hill

2 Review: Compilation/Interpretation Compiler or Interpreter Translation Execution Source Code Target Code Interpre-tation

3 Phases of Compilation

4 High-Level Programming Languages Two main goals:Two main goals: –Machine independence –Ease of programming High-level programming languages are independent of any particular instruction setHigh-level programming languages are independent of any particular instruction set –But compilation to assembly code requires a target instruction set –There is a trade-off between machine independence and efficiency »E.g. Java vs. C

5 Ease of Programming The driving problem in programming language designThe driving problem in programming language design The rest of this classThe rest of this class –Naming –Control Flow –Types –Subroutines –Object Orientation –Concurrency –Functional Programming –Declarative Programming ProgrammingLanguage

6 Naming Naming is the process by which the programmer associates a name with a potentially complicated program fragmentNaming is the process by which the programmer associates a name with a potentially complicated program fragment –The goal is to hide complexity –Programming languages use name to designate variables, types, classes, methods, operators,… Naming provides abstractionNaming provides abstraction –E.g. Mathematics is all about the formal notation (i.e. naming) that lets us explore more and more abstract concepts

7 Control and Data Abstraction Control abstraction allows the programmer to hide an arbitrarily complicated code behind a simple interfaceControl abstraction allows the programmer to hide an arbitrarily complicated code behind a simple interface –Subroutines –Modules Data Abstraction allows the programmer to hide data representation details behind abstract operationsData Abstraction allows the programmer to hide data representation details behind abstract operations –ADTs –Classes

8 Binding Time A binding is an association between two thingsA binding is an association between two things –E.g. Name of an object and the object Binding time is the time at which a binding is createdBinding time is the time at which a binding is created –Language design time –Language implementation –Program writing time –Compile Time –Link Time –Load Time –Run Time

9 Binding Time Impact Binding times have a crucial impact in programming languagesBinding times have a crucial impact in programming languages –They are a fundamental design decision In general, early binding is associated with greater efficiencyIn general, early binding is associated with greater efficiency –E.g. compilers translate a program once, interpreters translate it every time it is run In general, late binding is associated with greater flexibilityIn general, late binding is associated with greater flexibility –E.g. Class method vs. Subroutine Compiled languages tend to bind names earlier than interpreted languagesCompiled languages tend to bind names earlier than interpreted languages

10 Events in the life of a bindingEvents in the life of a binding –Creation –Destruction »A binding to an object that no longer exists is called a dangling reference –Deactivation and Reactivation Object Lifetime Events in the life of an objectEvents in the life of an object –Creation –Destruction

11 Storage Allocation Mechanisms In static allocation, objects are given an absolute address that is retained throughout the program’s executionIn static allocation, objects are given an absolute address that is retained throughout the program’s execution –E.g. Global variables, Non-recursive Subroutine Parameters, constant literals, run-time tables –Some objects are placed in protected, read-only memory

12 Static Allocation

13 Storage Allocation Mechanisms In static allocation, (static) objects are given an absolute address that is retained throughout the program’s executionIn static allocation, (static) objects are given an absolute address that is retained throughout the program’s execution –E.g. Global variables, Non-recursive Subroutine Parameters In stack-based allocation, (stack) objects are allocated in last-in, first-out data structure, a stack.In stack-based allocation, (stack) objects are allocated in last-in, first-out data structure, a stack. –E.g. Recursive subroutine parameters

14 Stack-based Allocation

15 Storage Allocation Mechanisms In static allocation, (static) objects are given an absolute address that is retained throughout the program’s executionIn static allocation, (static) objects are given an absolute address that is retained throughout the program’s execution –E.g. Global variables, Non-recursive Subroutine Parameters In stack-based allocation, (stack) objects are allocated in last-in, first-out data structure, a stack.In stack-based allocation, (stack) objects are allocated in last-in, first-out data structure, a stack. –E.g. Subroutine parameters In heap-based allocation, (heap) objects may be allocated and deallocated at arbitrary timesIn heap-based allocation, (heap) objects may be allocated and deallocated at arbitrary times –E.g. objects created with C++ new and delete

16 Heap-based Allocation The heap is a region of storage in which blocks of memory can be allocated and deallocatedThe heap is a region of storage in which blocks of memory can be allocated and deallocated –This not the heap data structure

17 Heap Space Management In general, the heap is allocated sequentiallyIn general, the heap is allocated sequentially This creates space fragmentation problemsThis creates space fragmentation problems –Internal fragmentation »If size of object to allocated is smaller than the size of the memory chunk available in the heap –External fragmentation »If size of object to allocated is not larger than the size of the available heap, but the available space in the heap is scattered through the heap in such a way that no contiguous allocation is possible Automatic deallocation after an object has no bindings is called garbage collectionAutomatic deallocation after an object has no bindings is called garbage collection –E.g. Java, Ada, Scheme, SmallTalk, etc.