Unformatted text preview:

Binding Time and Storage Allocation (Section 3.1-3.2)Review: Compilation/InterpretationPhases of CompilationHigh-Level Programming LanguagesEase of ProgrammingNamingControl and Data AbstractionBinding TimeBinding Time ImpactObject LifetimeStorage Allocation MechanismsStatic AllocationSlide 13Stack-based AllocationSlide 15Heap-based AllocationHeap Space Management11Binding Time and Storage Binding Time and Storage AllocationAllocation(Section 3.1-3.2)(Section 3.1-3.2)CSCI 431 Programming LanguagesCSCI 431 Programming LanguagesFall 2003Fall 2003A modification of slides developed by Felix A modification of slides developed by Felix Hernandez-Campos at UNC Chapel HillHernandez-Campos at UNC Chapel Hill22Review: Compilation/InterpretationReview: Compilation/InterpretationCompiler or InterpreterCompiler or InterpreterTranslation Translation ExecutionExecutionSource CodeSource CodeTarget CodeTarget CodeInterpre-Interpre-tationtation33Phases of CompilationPhases of Compilation44High-Level Programming LanguagesHigh-Level Programming Languages•Two main goals:Two main goals:–Machine independenceMachine independence–Ease of programmingEase of programming•High-level programming languages are independent High-level programming languages are independent of any particular instruction setof any particular instruction set–But compilation to assembly code requires a target But compilation to assembly code requires a target instruction setinstruction set–There is a trade-off between machine independence and There is a trade-off between machine independence and efficiencyefficiency»E.g.E.g. Java vs. C Java vs. C55Ease of ProgrammingEase of Programming•The driving problem in programming language The driving problem in programming language designdesign•The rest of this classThe rest of this class–NamingNaming–Control FlowControl Flow–TypesTypes–SubroutinesSubroutines–Object OrientationObject Orientation–ConcurrencyConcurrency–Functional ProgrammingFunctional Programming–Declarative ProgrammingDeclarative ProgrammingProgramming Programming LanguageLanguage66NamingNaming•NamingNaming is the process by which the programmer is the process by which the programmer associates a name with a potentially complicated associates a name with a potentially complicated program fragmentprogram fragment–The goal is to hide complexityThe goal is to hide complexity–Programming languages use name to designate variables, Programming languages use name to designate variables, types, classes, methods, operators,…types, classes, methods, operators,…•Naming provides Naming provides abstractionabstraction –E.g.E.g. Mathematics is all about the formal notation (i.e. Mathematics is all about the formal notation (i.e. naming) that lets us explore more and more abstract naming) that lets us explore more and more abstract conceptsconcepts77Control and Data AbstractionControl and Data Abstraction•Control abstractionControl abstraction allows the programmer to hide allows the programmer to hide an arbitrarily complicated code behind a simple an arbitrarily complicated code behind a simple interfaceinterface–SubroutinesSubroutines–ModulesModules•Data AbstractionData Abstraction allows the programmer to hide allows the programmer to hide data representation details behind abstract operationsdata representation details behind abstract operations–ADTsADTs–ClassesClasses88Binding TimeBinding Time•A A bindingbinding is an association between two things is an association between two things–E.g. Name of an object and the objectE.g. Name of an object and the object•Binding timeBinding time is the time at which a binding is is the time at which a binding is createdcreated–Language design timeLanguage design time–Language implementationLanguage implementation–Program writing timeProgram writing time–Compile TimeCompile Time–Link TimeLink Time–Load TimeLoad Time–Run TimeRun Time99Binding Time ImpactBinding Time Impact•Binding times have a Binding times have a crucialcrucial impact in programming impact in programming languageslanguages–They are a fundamental design decisionThey are a fundamental design decision•In general, early binding is associated with greater In general, early binding is associated with greater efficiencyefficiency–E.g.E.g. compilers translate a program once, interpreters compilers translate a program once, interpreters translate it every time it is runtranslate it every time it is run•In general, late binding is associated with greater In general, late binding is associated with greater flexibilityflexibility–E.g. E.g. Class method vs. SubroutineClass method vs. Subroutine•Compiled languages tend to bind names earlier than Compiled languages tend to bind names earlier than interpreted languagesinterpreted languages1010•Events in the life of a bindingEvents in the life of a binding–CreationCreation–DestructionDestruction»A binding to an object that no longer exists is called a A binding to an object that no longer exists is called a dangling dangling referencereference–Deactivation and ReactivationDeactivation and ReactivationObject LifetimeObject LifetimeObject LifetimeObject Lifetime•Events in the life of an objectEvents in the life of an object–CreationCreation–DestructionDestruction1111Storage Allocation MechanismsStorage Allocation Mechanisms•In In static allocationstatic allocation, objects are given an absolute , objects are given an absolute address that is retained throughout the program’s address that is retained throughout the program’s executionexecution–E.g. E.g. Global variables, Non-recursive Subroutine Global variables, Non-recursive Subroutine Parameters, constant literals, run-time tablesParameters, constant literals, run-time tables–Some objects are placed in protected, read-only memorySome objects are placed in protected, read-only memory1212Static AllocationStatic Allocation1313Storage Allocation MechanismsStorage Allocation Mechanisms•In In static allocationstatic allocation, (static) objects are given an , (static) objects are given an absolute address that is retained throughout the absolute address that is retained throughout the program’s executionprogram’s execution–E.g. E.g. Global variables, Non-recursive Subroutine Global variables, Non-recursive Subroutine ParametersParameters•In In stack-based allocationstack-based allocation, (stack) objects are , (stack)


View Full Document

UNCA CSCI 431 - Binding Time and Storage Allocation

Download Binding Time and Storage Allocation
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 Binding Time and Storage Allocation 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 Binding Time and Storage Allocation 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?