{'fraction_non_alphanumeric': 0.018175582990397805, 'fraction_numerical': 0.0, 'mean_word_length': 5.439293598233996, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Region based program specialization: an operational approach to polymorphic offline partial evaluation for ML-like languages

Program specialization or partial evaluation is a proven program optimization technique dating back to the early seventies. It is based on aggressive constant propagation and function unfolding, and is usually employed as an extra tool in the program compilation process. Partial evaluation works remarkably well when the program input can be factored in static, less variable, and dynamic, often changing, parts. A partial evaluator transforms the source program by reducing as much operations as possible with respect to the static input. The resulting program is usually faster than the original program whenever the latter has to be executed with its static input. One common flavor of program specialization is offline partial evaluation. It employs a program analysis to determine what operations can be reduced at specialization time. Historically, offline systems used simple binding-time annotation techniques, or considered simply-typed programming languages. These approaches have hampered offline methods in reaching their full potential. In this thesis, we aim to address these limitations. We describe the development of a new and entirely operational theory for offline polymorphic specialization of ML-like languages by combining techniques from dynamic memory management with program specialization. Our approach is based on the region calculus of Tofte and Talpin, a polymorphically typed lambda calculus with annotations that make memory allocation and deallocation explicit. It is intended as an intermediate language for implementing Hindley-Milner typed functional languages without traditional trace-based garbage collection. Static region and effect inference can be used to annotate a statically-typed ML program with memory management primitives. The formal correctness proof of our novel specialization technique based on a region type system requires two theoretical building blocks: a type soundness proof for the region calculus and a correctly proven equational theory between region-annotated terms. To establish the first building block, we present a new formulation of type soundness for the region and effect system of the region calculus. Such a property is crucial to guarantee safe deallocation of regions, i.e., deallocation should only take place for objects which are provably dead. The original soundness proof by Tofte and Talpin is based on a big-step evaluation-style operational semantics and requires a complex co-inductive safety relation. We reformulate type soundness with respect to two small-step operational semantics. Following the standard syntactic approach of Wright, Felleisen and Harper, we obtain simple inductive proofs. The first semantics is storeless. It is simple and gives rise to perspicuous proofs. The second imperative …