On the Overhead of CPS
نویسندگان
چکیده
Continuation-passing style (CPS) is often criticized to be more expensive than the usual direct style of functional programming. By structure, CPS functions indeed are passed one extra argument (the continuation), and each intermediate result indeed occurs in a function call (to the continuation). As higher-order functions, continuations are also more expensive. However, by structure also, CPS exhibits a great deal of syntactic regularity. We show how to exploit this regularity to implement CPS with two stacks — one for continuation parameters and one for the parameters of continuations — in a way that reduces the extra price of CPS to managing those two stacks. In effect, the stack for continuation parameters acts as a control stack for calls and returns, and the stack for parameters of continuations acts as a data stack for intermediate results. This demonstrates that CPS is just about as expensive as direct style, where calls, returns, and intermediate results also have to be dealt with. To this end, we present four abstract machines for CPS λ-terms — a bare one, one with a control stack, one with a data stack, and one with both a control stack and a data stack — and we prove their equivalence. Our result also applies to A-normal forms, i.e., monadic style.
منابع مشابه
Efficient and Scalable Runtime Monitoring for Cyber–Physical System
Our reliance on cyber–physical systems (CPSs) is increasingly widespread, but scalable methods for the analysis of such systems remain a significant challenge. Runtime verification of CPSs provides a reasonable middle ground between formal verification and simulation approaches, but it comes with its own challenges. A runtime verification system must run directly on the deployed application. In...
متن کاملCode-Pointer Integrity
Systems code is often written in low-level languages like C/C++, which offer many benefits but also delegate memory management to programmers. This invites memory safety bugs that attackers can exploit to divert control flow and compromise the system. Deployed defense mechanisms (e.g., ASLR, DEP) are incomplete, and stronger defense mechanisms (e.g., CFI) often have high overhead and limited gu...
متن کاملBraceAssertion: Behavior Driven Development for CPS Application
Cyber-Physical Systems (CPS) have gained widepopularity, however, developing and debugging CPS remainsignificant challenges. Many bugs are detectable only at runtimeunder deployment conditions that may be unpredictable or atleast unexpected at development time. The current state of thepractice of debugging CPS is generally ad hoc, involving trial anderror in a real deplo...
متن کاملAssessing the Overhead of ML Exceptions by Selective CPS Transformation
ML’s exception handling makes it possible to describe exceptional execution flows conveniently, but it also forms a performance bottleneck. Our goal is to reduce this overhead by source-level transformation. To this end, we transform source programs into continuation-passing style (CPS), replacing handle and raise expressions by continuationcatching and throwing expressions, respectively. CPS-t...
متن کاملCyber-Physical Systems: Theoretical and Practical Challenges
ubiquitous embedded systems employed to monitor and control physical processes: cars, airplanes, automotive highway systems, air traffic management , etc. In the past, research on embedded systems tended to focus on the design optimization problems of these computational devices. In recent years, the focus has shifted towards the complex synergy between the computational elements and the physic...
متن کامل