Distinguish bytes-per-object from target-bytes-per-object.
authorTaylor R Campbell <campbell@mumble.net>
Wed, 12 Dec 2018 19:33:05 +0000 (19:33 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 12 Dec 2018 20:17:59 +0000 (20:17 +0000)
This is a kludge for now until we have a syntactic tower where we can
use distinct environments at each level of syntax expansion.

src/Makefile.in
src/configure.ac
src/runtime/boot.scm
src/runtime/bytevector.scm
src/runtime/host-adapter.scm
src/runtime/runtime.pkg
src/runtime/sysmac.scm

index cb5a0c278a16777f2bd2904de0702e2a96c68978..f7470c3822f1df7b3d6e65fa017b2171c8ef2330 100644 (file)
@@ -75,7 +75,9 @@ AUXDIR = @AUXDIR@
 @IF_CROSS@COMPILER_SETTINGS_CROSS = (set! compiler:cross-compiling? true)
 @IF_CROSS@SF_SETTINGS_CROSS = \
 @IF_CROSS@     (set! sf/cross-compiling? true) \
-@IF_CROSS@     (set! package/cross-compiling? true)
+@IF_CROSS@     (set! package/cross-compiling? true) \
+@IF_CROSS@     (set! target-bytes-per-object \
+@IF_CROSS@           (lambda () @mit_scheme_target_bytes_per_object@))
 @IF_LIARC@COMPILER_SETTINGS_LIARC = (set! compiler:invoke-c-compiler? false)
 HOST_COMPILER_HEAP = @HOST_COMPILER_HEAP@
 
@@ -85,7 +87,7 @@ HOST_COMPILER_SETTINGS = \
        $(COMPILER_SETTINGS_LIARC)
 
 HOST_COMPILER = '$(MIT_SCHEME_EXE)' --batch-mode $(HOST_COMPILER_HEAP) --no-init-file \
-  --eval '(begin $(HOST_COMPILER_SETTINGS))' --load runtime/host-adapter.scm
+  --load runtime/host-adapter.scm --eval '(begin $(HOST_COMPILER_SETTINGS))'
 
 HOST_RUNTIME_ONLY = '$(MIT_SCHEME_EXE)' --batch-mode $(HOST_COMPILER_HEAP) \
   --band runtime.com --no-init-file --load runtime/host-adapter.scm
index 5456b89bde6c1c5fc33b5110747811e05882b933..e625cde9f2dfabe8070dc7bddedfe98b651057d4 100644 (file)
@@ -139,6 +139,9 @@ AC_ARG_ENABLE([mcrypt],
 
 AC_CANONICAL_HOST
 
+AC_CHECK_SIZEOF([unsigned long])
+mit_scheme_target_bytes_per_object=$ac_cv_sizeof_unsigned_long
+
 ALL_TARGET=all-native
 INSTALL_COM='$(INSTALL_DATA)'
 INSTALL_LIARC_BUNDLES=
@@ -386,6 +389,7 @@ AC_SUBST([INSTALL_COM])
 AC_SUBST([INSTALL_LIARC_BUNDLES])
 AC_SUBST([MIT_SCHEME_EXE])
 AC_SUBST([mit_scheme_native_code])
+AC_SUBST([mit_scheme_target_bytes_per_object])
 AC_SUBST([OPTION_SUBDIRS])
 
 AC_PROG_INSTALL
index c73ab8d7320c6e60e6593bcdd586ccb46607f676..ff5a7a5efed43dd3c8b17854826be6a92924211c 100644 (file)
@@ -508,4 +508,12 @@ USA.
   ((ucode-primitive gc-space-status)))
 
 (define (bytes-per-object)
-  (vector-ref (gc-space-status) 0))
\ No newline at end of file
+  (vector-ref (gc-space-status) 0))
+
+;;; XXX Cross-compilation kludge: We redefine this to return the
+;;; characteristic of the target system.  In the future, macro
+;;; expanders should just see a binding of bytes-per-object that
+;;; reflects the target system.
+
+(define (target-bytes-per-object)
+  (bytes-per-object))
\ No newline at end of file
index a77216998add2b653b7449139f407176eec6606a..8743437c48ac77e236fb4744beb4c8b03020bc2a 100644 (file)
@@ -205,9 +205,16 @@ USA.
    (lambda (form rename compare)
      rename compare
      (syntax-check '(_ expression expression) form)
+     ;; XXX This queries the host system rather than the target system.
+     ;; We should expose definitions of fix:fixnum? to macro expanders
+     ;; that reflect the target system instead.
+     #;
      (if (fix:fixnum? #xFFFFFFFF)
         (cadr form)
-        (caddr form)))))
+        (caddr form))
+     ;; XXX For now, we can use the number of bytes per word as a proxy
+     ;; for whether fixnums have 32 bits.
+     `(select-on-bytes-per-word ,(caddr form) ,(cadr form)))))
 
 (select-u32-code
  ;; Can use fixnums:
index e7af3e2850174c138fcf8b5c24741328fcef517a..4a946115854cc7c9108c9678472c6f94561db209 100644 (file)
@@ -35,4 +35,9 @@ USA.
 ;;; the new runtime.  It contains temporary hacks that will be kept
 ;;; only until the new runtime is released.
 
+(if (lexical-unreferenceable? (->environment '()) 'target-bytes-per-object)
+    (environment-define (->environment '())
+                       'target-bytes-per-object
+                       bytes-per-object))
+
 unspecific
\ No newline at end of file
index efd7d106c663831df4d0a6139e637e6727eceb8f..f1e87b223045b406c741abc52f51d5df004c1230 100644 (file)
@@ -203,6 +203,7 @@ USA.
          set-predicate<=!
          simple-parser-method
          standard-print-method
+         target-bytes-per-object
          weak-car
          weak-cdr
          weak-cons
index 47900b49e07ce14ccf0cdef1a166851a7c6e9e6d..1f9f216d5595ae06055b72a47a9476006d02fbad 100644 (file)
@@ -112,7 +112,7 @@ USA.
    (lambda (form rename compare)
      (declare (ignore rename compare))
      (syntax-check '(_ expression expression) form)
-     (let ((bpo (bytes-per-object)))
+     (let ((bpo (target-bytes-per-object)))
        (case bpo
         ((4) (cadr form))
         ((8) (caddr form))