Honors Compilers Run-Time Support for Compilers Mar 21st 2002

Click here to load reader

  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    1

Embed Size (px)

Transcript of Honors Compilers Run-Time Support for Compilers Mar 21st 2002

  • Slide 1
  • Honors Compilers Run-Time Support for Compilers Mar 21st 2002
  • Slide 2
  • Major Issues What is a compiler run-time? What is a compiler run-time? Major components of run-time Major components of run-time Computational Support Computational Support I/O interfacing I/O interfacing Storage Management Storage Management Tasking interfaces Tasking interfaces Exception Handling Exception Handling Other operating system issues Other operating system issues
  • Slide 3
  • The Compiler Run-Time Simple operations generate direct machine language (e.g. addition) Simple operations generate direct machine language (e.g. addition) But modern languages have many high level constructs But modern languages have many high level constructs Compiler generates calls to hidden routines called the run-time. Compiler generates calls to hidden routines called the run-time. Run-time is included silently in linked program (standard libraries used) Run-time is included silently in linked program (standard libraries used)
  • Slide 4
  • The Compiler Run-Time Part of the implementation Part of the implementation Not available directly to program Not available directly to program Interface may not be documented Interface may not be documented Special calling sequences can be used Special calling sequences can be used Tailored asm may be appropriate Tailored asm may be appropriate Special operating system interface Special operating system interface Delivered as part of the compiler Delivered as part of the compiler Licensing considerations apply Licensing considerations apply
  • Slide 5
  • Computational Support Some simple operations may not be supported by instruction set Some simple operations may not be supported by instruction set 64-bit integer arithmetic 64-bit integer arithmetic Conversion of fpt to integer Conversion of fpt to integer Overflow checking Overflow checking Floating-point (emulation needed) Floating-point (emulation needed) Long shifts Long shifts Square root Square root
  • Slide 6
  • Handling Computational Support Need very small high efficiency routines, might possibly be inlinable Need very small high efficiency routines, might possibly be inlinable Special calling sequences may be useful (e.g. args in registers) Special calling sequences may be useful (e.g. args in registers) Assembly language may be reasonable in this case Assembly language may be reasonable in this case Implementation is target dependent Implementation is target dependent
  • Slide 7
  • Language Considerations Some languages have no high level constructs, so need minimal run time Some languages have no high level constructs, so need minimal run time For example, C, everything is done with explicit procedure calls. For example, C, everything is done with explicit procedure calls. But other languages, e.g. But other languages, e.g. C++ (stream operations) C++ (stream operations) Ada (tasking) Ada (tasking) Java (automatic storage mgmt) Java (automatic storage mgmt)
  • Slide 8
  • The Run-Time in C Very small Very small Usually only some computational routines. Usually only some computational routines. Standard has many standard functions as part of language Standard has many standard functions as part of language These are explicit library routines These are explicit library routines Often part of the underlying OS Often part of the underlying OS E.g. fopen, delete, etc. E.g. fopen, delete, etc. Command line interface needed Command line interface needed
  • Slide 9
  • The Run-Time in Ada Much more extensive Much more extensive Tasking Tasking Timing Timing Storage Management Storage Management Conversions (e.g. string to fpt) Conversions (e.g. string to fpt) Requires extensive library Requires extensive library Only partly target dependent Only partly target dependent
  • Slide 10
  • Other Languages C++ nearer to C, but has C++ nearer to C, but has Streams Streams Exception Handling Exception Handling Java, more extensive, adds Java, more extensive, adds Storage mgmt (garbage collection) Storage mgmt (garbage collection) Standardized arithmetic (IEEE fpt) Standardized arithmetic (IEEE fpt) Interface to JBC/JVM Interface to JBC/JVM
  • Slide 11
  • Other Languages (cont) COBOL, much more extensive COBOL, much more extensive Detailed complex I/O model Detailed complex I/O model Includes full indexed files Includes full indexed files SORT subsystem SORT subsystem INSPECT REPLACING INSPECT REPLACING PICTURE editing PICTURE editing Display and packed numeric formats Display and packed numeric formats
  • Slide 12
  • Other Languages (cont) Very high level languages Very high level languages Setl, Python, GUILE, Visual Basic Setl, Python, GUILE, Visual Basic Set operations Set operations GUI operations GUI operations High level operating systems interfaces High level operating systems interfaces E.g. COM/DCOM interfacing E.g. COM/DCOM interfacing Web interfacing Web interfacing
  • Slide 13
  • I/O interface Language may have explicit I/O statements, or rely on proc interface Language may have explicit I/O statements, or rely on proc interface In either case, have to map the language notion of I/O to op sys In either case, have to map the language notion of I/O to op sys End of line (record vs stream) End of line (record vs stream) Notion of file system (directories?) Notion of file system (directories?) Exception handling Exception handling Character sets (esp wide chars) Character sets (esp wide chars)
  • Slide 14
  • Implementing the I/O Interface Two parts Two parts Target independent code Target independent code Target dependent code Target dependent code Target Independent code Target Independent code Simply implements the language semantics Simply implements the language semantics Using some abstractions Using some abstractions
  • Slide 15
  • Target Dependent I/O On top of operating system On top of operating system Map language semantics to OS semantics, deal with differences as well as possible. Map language semantics to OS semantics, deal with differences as well as possible. On a bare board, have to actually implement basic I/O On a bare board, have to actually implement basic I/O Perhaps at the port level Perhaps at the port level Basically compiler includes an O/S Basically compiler includes an O/S
  • Slide 16
  • Storage Management Stack Allocation Stack Allocation Heap Allocation Heap Allocation Controlled Allocation Controlled Allocation Automatic Garbage Collection Automatic Garbage Collection
  • Slide 17
  • Stack Management Stack must be allocated for each task in the program Stack must be allocated for each task in the program Usually handled by operating system Usually handled by operating system Have to worry about size of stack Have to worry about size of stack How/whether to extend it as needed How/whether to extend it as needed How/whether to check stack overflow How/whether to check stack overflow May or may not be language required May or may not be language required
  • Slide 18
  • Heap Management Basic semantics is Allocate/Free Basic semantics is Allocate/Free Parameters for allocation Parameters for allocation Size in bytes Size in bytes Alignment (often just use max alignment as required for example in C by malloc) Alignment (often just use max alignment as required for example in C by malloc) Parameters for free Parameters for free Probably just address (but perhaps size and aligmnent as well, as in Ada) Probably just address (but perhaps size and aligmnent as well, as in Ada)
  • Slide 19
  • Heap Algorithms Many algorithms available Many algorithms available Free list Free list Multiple free lists Multiple free lists Binary allocator Binary allocator Performance considerations Performance considerations Average case time Average case time Worst case time (real-time critical) Worst case time (real-time critical) Fragmentation considerations Fragmentation considerations
  • Slide 20
  • OS Heap Allocation Typical O/S provides malloc/free Typical O/S provides malloc/free Malloc takes size in bytes Malloc takes size in bytes Returns max aligned address Returns max aligned address Free takes address Free takes address Optimized for average performance Optimized for average performance Often algorithm is not documented Often algorithm is not documented
  • Slide 21
  • More on malloc/free Can map language requirements Can map language requirements E.g. new in C++ or Ada maps to malloc E.g. new in C++ or Ada maps to malloc Unchecked_Deallocation to free Unchecked_Deallocation to free May want to allocate large blocks with malloc, subdivide for use May want to allocate large blocks with malloc, subdivide for use Built in for PL/1 areas Built in for PL/1 areas Built in for Ada collections with storage size clause given. Built in for Ada collections with storage size clause given.
  • Slide 22
  • Commit Strategies Physical Allocation Physical Allocation Virtual Allocation Virtual Allocation Storage committed at allocate time Storage committed at allocate time Storage committed at use time Storage committed at use time Overflow checking Overflow checking Indication of out of memory Indication of out of memory Difficulties with commit on use Difficulties with commit on use
  • Slide 23
  • Specialized Strategies Trade off fragmentation with time performance. Trade off fragmentation with ti