29 research outputs found

    Uniting Language Embeddings for Fast and Friendly DSLs

    Get PDF
    The holy grail for a domain-specific language (DSL) is to be friendly and fast. A DSL should be friendly in the sense that it is easy to use by DSL end-users, and easy to develop by DSL authors. DSLs can be developed as entirely new compilers and ecosystems, which requires tremendous effort and often requires DSL authors to reinvent the wheel. Or, DSLs can be developed as libraries embedded in an existing host language, which requires significantly less effort. Embedded DSLs (EDSLs) manifest a trade-off between being friendly and fast as they stand divided in two groups: - Deep EDSLs trade user experience of both DSL authors and DSL end-users, for improved program performance. As proposed by Elliott et al., deep EDSLs build an intermediate representation (IR) of a program that can be used to drive domain-specific optimizations, which can significantly improve performance. However, this program IR introduces significant usability hurdles for both the DSL authors and DSL end-users. Correctly transforming programs is difficult and error prone for DSL authors, while error messages can be cryptic and confusing for DSL end-users. - Shallow EDSLs trade program performance for good user experience. As proposed by P. Hudak, shallow EDSLs omit construction of the IR, i.e., they are executed directly in the host language. Although friendly to both DSL end-users and DSL authors, they can not perform domain-specific optimizations and thus exhibit inferior performance. This thesis makes a stride towards achieving both (1) good user experience for DSL authors and DSL end-users, as well as (2) enabling domain-specific optimizations for improved performance. It unites shallow and deep DSLs by defining an automatic translation from end-user-friendly shallow DSLs, to better-performing deep DSLs. The translation uses reflection of the host language to cherry-pick the best of both shallow and deep EDSLs. During program development, a DSL end-user is presented with user friendly features of a shallow EDSL. Before execution in a production environment, programs are reliably translated into the high-performance deep EDSL with equivalent semantics. Since maintaining both shallow and deep EDSLs is difficult, the thesis further shows how to reuse the shallow-to-deep translation to automatically generate deep EDSLs based on shallow EDSLs. With automatic generation of the deep EDSL, the DSL author is required only to develop a shallow EDSL and the domain-specific optimizations for the deep EDSL that she deems useful. Finally, the thesis discusses a new programming abstraction that eases the development, of a specific kind, of deep EDSLs that are compiled in two stages. The new abstraction simplifies management of dynamic compilation in two-stage deep EDSLs

    Comparing Rapid Type Analysis with Points-To Analysis in GraalVM Native Image

    Full text link
    Whole-program analysis is an essential technique that enables advanced compiler optimizations. An important example of such a method is points-to analysis used by ahead-of-time (AOT) compilers to discover program elements (classes, methods, fields) used on at least one program path. GraalVM Native Image uses a points-to analysis to optimize Java applications, which is a time-consuming step of the build. We explore how much the analysis time can be improved by replacing the points-to analysis with a rapid type analysis (RTA), which computes reachable elements faster by allowing more imprecision. We propose several extensions of previous approaches to RTA: making it parallel, incremental, and supporting heap snapshotting. We present an extensive experimental evaluation of the effects of using RTA instead of points-to analysis, in which RTA allowed us to reduce the analysis time for Spring Petclinic, a popular demo application of the Spring framework, by 64% and the overall build time by 35% at the cost of increasing the image size due to the imprecision by 15%

    Synchronization of Huygens' clocks and the Poincare method

    Full text link
    We study two models of connected pendulum clocks synchronizing their oscillations, a phenomenon originally observed by Huygens. The oscillation angles are assumed to be small so that the pendulums are modeled by harmonic oscillators, clock escapements are modeled by the van der Pol terms. The mass ratio of the pendulum bobs to their casings is taken as a small parameter. Analytic conditions for existence and stability of synchronization regimes, and analytic expressions for their stable amplitudes and period corrections are derived using the Poincare theorem on existence of periodic solutions in autonomous quasi-linear systems. The anti-phase regime always exists and is stable under variation of the system parameters. The in-phase regime may exist and be stable, exist and be unstable, or not exist at all depending on parameter values. As the damping in the frame connecting the clocks is increased the in-phase stable amplitude and period are decreasing until the regime first destabilizes and then disappears. The results are most complete for the traditional three degrees of freedom model, where the clock casings and the frame are consolidated into a single mass.Comment: 23 pages, 8 figure

    D'Alembert sums for vibrating bar with viscous ends

    Full text link
    We describe a new method for finding analytic solutions to some initial-boundary problems for partial differential equations with constant coefficients. The method is based on expanding the denominator of the Laplace transformed Green's function of the problem into a convergent geometric series. If the denominator is a linear combination of exponents with real powers one obtains a closed form solution as a sum with finite but time dependent number of terms. We call it a d'Alembert sum. This representation is computationally most effective for small evolution times, but it remains valid even when the system of eigenmodes is incomplete and the eigenmode expansion is unavailable. Moreover, it simplifies in such cases. In vibratory problems d'Alembert sums represent superpositions of original and partially reflected traveling waves. They generalize the d'Alembert type formulas for the wave equation, and reduce to them when original waves can undergo only finitely many reflections in the entire course of evolution. The method is applied to vibrations of a bar with dampers at each end and at some internal point. The results are illustrated by computer simulations and comparisons to modal and FEM solutions.Comment: 18 pages, 8 figure

    Squid: Type-Safe, Hygienic, and Reusable Quasiquotes

    Get PDF
    Quasiquotes have been shown to greatly simplify the task of metaprogramming. This is in part because they hide the data structures of the intermediate representation (IR), instead allowing metaprogrammers to use the concrete syntax of the language they manipulate. Scala has had ``syntactic'' quasiquotes for a long time, but still misses a statically-typed version like in MetaOCaml, Haskell and F#. This safer flavor of quasiquotes has been particularly useful for staging and domain-specific languages. In this paper we present Squid, a metaprogramming system for Scala that fills this gap. Squid quasiquotes are novel in three ways: they are the first statically-typed quasiquotes we know that allow code inspection (via pattern matching); they are implemented purely as a macro library, without modifications to the compiler; and they are reusable in the sense that they can manipulate different IRs. Adapting (or binding) a new IR to Squid is done simply by implementing a well-defined interface in the style of object algebras (i.e., tagless-final). We detail how Squid is implemented, leveraging the metaprogramming tools already offered by Scala, and show three application examples: the definition of a binding for a DSL in the style of LMS; a safe ANF conversion; and the introduction of type-safe, hygienic macros as an alternative to the current macro system
    corecore