From 71793eca9cac18cdc0b5ae65c6ef18ae95832710 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 5 Feb 2021 17:01:01 -0500 Subject: [PATCH] Issue #445 - Do not inline prims that open ports It is dangerous to inline these operations because the resource may be opened multiple times and/or not closed properly. --- CHANGELOG.md | 6 ++++++ scheme/cyclone/cps-optimizations.sld | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdd9803e..1d74c846 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.27 - TBD + +Bug Fixes + +- Prevent the compiler from inlining calls to primitives that open ports, avoiding a range of issues such as an open file operation being inlined across multiple places in the intermediate code. + ## 0.26 - February 3, 2021 Features diff --git a/scheme/cyclone/cps-optimizations.sld b/scheme/cyclone/cps-optimizations.sld index 56ef7f75..890dcd17 100644 --- a/scheme/cyclone/cps-optimizations.sld +++ b/scheme/cyclone/cps-optimizations.sld @@ -156,13 +156,18 @@ global defined-by defines-lambda-id - const const-value - ref-count ref-by + const + const-value + ref-count + ref-by mutated-by-set - reassigned assigned-value - app-fnc-count app-arg-count + reassigned + assigned-value + app-fnc-count + app-arg-count cannot-inline - inlinable mutated-indirectly + inlinable + mutated-indirectly cont def-in-loop ref-in-loop @@ -1173,6 +1178,10 @@ Cyc-fast-vector-3 Cyc-fast-vector-4 Cyc-fast-vector-5 + open-input-file + open-output-file + open-binary-input-file + open-binary-output-file ))) (define (prim-calls-inlinable? prim-calls)