kth.sePublications KTH
Change search
Link to record
Permanent link

Direct link
Castegren, Elias, DoktorORCID iD iconorcid.org/0000-0003-4918-6582
Alternative names
Publications (8 of 8) Show all publications
Palmkvist, V., Castegren, E., Haller, P. & Broman, D. (2021). Resolvable ambiguity: Principled resolution of syntactically ambiguous programs. In: CC 2021: Proceedings of the 30th ACM SIGPLAN International Conference on Compiler Construction. Paper presented at CC '21: 30th ACM SIGPLAN International Conference on Compiler Construction, Online, South Korea, March 2-3, 2021. New York, NY, United States: Association for Computing Machinery (ACM)
Open this publication in new window or tab >>Resolvable ambiguity: Principled resolution of syntactically ambiguous programs
2021 (English)In: CC 2021: Proceedings of the 30th ACM SIGPLAN International Conference on Compiler Construction, New York, NY, United States: Association for Computing Machinery (ACM) , 2021Conference paper, Published paper (Refereed)
Abstract [en]

When building a new programming language, it can be useful to compose parts of existing languages to avoid repeating implementation work. However, this is problematic already at the syntax level, as composing the grammars of language fragments can easily lead to an ambiguous grammar. State-of-the-art parser tools cannot handle ambiguity truly well: either the grammar cannot be handled at all, or the tools give little help to an end-user who writes an ambiguous program. This composability problem is twofold: (i) how can we detect if the composed grammar is ambiguous, and (ii) if it is ambiguous, how can we help a user resolve an ambiguous program? In this paper, we depart from the traditional view of unambiguous grammar design and enable a language designer to work with an ambiguous grammar, while giving users the tools needed to handle these ambiguities. We introduce the concept of resolvable ambiguity wherein a user can resolve an ambiguous program by editing it, as well as an approach to computing the resolutions of an ambiguous program. Furthermore, we present a method based on property-based testing to identify if a composed grammar is unambiguous, resolvably ambiguous, or unresolvably ambiguous. The method is implemented in Haskell and evaluated on a large set of language fragments selected from different languages. The evaluation shows that (i) the approach can handle significantly more cases of language compositions compared to approaches which ban ambiguity altogether, and (ii) that the approach is fast enough to be used in practice.

Place, publisher, year, edition, pages
New York, NY, United States: Association for Computing Machinery (ACM), 2021
Keywords
Syntax, Ambiguity
National Category
Computer Sciences
Research subject
Computer Science
Identifiers
urn:nbn:se:kth:diva-295417 (URN)10.1145/3446804.3446846 (DOI)001436601600014 ()2-s2.0-85102312948 (Scopus ID)
Conference
CC '21: 30th ACM SIGPLAN International Conference on Compiler Construction, Online, South Korea, March 2-3, 2021
Funder
Swedish Foundation for Strategic Research, FFL15-0032Wallenberg AI, Autonomous Systems and Software Program (WASP)
Note

Part of ISBN 9781450383257

QC 20251020

Available from: 2021-05-20 Created: 2021-05-20 Last updated: 2025-10-20Bibliographically approved
Åkerblom, B., Castegren, E. & Wrigstad, T. (2020). Reference Capabilities for Safe Parallel Array Programming. The Art, Science, and Engineering of Programming, 4(1)
Open this publication in new window or tab >>Reference Capabilities for Safe Parallel Array Programming
2020 (English)In: The Art, Science, and Engineering of Programming, E-ISSN 2473-7321, Vol. 4, no 1Article in journal (Refereed) Published
Abstract [en]

