[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sbcl-commits
Subject:    [Sbcl-commits] master: Remove an unnecessary complication in cross-compiled defconstant-eqx
From:       Douglas Katzman via Sbcl-commits <sbcl-commits () lists ! sourceforge ! net>
Date:       2021-01-14 3:03:24
Message-ID: 1610593405.154839.19909 () sfp-scm-4 ! v30 ! lw ! sourceforge ! com
[Download RAW message or body]

The branch "master" has been updated in SBCL:
       via  c67888d1a0c8f7eeae64ac60a8a2aa8a248e76fa (commit)
      from  aa84e5c1715716f2eaee9f4bd5c6c708a33ff219 (commit)

- Log -----------------------------------------------------------------
commit c67888d1a0c8f7eeae64ac60a8a2aa8a248e76fa
Author: Douglas Katzman <dougk@google.com>
Date:   Wed Jan 13 21:33:15 2021 -0500

    Remove an unnecessary complication in cross-compiled defconstant-eqx
    
    Always treat the value form as producing a dumpable literal.
---
 src/code/primordial-extensions.lisp | 27 +++++++++++++--------------
 src/compiler/main.lisp              | 11 ++---------
 2 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/src/code/primordial-extensions.lisp b/src/code/primordial-extensions.lisp
index 63ac0299b..3ef76d272 100644
--- a/src/code/primordial-extensions.lisp
+++ b/src/code/primordial-extensions.lisp
@@ -322,20 +322,19 @@
 
 ;;; Special variant at cross-compile-time. Face it: the "croak-if-not-EQx" test
 ;;; is irrelevant - there can be no pre-existing value to test against.
-;;; The extra magic is that we need to discern between constants simple enough
-;;; to assigned during genesis (cold-load) from those assigned in cold-init.
-;;; This choice informs the compiler how to emit references to the symbol.
-(defvar sb-c::*!const-value-deferred* '())
+;;; The extra magic is that we force evaluation of the value form to occur
+;;; inside the macroexpander so that it can be dumped as a literal object,
+;;; which in turn allows a LOAD-TIME-VALUE form referencing the constant to work
+;;; in genesis because the target representation of the value will be available.
+;;; It would not be available if the form were computable only by target code.
 #-sb-xc-host
 (eval-when (:compile-toplevel)
   (sb-xc:defmacro defconstant-eqx (symbol expr eqx &optional doc)
-    (let ((constp (constantp expr)))
-      `(progn
-         (eval-when (:compile-toplevel)
-           (defconstant ,symbol (%defconstant-eqx-value ',symbol ,expr ,eqx))
-           ,@(unless constp
-               `((push ',symbol sb-c::*!const-value-deferred*))))
-         (eval-when (:load-toplevel)
-           (sb-c::%defconstant ',symbol
-             ,(if constp `',(constant-form-value expr) expr)
-             (sb-c:source-location) ,@(when doc (list doc))))))))
+    (unless (constantp expr)
+      (format t "~&Assuming constant value for ~s~%" symbol))
+    `(progn
+       (eval-when (:compile-toplevel)
+         (defconstant ,symbol (%defconstant-eqx-value ',symbol ,expr ,eqx)))
+       (eval-when (:load-toplevel)
+         (sb-c::%defconstant ',symbol `',(eval expr)
+           (sb-c:source-location) ,@(when doc (list doc)))))))
diff --git a/src/compiler/main.lisp b/src/compiler/main.lisp
index 5d729a5b9..f9e6dd5a6 100644
--- a/src/compiler/main.lisp
+++ b/src/compiler/main.lisp
@@ -1976,18 +1976,11 @@ returning its filename.
         (throw 'pending-init circular-ref)))
     ;; If this is a global constant reference, we can call SYMBOL-GLOBAL-VALUE
     ;; during LOAD as a fasl op, and not compile a lambda.
-    ;; However: the cross-compiler can not always emit fop-funcall for this,
-    ;; because the order of load-time actions is not strictly preserved as it
-    ;; would be for normal compilation. If the symbol's value needs computation,
-    ;; then it is unbound during genesis.
-    ;; So check if assignment was deferred, and if so, also defer the use.
-    (when (and namep #+sb-xc-host (not (member name *!const-value-deferred*)))
+    (when namep
       (fopcompile `(symbol-global-value ',name) nil t nil)
       (fasl-note-handle-for-constant constant (sb-fasl::dump-pop fasl) fasl)
       (return-from emit-make-load-form nil))
-    (multiple-value-bind (creation-form init-form)
-        (cond (namep (values `(symbol-global-value ',name) nil))
-              (t (%make-load-form constant)))
+    (multiple-value-bind (creation-form init-form) (%make-load-form constant)
       (cond
         ((eq init-form 'sb-fasl::fop-struct)
          (fasl-note-dumpable-instance constant fasl)

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL


_______________________________________________
Sbcl-commits mailing list
Sbcl-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic