Implementing Explicit and Finding Implicit Sharing in Embedded DSLs

Aliasing, or sharing, is prominent in many domains, denoting that two differently-named objects are in fact identical: a change in one object (memory cell, circuit terminal, disk block) is instantly reflected in the other. Languages for modelling such domains should let the programmer explicitly def...

Full description

Bibliographic Details
Main Author: Oleg Kiselyov
Format: Article
Language:English
Published: Open Publishing Association 2011-09-01
Series:Electronic Proceedings in Theoretical Computer Science
Online Access:http://arxiv.org/pdf/1109.0784v1
id doaj-5322b7f4f84f44f0bc61cd505bfc3bde
record_format Article
spelling doaj-5322b7f4f84f44f0bc61cd505bfc3bde2020-11-25T02:44:55ZengOpen Publishing AssociationElectronic Proceedings in Theoretical Computer Science2075-21802011-09-0166Proc. DSL 201121022510.4204/EPTCS.66.11Implementing Explicit and Finding Implicit Sharing in Embedded DSLsOleg KiselyovAliasing, or sharing, is prominent in many domains, denoting that two differently-named objects are in fact identical: a change in one object (memory cell, circuit terminal, disk block) is instantly reflected in the other. Languages for modelling such domains should let the programmer explicitly define the sharing among objects or expressions. A DSL compiler may find other identical expressions and share them, implicitly. Such common subexpression elimination is crucial to the efficient implementation of DSLs. Sharing is tricky in embedded DSL, since host aliasing may correspond to copying of the underlying objects rather than their sharing. This tutorial summarizes discussions of implementing sharing in Haskell DSLs for automotive embedded systems and hardware description languages. The technique has since been used in a Haskell SAT solver and the DSL for music synthesis. We demonstrate the embedding in pure Haskell of a simple DSL with a language form for explicit sharing. The DSL also has implicit sharing, implemented via hash-consing. Explicit sharing greatly speeds up hash-consing. The seemingly imperative nature of hash-consing is hidden beneath a simple combinator language. The overall implementation remains pure functional and easy to reason about. http://arxiv.org/pdf/1109.0784v1
collection DOAJ
language English
format Article
sources DOAJ
author Oleg Kiselyov
spellingShingle Oleg Kiselyov
Implementing Explicit and Finding Implicit Sharing in Embedded DSLs
Electronic Proceedings in Theoretical Computer Science
author_facet Oleg Kiselyov
author_sort Oleg Kiselyov
title Implementing Explicit and Finding Implicit Sharing in Embedded DSLs
title_short Implementing Explicit and Finding Implicit Sharing in Embedded DSLs
title_full Implementing Explicit and Finding Implicit Sharing in Embedded DSLs
title_fullStr Implementing Explicit and Finding Implicit Sharing in Embedded DSLs
title_full_unstemmed Implementing Explicit and Finding Implicit Sharing in Embedded DSLs
title_sort implementing explicit and finding implicit sharing in embedded dsls
publisher Open Publishing Association
series Electronic Proceedings in Theoretical Computer Science
issn 2075-2180
publishDate 2011-09-01
description Aliasing, or sharing, is prominent in many domains, denoting that two differently-named objects are in fact identical: a change in one object (memory cell, circuit terminal, disk block) is instantly reflected in the other. Languages for modelling such domains should let the programmer explicitly define the sharing among objects or expressions. A DSL compiler may find other identical expressions and share them, implicitly. Such common subexpression elimination is crucial to the efficient implementation of DSLs. Sharing is tricky in embedded DSL, since host aliasing may correspond to copying of the underlying objects rather than their sharing. This tutorial summarizes discussions of implementing sharing in Haskell DSLs for automotive embedded systems and hardware description languages. The technique has since been used in a Haskell SAT solver and the DSL for music synthesis. We demonstrate the embedding in pure Haskell of a simple DSL with a language form for explicit sharing. The DSL also has implicit sharing, implemented via hash-consing. Explicit sharing greatly speeds up hash-consing. The seemingly imperative nature of hash-consing is hidden beneath a simple combinator language. The overall implementation remains pure functional and easy to reason about.
url http://arxiv.org/pdf/1109.0784v1
work_keys_str_mv AT olegkiselyov implementingexplicitandfindingimplicitsharinginembeddeddsls
_version_ 1724765166920269824