The array is a fundamental data structure that provides an efficient way to store and retrieve non-sparse data contiguous in memory. Arrays are important for the performance of many memory-intensive applications due to the design of modern memory hierarchies: contiguous storage facilitates spatial locality and predictive access patterns which enables prefetching. Operations on large arrays often lend themselves well to parallelisation, such as a fork-join style divideand-conquer algorithm for sorting. For parallel operations on arrays to be deterministic, data-race freedom must be guaranteed. For operations on arrays of primitive data, data-race freedom is obtained by coordinating accesses so that no two threads operate on the same array indices. This is however not enough for arrays of non-primitives due to aliasing: accesses of separate array elements may return pointers to the same object, or overlapping structures. Reference capabilities have been used successfully in the past to statically guarantee the absence of dataraces in object-oriented programs by combining concepts such as uniqueness, read-only access, immutability, and borrowing. This paper presents the first extension of reference capabilities—called array capabilities— that support concurrent and parallel operations on arrays of both primitive and non-primitive values. We define a small language of operators on array capabilities. In addition to element access, these operations support the abstract manipulation of arrays: logical splitting of arrays into subarrays; merging subarrays; and in-place alignment of the physical elements of an array with the logical order defined through splitting and merging. The interplay of these operations with uniqueness, borrowing and read-only access allows expressing a wide range of array use cases. By formalising our type system and the dynamic semantics of the key operations on array capabilities in a simple calculus, we give a precise description of the array capabilities. We when prove type soundness and array disjointness—that two capabilities that allow mutation can never give access to overlapping sets of elements. Data-race freedom is stated as a corollary to these theorems, as data races require two array capabilities in different threads. In addition to the formal approach, we experiment with array capabilities on a small number of parallel array algorithms and report our preliminary findings. Array capabilities extend the safety of reference capabilities to arrays in a way that build cleanly on existing reference capability concepts and constructs. This allows programmers to express parallel array algorithms on a higher level than individual indices, and with absences of data races guaranteed statically.

Place, publisher, year, edition, pages
Aspect-Oriented Software Association (AOSA), 2020
Keywords
Arrays, Capabilities, Parallelism, Type systems
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-313916 (URN)10.22152/programming-journal.org/2020/4/1 (DOI)2-s2.0-85113859645 (Scopus ID)
Note

QC 20220614

Available from: 2022-06-14 Created: 2022-06-14 Last updated: 2024-06-28Bibliographically approved
Castegren, E. & Fernandez-Reyes, K. (2019). Developing a monadic type checker for an object-oriented language: An experience report. In: SLE 2019 - Proceedings of the 12th ACM SIGPLAN International Conference on Software Language Engineering, co-located with SPLASH 2019: . Paper presented at SLE 2019 - International Conference on Software Language Engineering, co-located with SPLASH 2019 (pp. 184-196). Association for Computing Machinery, Inc
Open this publication in new window or tab >>Developing a monadic type checker for an object-oriented language: An experience report
2019 (English)In: SLE 2019 - Proceedings of the 12th ACM SIGPLAN International Conference on Software Language Engineering, co-located with SPLASH 2019, Association for Computing Machinery, Inc , 2019, p. 184-196Conference paper, Published paper (Refereed)
Abstract [en]

Functional programming languages are well-suited for developing compilers, and compilers for functional languages are often themselves written in a functional language. Functional abstractions, such as monads, allow abstracting away some of the repetitive structure of a compiler, removing boilerplate code and making extensions simpler. Even so, functional languages are rarely used to implement compilers for languages of other paradigms. This paper reports on the experience of a four-year long project where we developed a compiler for a concurrent, object-oriented language using the functional language Haskell. The focus of the paper is the implementation of the type checker, but the design works well in static analysis tools, such as tracking uniqueness of variables to ensure data-race freedom. The paper starts from a simple type checker to which we add more complex features, such as type state, with minimal changes to the overall initial design.

Place, publisher, year, edition, pages
Association for Computing Machinery, Inc, 2019
Keywords
Compilers, Functional programming, Object-oriented languages, Type systems, Abstracting, Computer programming languages, Program compilers, Static analysis, Experience report, Functional abstractions, Functional languages, Initial design, Repetitive structure, Simple types, Type checker, Object oriented programming
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-272341 (URN)10.1145/3357766.3359545 (DOI)000717264800018 ()2-s2.0-85076785647 (Scopus ID)
Conference
SLE 2019 - International Conference on Software Language Engineering, co-located with SPLASH 2019
Note

QC 20200427

Part of ISBN 9781450369817

Available from: 2020-04-27 Created: 2020-04-27 Last updated: 2024-10-25Bibliographically approved
Castegren, E. & Wrigstad, T. (2019). OOlong: A Concurrent Object Calculus for Extensibility and Reuse. ACM SIGAPP Applied Computing Review, 18(4), 47-60
Open this publication in new window or tab >>OOlong: A Concurrent Object Calculus for Extensibility and Reuse
2019 (English)In: ACM SIGAPP Applied Computing Review, ISSN 1559-6915, E-ISSN 1931-0161, Vol. 18, no 4, p. 47-60Article in journal (Refereed) Published
Abstract [en]

