Analyzing Stack and Heap Bounds for Primitive Recursive Programs in PR- Hume Kevin Hammond, Pedro Vasconcelos, Sun Meng, Álvaro Rebón Portillo, Leonid Timochouk University of St Andrews, Scotland Greg Michaelson, Robert Pointon, Graeme McHale, Chunxiu Liu Heriot-Watt University, Scotland Jocelyn Sérot LASMEA, Clermont-Ferrand, France http://www.hume-lang.org
44
Embed
Analyzing Stack and Heap Bounds for Primitive Recursive Programs in PR-Hume Kevin Hammond, Pedro Vasconcelos, Sun Meng, Álvaro Rebón Portillo, Leonid Timochouk.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Analyzing Stack and Heap Bounds for Primitive Recursive
Programs in PR-Hume
Analyzing Stack and Heap Bounds for Primitive Recursive
Programs in PR-Hume
Kevin Hammond, Pedro Vasconcelos, Sun Meng,Álvaro Rebón Portillo, Leonid Timochouk
University of St Andrews, Scotland
Greg Michaelson, Robert Pointon, Graeme McHale, Chunxiu LiuHeriot-Watt University, Scotland
Jocelyn SérotLASMEA, Clermont-Ferrand, France
http://www.hume-lang.org
Hume
Higher-order Uniform Meta-Environment
Hume
Higher-order Uniform Meta-Environment
David Hume
Scottish Enlightenment Philosopher and Sceptic
1711-1776
Slide 3Kevin Hammond, University of St Andrews
Hume Research ObjectivesHume Research Objectives
• Real-Time, Hard Space Functional Programming– Including Device Drivers, Derek!
• Virtual Testbed for Space/Time Cost Modelling
• Generative, Domain-Specific Language Design
Slide 4Kevin Hammond, University of St Andrews
OverviewOverview
1. Hume Language Design and Examples
2. Stack and Heap Usage for Primitive Recursive Programs1. Cost Model
2. Inference Algorithm (Type-and-Effect System)
3. Results of the Analysis
4. Conclusions and Further Work
Slide 5Kevin Hammond, University of St Andrews
Hume Design Domain (1)Hume Design Domain (1)
QuickTime™ and aYUV420 codec decompressorare needed to see this picture.
Slide 6Kevin Hammond, University of St Andrews
Hume Design Domain (2)Hume Design Domain (2)
Slide 7Kevin Hammond, University of St Andrews
State of the Art...State of the Art...
• Embedded Systems Engineering– big trend to high level software design (UML etc.)
– 80% of all embedded software is now written in C/C++
– 75% of embedded software is delivered late
– bugs can cost $14,000 each to fix!
• A Major Problem with C/C++ is Poor Memory Management– explicit allocation, deallocation
– pointer following
– etc. etc.
• No Accurate Method for Determining Memory Usage – profiling, guesswork(!!), approximation
Slide 8Kevin Hammond, University of St Andrews
A New Direction?A New Direction?
Slide 9Kevin Hammond, University of St Andrews
Hume Design ObjectivesHume Design Objectives
• Targets embedded/critical applications– Hard real-time target– Formally bounded time and space– I/O managed through low-level “ports”/“streams”
» Memory-mapped, timed, interrupts or devices– Asynchronous concurrency model (multicore?)– Simple, easily costed, exception handling mechanisms– Transparent design and implementation: correctness by construction– uses Haskell FFI to allow external calls in C/assembler etc.
• High level of expressiveness/productivity– Rule-based system: concise & clear using functional notation– Runtime errors reduced by strong polymorphic types– Structured reuse through higher order functions– Thread management simplified by implicit concurrency/parallelism – Elimination of memory errors through automatic memory management
Reliability,
Expressibility,
Controllability,
Predictability,
Costability
Slide 10Kevin Hammond, University of St Andrews
FSA-derived NotationFSA-derived Notation• Based on generalised Mealy machines (see Michaelson et al. 2003)• Boxes encapsulate a set of rules each mapping inputs to outputs• Multiple inputs/outputs are grouped into tuples
• Sets of boxes are wired into static process networks (automata)• Boxes repeat indefinitely once a result is produced (tail recursion)• Boxes are asynchronous (ignored inputs/outputs)• Wires are single-buffered
• For the Higher-Order twice and map2 functionstwice f x = f (f x);map2 f [] = [];map2 f (x:[]) = [f x];map2 f (x:(y:[])) = [f x,f y];add1 x = 1+x;h x = map2 (twice add1) x;• The types inferred are:twice :: (t21-{x14,x15}->t21)-{x2,x3}->t21-{x4,x5}->t21,
– alternative real-time scheduling algorithms should be tried
• 1MEuro Framework VI Proposal (FET-OPEN)– with Jocelyn Sérot (LASMEA, France), Martin Hofmann (Ludwigs-Maximilian Univerität,
Germany) and AbsInt GmbH (Saarbrücken, Germany)
Slide 41Kevin Hammond, University of St Andrews
Recent PapersRecent PapersInferring Costs for Recursive, Polymorphic and Higher-Order Functional Programs
Pedro Vasconcelos and Kevin HammondTo appear in Proc. 2003 Intl. Workshop on Implementation of Functional Languages (IFL ‘03), Edinburgh,Springer-Verlag LNCS, 2004. Winner of the Peter Landin Prize for best paper
Hume: A Domain-Specific Language for Real-Time Embedded SystemsKevin Hammond and Greg MichaelsonProc. 2003 Conf. on Generative Programming and Component Engineering (GPCE 2003), Erfurt, Germany,Springer-Verlag LNCS, Sept. 2003. Proposed for ACM TOSEM Fast Track Submission
FSM-Hume: Programming Resource-Limited Systems using Bounded AutomataGreg Michaelson, Kevin Hammond and Jocelyn SérotProc. 2004 ACM Symp. on Applied Computing (SAC ‘04), Nicosia, Cyprus, March 2004
The Design of HumeKevin HammondInvited chapter in Domain-Specific Program Generation,Springer-Verlag LNCS State-of-the-art Survey, C. Lengauer (ed.), 2004
Predictable Space Behaviour in FSM-Hume”,Kevin Hammond and Greg Michaelson,Proc. 2002 Intl. Workshop on Implementation of Functional Languages (IFL ‘02), Madrid, Spain, Sept. 2002, Springer-Verlag LNCS 2670, ISBN 3-540-40190-3,, 2003, pp. 1-16