[m-rev.] for review: Fix boxing/unboxing of 64-bit integers in pregen grades.

Peter Wang novalazy at gmail.com
Tue Mar 13 13:50:05 AEDT 2018


64-bit integers should be boxed in .pregen grades.
We forgot to define MR_BOXED_INT64S in .pregen grades so the wrong
definitions of the MR_(un)box_(u)int64 macros were being used
when compiling pregenerated C source files on 64-bit machines.
Fixes bug #454.

runtime/mercury_conf_param.h:
    Define MR_BOXED_INT64S in .pregen grades.

runtime/mercury_conf.h.in:
runtime/mercury_engine.h:
    Update some comments.
---
 runtime/mercury_conf.h.in    | 17 +++++++----------
 runtime/mercury_conf_param.h |  3 +++
 runtime/mercury_engine.h     |  3 +--
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/runtime/mercury_conf.h.in b/runtime/mercury_conf.h.in
index a6e894d3e..89e52cc4a 100644
--- a/runtime/mercury_conf.h.in
+++ b/runtime/mercury_conf.h.in
@@ -1,6 +1,7 @@
 // vim: ts=4 sw=4 expandtab
 
 // Copyright (C) 1995-2003, 2005-2012 The University of Melbourne.
+// Copyright (C) 2013-2018 The Mercury team.
 // This file may only be copied under the terms of the GNU Library General
 // Public License - see the file COPYING.LIB in the Mercury distribution.
 
@@ -91,21 +92,17 @@
 
 #undef  MR_LOW_TAG_BITS
 
-// MR_BOXED_FLOAT: defined if MR_Float is wider than a MR_Word,
-// i.e. when using double-precision floats on 32-bit architectures.
+// MR_BOXED_FLOAT: defined if MR_Float is wider than MR_Word
+// (i.e. when using double-precision floats on 32-bit architectures),
+// or in a .pregen grade where MR_Float MAY be wider than MR_Word.
 // It does NOT mean that all floats are necessarily boxed.
 // A better name might be MR_OVERSIZED_FLOAT.
-//
-// Note that when bootstrapping from the source distribution,
-// we initially build things without MR_BOXED_FLOAT even on machines
-// for which sizeof(MR_Float) <= sizeof(MR_Word).
-// Conversely if MR_BOXED_FLOAT is undefined, it implies that
-// sizeof(MR_Float) <= sizeof(MR_Word).
 
 #undef  MR_BOXED_FLOAT
 
-// MR_BOXED_INT64S: defined if int64_t and uint64_t is wider than a MR_Word,
-// i.e. on 32-bit architectures.
+// MR_BOXED_INT64S: defined if int64_t/uint64_t is wider than MR_Word
+// (i.e. on 32-bit architectures), or in a .pregen grade where
+// int64_t/uint64_t MAY be wider than MR_Word.
 
 #undef  MR_BOXED_INT64S
 
diff --git a/runtime/mercury_conf_param.h b/runtime/mercury_conf_param.h
index 2f6cc0b04..96106ed09 100644
--- a/runtime/mercury_conf_param.h
+++ b/runtime/mercury_conf_param.h
@@ -1,6 +1,7 @@
 // vim: ts=4 sw=4 expandtab ft=c
 
 // Copyright (C) 1997-2007, 2009-2011 The University of Melbourne.
+// Copyright (C) 2013-2018 The Mercury team.
 // This file may only be copied under the terms of the GNU Library General
 // Public License - see the file COPYING.LIB in the Mercury distribution.
 
@@ -141,6 +142,7 @@
 // MR_NATIVE_GC
 // MR_NO_TYPE_LAYOUT
 // MR_BOXED_FLOAT
+// MR_BOXED_INT64S
 // MR_USE_TRAIL
 // MR_USE_MINIMAL_MODEL_STACK_COPY
 // MR_USE_MINIMAL_MODEL_OWN_STACKS
@@ -629,6 +631,7 @@
   #undef  MR_LOW_TAG_BITS
   #define MR_LOW_TAG_BITS  2
   #define MR_BOXED_FLOAT   1
+  #define MR_BOXED_INT64S  1
 #endif
 
 // MR_PIC means that we are generating position independent code,
diff --git a/runtime/mercury_engine.h b/runtime/mercury_engine.h
index a2933525e..768a1f7d0 100644
--- a/runtime/mercury_engine.h
+++ b/runtime/mercury_engine.h
@@ -291,8 +291,7 @@ typedef struct {
 //
 // float_reg
 //              The float reg vector for this engine. This exists only if
-//              MR_BOXED_FLOAT is defined, i.e. when sizeof(MR_Float) >
-//              sizeof(MR_Word).
+//              MR_BOXED_FLOAT is defined.
 //
 // trail_ptr
 // ticket_counter
-- 
2.16.2



More information about the reviews mailing list