We present OOlong, an object calculus with interface inheritance, structured concurrency and locks. The goal of the calculus is extensibility and reuse. The semantics are therefore available in a version for LATEX typesetting (written in Ott), a mechanised version for doing rigorous proofs in Coq, and a prototype interpreter (written in OCaml) for typechecking an running OOlong programs.

Place, publisher, year, edition, pages
ACM Press, 2019
Keywords
Object Calculi, Semantics, Mechanisation, Concurrency
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-243970 (URN)10.1145/3307624.3307629 (DOI)000456397300004 ()
Note

QC 20230919

Available from: 2019-02-21 Created: 2019-02-21 Last updated: 2023-09-20Bibliographically approved
Åkerblom, B., Castegren, E. & Wrigstad, T. (2019). Progress Report: Exploring API Design for Capabilities for Programming with Arrays. In: ECOOP 2019: . Paper presented at 14th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, Mon 15 - Fri 19 July 2019 Hammersmith, London, United Kingdom. Association for Computing Machinery (ACM)
Open this publication in new window or tab >>Progress Report: Exploring API Design for Capabilities for Programming with Arrays
2019 (English)In: ECOOP 2019, Association for Computing Machinery (ACM) , 2019Conference paper, Published paper (Refereed)
Abstract [en]

In on-going work, we are exploring reference capabilities for arrays, with the intention of carrying over previous results on statically guaranteed data-race freedom to parallel array algorithms. Reference capabilities typically restrict incoming pointers to an object to one (uniqueness), or restrict operations via multiple pointer to a single object (e.g., to only read). Extending such a design to arrays involve operations such as logically partitioning an array so that even though there are multiple pointers to a single array, these pointers cannot access the same elements. In this paper, we report on the on-going work of a prototype implementation of array capabilities, focusing in particular on the “array capability API design”, meaning the native operations on capabilities such as splitting and merging arrays. Using our prototype implementation, we translate several existing array algorithms into using array capabilities and qualitatively study the result. In addition to identifying the need for additional operations, we study what features are commonly exercised, what are the recurring patterns, and how reliance on direct element addressing using indexes can be reduced. We end by discussing a possible design for a more performant implementation once the API is fixed.

Place, publisher, year, edition, pages
Association for Computing Machinery (ACM), 2019
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-257978 (URN)10.1145/3340670.3342427 (DOI)000545977200003 ()2-s2.0-85073118146 (Scopus ID)
Conference
14th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, Mon 15 - Fri 19 July 2019 Hammersmith, London, United Kingdom
Note

QC 20190917

Available from: 2019-09-09 Created: 2019-09-09 Last updated: 2022-06-26Bibliographically approved
Castegren, E., Clarke, D., Fernandez-Reyes, K., Wrigstad, T. & Yang, A. M. (2018). Attached and detached closures in actors. In: AGERE 2018 - Proceedings of the 8th ACM SIGPLAN International Workshop on Programming Based on Actors, Agents, and Decentralized Control, co-located with SPLASH 2018: . Paper presented at 8th International Workshop on Programming based on Actors, Agents, and Decentralized Control, AGERE! 2018, co-located with SPLASH 2018, Boston, United States, 5 November 2018 through 5 November 2018 (pp. 54-61). Association for Computing Machinery (ACM)
Open this publication in new window or tab >>Attached and detached closures in actors
Show others...
2018 (English)In: AGERE 2018 - Proceedings of the 8th ACM SIGPLAN International Workshop on Programming Based on Actors, Agents, and Decentralized Control, co-located with SPLASH 2018, Association for Computing Machinery (ACM), 2018, p. 54-61Conference paper, Published paper (Refereed)
Abstract [en]

Expressive actor models combine aspects of functional programming into the pure actor model enriched with futures. Such functional features include first-class closures which can be passed between actors and chained on futures. Combined with mutable objects, this opens the door to race conditions. In some situations, closures may not be evaluated by the actor that created them yet may access fields or objects owned by that actor. In other situations, closures may be safely fired off to run as a separate task. This paper discusses the problem of who can safely evaluate a closure to avoid race conditions, and presents the current solution to the problem adopted by the Encore language. The solution integrates with Encore’s capability type system, which influences whether a closure is attached and must be evaluated by the creating actor, or whether it can be detached and evaluated independently of its creator. Encore’s current solution to this problem is not final or optimal. We conclude by discussing a number of open problems related to dealing with closures in the actor model.

