From b067063c94524dd1a851e1ec11003826a642f315 Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Sun, 17 Nov 2019 18:19:55 +0100 Subject: [PATCH] cmp: prevent inline information from getting lost while compiling ECL itself C inline information is saved in +default-machine+, which was previously a constant. However, the value assigned to +default-machine+ is recomputed during load and compile time. Technically, assigning a constant a new value which is not eql to the old one is undefined behaviour in the ANSI standard. What ECL did was simply to reassign the constant when compiling cmpc-machine.lsp. However, this meant that the inline information which was added to +default-machine+ when loading sysfun.lsp was lost. Thus, all ECL source files compiled after cmpc-machine.lsp were compiled without inline information. We prevent this by using an ordinary variable *default-machine* instead of a constant. --- contrib/cl-simd/ecl-sse-core.lisp | 4 ++-- src/cmp/cmpc-machine.lsp | 2 +- src/cmp/cmpct.lsp | 2 +- src/cmp/cmpglobals.lsp | 2 +- src/cmp/sysfun.lsp | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/contrib/cl-simd/ecl-sse-core.lisp b/contrib/cl-simd/ecl-sse-core.lisp index 49b091b0..58570282 100644 --- a/contrib/cl-simd/ecl-sse-core.lisp +++ b/contrib/cl-simd/ecl-sse-core.lisp @@ -107,9 +107,9 @@ `(eval-when (:compile-toplevel :load-toplevel) ;; FIXME: We should think of a way to achieve this without using ;; internal compiler functions - (let ((c::*inline-information* (c::machine-inline-information c::+default-machine+))) + (let ((c::*inline-information* (c::machine-inline-information c::*default-machine*))) (c::def-inline ',name ',mode ',arg-types ',ret-type ,call-str ,@flags) - (setf (c::machine-inline-information c::+default-machine+) + (setf (c::machine-inline-information c::*default-machine*) c::*inline-information*)))) (defmacro def-intrinsic (name arg-types ret-type c-name diff --git a/src/cmp/cmpc-machine.lsp b/src/cmp/cmpc-machine.lsp index 6fcc4e3c..83925c46 100644 --- a/src/cmp/cmpc-machine.lsp +++ b/src/cmp/cmpc-machine.lsp @@ -175,4 +175,4 @@ (defun machine-fixnump (number) (typep number (rep-type-lisp-type (gethash :fixnum number)))) -(defconstant +default-machine+ (setf *machine* (default-machine))) +(defvar *default-machine* (setf *machine* (default-machine))) diff --git a/src/cmp/cmpct.lsp b/src/cmp/cmpct.lsp index c0fc7ab4..b49a9750 100644 --- a/src/cmp/cmpct.lsp +++ b/src/cmp/cmpct.lsp @@ -129,7 +129,7 @@ #+threads (#.(find-package :mp) "cl_core.mp_package") ) - (when (eq machine +default-machine+) + (when (eq machine *default-machine*) ;; Constants which are not portable `((MOST-POSITIVE-SHORT-FLOAT "FLT_MAX") (MOST-POSITIVE-SINGLE-FLOAT "FLT_MAX") diff --git a/src/cmp/cmpglobals.lsp b/src/cmp/cmpglobals.lsp index b51a9ab1..5f0f9afe 100644 --- a/src/cmp/cmpglobals.lsp +++ b/src/cmp/cmpglobals.lsp @@ -331,7 +331,7 @@ be deleted if they have been opened with LoadLibrary.") (*inline-blocks* 0) (*open-c-braces* 0) (si::*defun-inline-hook* 'maybe-install-inline-function) - (*machine* (or *machine* +default-machine+)) + (*machine* (or *machine* *default-machine*)) (*optimizable-constants* (make-optimizable-constants *machine*)) (*inline-information* (let ((r (machine-inline-information *machine*))) diff --git a/src/cmp/sysfun.lsp b/src/cmp/sysfun.lsp index 3f9bf023..60bd46ef 100644 --- a/src/cmp/sysfun.lsp +++ b/src/cmp/sysfun.lsp @@ -926,8 +926,8 @@ name i inline-info)) (push inline-info (gethash (list name safety) *inline-information*)))) -(setf (machine-inline-information +default-machine+) - (make-inline-information +default-machine+)) +(setf (machine-inline-information *default-machine*) + (make-inline-information *default-machine*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;