diff --git a/src/cmp/cmpffi.lsp b/src/cmp/cmpffi.lsp index be4c1fe2b9efd305efe09293715cfcb79c9ddf64..7dde8727595a5ec77cbb5f9c69a3cc9e5c1fbd29 100644 --- a/src/cmp/cmpffi.lsp +++ b/src/cmp/cmpffi.lsp @@ -99,12 +99,17 @@ (defun loc-movable-p (loc) (if (atom loc) - t - (case (first loc) - ((CALL CALL-LOCAL) NIL) - ((C-INLINE) (not (fifth loc))) ; side effects? - (otherwise t) - ))) + (if (var-p loc) + (case (var-kind loc) ((CLOSURE SPECIAL GLOBAL) nil) (otherwise t)) ;; for efficiency reason. + t) + (case (first loc) + ((CALL CALL-LOCAL CALL-NORMAL CALL-INDIRECT) NIL) ;; Is CALL-LOCAL still used? + ((FDEFINITION MAKE-CCLOSURE SI::STRUCTURE-REF) NIL) ;; for efficiency reason. + ((C-INLINE) NIL) ;; the safe choice, otherwise we need to prove it both side-effect free and context insensitive. + ((COERCE-LOC) (loc-movable-p (third loc))) + ((CAR CDR CADR) NIL) ;; not moveable in a multi-thread context. + (otherwise t) + ))) (defun loc-type (loc) (cond ((eq loc NIL) 'NULL) @@ -567,7 +572,7 @@ (unless block-opened (incf *inline-blocks*) (wt-nl "{")) - (wt (rep-type-name rep-type) " " lcl "= ") + (wt " const " (rep-type-name rep-type) " " lcl "= ") (wt-coerce-loc rep-type loc) (wt ";") (setq loc lcl))) diff --git a/src/cmp/cmpinline.lsp b/src/cmp/cmpinline.lsp index fce3ce4d45d4fe49dbb55ec4ea071ca3d2c08b3f..81bb99b8b9261691fc5144f8131f20c19082c8ec 100644 --- a/src/cmp/cmpinline.lsp +++ b/src/cmp/cmpinline.lsp @@ -86,7 +86,7 @@ (let* ((and-type (type-and return-type (loc-type loc))) (out-rep-type (loc-representation-type loc)) (var (make-lcl-var :rep-type out-rep-type :type and-type))) - (wt-nl "{" (rep-type-name out-rep-type) " " var "= " loc ";") + (wt-nl "{" " const " (rep-type-name out-rep-type) " " var "= " loc ";") (incf *inline-blocks*) (setq loc var) (push (list (loc-type loc) loc) locs))