Place, publisher, year, edition, pages
Association for Computing Machinery (ACM), 2018
Keywords
Closures, Concurrent programming, Parallel programming, Type systems
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-241488 (URN)10.1145/3281366.3281371 (DOI)000458146800006 ()2-s2.0-85059003161 (Scopus ID)9781450360661 (ISBN)
Conference
8th International Workshop on Programming based on Actors, Agents, and Decentralized Control, AGERE! 2018, co-located with SPLASH 2018, Boston, United States, 5 November 2018 through 5 November 2018
Note

QC 20190123

Available from: 2019-01-23 Created: 2019-01-23 Last updated: 2022-06-26Bibliographically approved
Castegren, E. & Wrigstad, T. (2018). OOlong: An extensible concurrent object calculus. In: Proceedings of the ACM Symposium on Applied Computing: . Paper presented at 33rd Annual ACM Symposium on Applied Computing, SAC 2018, Pau, France, 9 April - 13 April 2018 (pp. 1022-1029). Association for Computing Machinery
Open this publication in new window or tab >>OOlong: An extensible concurrent object calculus
2018 (English)In: Proceedings of the ACM Symposium on Applied Computing, Association for Computing Machinery , 2018, p. 1022-1029Conference paper, Published paper (Refereed)
Abstract [en]

We present OOlong, an object calculus with interface inheritance, structured concurrency and locks. The goal of the calculus is extensibility and reuse. The semantics are therefore available in a version for LATEX typesetting (written in Ott), and a mechanised version for doing rigorous proofs in Coq.

Place, publisher, year, edition, pages
Association for Computing Machinery, 2018
Keywords
Concurrency, Mechanisation, Object calculi, Semantics
National Category
Computer Sciences
Identifiers
urn:nbn:se:kth:diva-336782 (URN)10.1145/3167132.3167243 (DOI)000455180700147 ()2-s2.0-85050541609 (Scopus ID)
Conference
33rd Annual ACM Symposium on Applied Computing, SAC 2018, Pau, France, 9 April - 13 April 2018
Note

Part of ISBN 978-145035191-1

QC 20230920

Available from: 2023-09-20 Created: 2023-09-20 Last updated: 2024-08-29Bibliographically approved
Palmkvist, V., Ågren Thuné, A., Castegren, E. & Broman, D.Repr Types: One Abstraction to Rule Them All.
Open this publication in new window or tab >>Repr Types: One Abstraction to Rule Them All
(English)Manuscript (preprint) (Other academic)
Abstract [en]

The choice of how to represent an abstract type can have a major impact on the performance of a program, yet mainstream compilers cannot perform optimizations at such a high level. When dealing with optimizations of data type representations, an important feature is having extensible representation-flexible data types; the ability for a programmer to add new abstract types and operations, as well as concrete implementations of these, without modifying the compiler or a previously defined library. Many research projects support high-level optimizations through static analysis, instrumentation, or benchmarking, but they are all restricted in at least one aspect of extensibility.

This paper presents a new approach to representation-flexible data types without such restrictions and which still finds efficient optimizations. Our approach centers around a single built-in type repr and function overloading with cost annotations for operation implementations. We evaluate our approach (i) by defining a universal collection type as a library, a single type for all conventional collections, and (ii) by designing and implementing a representation-flexible graph library. Programs using repr types are typically faster than programs with idiomatic representation choices - sometimes dramatically so - as long as the compiler finds good implementations for all operations. Our compiler performs the analysis efficiently by finding optimized solutions quickly and by reusing previous results to avoid recomputations.

National Category
Computer Sciences
Research subject
Computer Science
Identifiers
urn:nbn:se:kth:diva-353104 (URN)10.48550/arXiv.2409.07950 (DOI)
Funder
Vinnova, TECoSASwedish Research Council, 2020-05346Swedish Research Council, 2023-05526Swedish Research Council, 2018-04329KTH Royal Institute of Technology, Digital Futures
Note

QC 20240920

Available from: 2024-09-14 Created: 2024-09-14 Last updated: 2024-09-20Bibliographically approved
Organisations
Identifiers
ORCID iD: ORCID iD iconorcid.org/0000-0003-4918-6582

Search in DiVA

Show all publications