chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] non-termination with (declare (inline ...))


From: Felix
Subject: [Chicken-hackers] [PATCH] non-termination with (declare (inline ...))
Date: Sun, 17 Mar 2013 23:31:04 +0100 (CET)

The attached patch changes the "inline" declaration, when used with an
identifier, to merely mark that identifier as potentially inlinable by
effectively giving it "local" semantics (the variable is externally
visible but not expected to be changed from outside of this
compilation unit). This leaves the decision to inline to the compiler
and does not force inlining, as was previously done, and which could
lead to non-termination in case the inlined procedure called itself
recursively.

Reported by Andrei Barbu.


cheers,
felix

>From c15a75953e67aad58734f1ec9bd6e14169ad253a Mon Sep 17 00:00:00 2001
From: felix <address@hidden>
Date: Tue, 12 Mar 2013 08:34:55 +0100
Subject: [PATCH] Declaring a procedure "inline" does not force inlining, as 
this may be lead to non-termination of the compiler. Declaring an identifier 
"inline" is now equivalent to declare it "local", which enables inlining for 
the given named procedures but does not force it. The decision as to inline or 
not is now done entirely by the compiler.

---
 NEWS          |    5 +++++
 compiler.scm  |    2 +-
 optimizer.scm |    1 -
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index c2d16fb..4e8e69c 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,11 @@
   - chicken-install now also accepts full URI syntax for proxy environment
     variables (thanks to Michele La Monaca)
 
+- Compiler
+  - the "inline" declaration does not force inlining anymore as recursive
+    inlining could lead to non-termination of the compiler (thanks to
+    Andrei Barbu).
+
 - Core libraries
   - read-line no longer returns trailing CRs in rare cases on TCP ports (#568)
   - write and pp now correctly use escape sequences for control characters
diff --git a/compiler.scm b/compiler.scm
index ba6bb5e..fdae883 100644
--- a/compiler.scm
+++ b/compiler.scm
@@ -1446,7 +1446,7 @@
        (if (null? (cdr spec))
            (set! inline-locally #t)
            (for-each
-            (cut mark-variable <> '##compiler#inline 'yes)
+            (cut mark-variable <> '##compiler#local)
             (globalize-all (cdr spec)))))
        ((inline-limit)
        (check-decl spec 1 1)
diff --git a/optimizer.scm b/optimizer.scm
index 791e644..c69b419 100644
--- a/optimizer.scm
+++ b/optimizer.scm
@@ -366,7 +366,6 @@
                                            (not (test ifid 'inline-target)) ; 
inlinable procedure has changed
                                            (not (test ifid 'explicit-rest))
                                            (case (variable-mark var 
'##compiler#inline) 
-                                             ((yes) #t)
                                              ((no) #f)
                                              (else 
                                               (or external (< (fourth lparams) 
inline-max-size)))))
-- 
1.7.2.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]