From 90465a5ce1a8595d5f000f0f3602951a64d3b6d7 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 12 Dec 2018 20:18:39 +0000 Subject: [PATCH] Skip constant-folding MD primitives when cross-compiling. --- src/compiler/base/utils.scm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/compiler/base/utils.scm b/src/compiler/base/utils.scm index 7239f9600..1fb10147f 100644 --- a/src/compiler/base/utils.scm +++ b/src/compiler/base/utils.scm @@ -469,6 +469,19 @@ USA. (ucode-primitive weak-car 1) (ucode-primitive weak-cdr 1))) +;; These primitives vary from machine to machine in the microcode. We +;; could emulate them based on the system characteristics, but for now +;; it will be easier to just avoid constant-folding them. +;; +;; XXX If we ever transition to a system where flonums are not IEEE 754 +;; binary64 floating-point, we'll have to list all the flonum +;; primitives here too. + +(define machine-dependent-primitives + (list (ucode-primitive primitive-object-ref 2) + (ucode-primitive system-vector-ref 2) + (ucode-primitive system-vector-size 1))) + ;;;; "Foldable" and side-effect-free operators (define boolean-valued-function-variables) @@ -521,8 +534,10 @@ USA. (define-integrable (boolean-valued-function-primitive? operator) (memq operator boolean-valued-function-primitives)) -(define-integrable (constant-foldable-primitive? operator) - (memq operator function-primitives)) +(define (constant-foldable-primitive? operator) + (and (memq operator function-primitives) + (or (not compiler:cross-compiling?)) + (not (memq operator machine-dependent-primitives)))) (define-integrable (side-effect-free-primitive? operator) (memq operator side-effect-free-primitives)) -- 2.25.1