[MLton-commit] r4062

Matthew Fluet MLton@mlton.org
Sun, 4 Sep 2005 04:44:18 -0700


#define-s for formatting and debugging
----------------------------------------------------------------------

U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h
U   mlton/branches/on-20050822-x86_64-branch/runtime/gc/util.h

----------------------------------------------------------------------

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-09-04 02:08:38 UTC (rev 4061)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/Makefile	2005-09-04 11:44:16 UTC (rev 4062)
@@ -24,7 +24,7 @@
 endif
 
 ifeq ($(TARGET_ARCH), amd64)
-FLAGS += -mtune=opteron -m32
+FLAGS += -mtune=opteron
 endif
 
 ifeq ($(TARGET_ARCH), sparc)

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c	2005-09-04 02:08:38 UTC (rev 4061)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.c	2005-09-04 11:44:16 UTC (rev 4062)
@@ -8,22 +8,35 @@
 static inline pointer objptrToPointer (objptr O, pointer B) {
   intptr_t O_ = (intptr_t)O;
   intptr_t B_;
+  pointer P;
+
   if GC_MODEL_B {
     B_ = (intptr_t)B;
   } else {
     B_ = 0;
   }
-  return (pointer)((O_ << GC_MODEL_S) + B_);
+
+  P = (pointer)((O_ << GC_MODEL_S) + B_);
+  if (DEBUG_DETAILED) 
+    fprintf (stderr, "objptrToPointer ("FMTOBJPTR") = "FMTPTR"\n", O, (intptr_t)P);
+  
+  return P;
 }
 
 static inline objptr pointerToObjptr (pointer P, pointer B) {
   intptr_t P_ = (intptr_t)P;
   intptr_t B_;
+  objptr O;
 
   if GC_MODEL_B {
     B_ = (intptr_t)B;
   } else {
     B_ = 0;
   }
-  return (objptr)((P_ - B_) >> GC_MODEL_S);
+
+  O = (objptr)((P_ - B_) >> GC_MODEL_S);
+  if (DEBUG_DETAILED) 
+    fprintf (stderr, "pointerToObjptr ("FMTPTR") = "FMTOBJPTR"\n", (intptr_t)P, O);
+
+  return O;
 }

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h	2005-09-04 02:08:38 UTC (rev 4061)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/model.h	2005-09-04 11:44:16 UTC (rev 4062)
@@ -14,8 +14,8 @@
 C. 32 bits, with bottom bit zero, shift left by two.
 D. 32 bits, shift left by two.
 E. 32 bits, shift left by three.
-F. 40 bits.
-G. 64 bits.
+F. 40 bits, with bottom two bits zero.
+G. 64 bits, with bottom two bits zero.
 
 These schemes vary in the number of bits to represent a pointer in an
 object, the time to load a pointer from memory into a register, the
@@ -51,9 +51,9 @@
 
                              =================================      E
 
-                         ========================================   F
+                         ======================================00   F
 
- ================================================================   G
+ ==============================================================00   G
 
 Algorithmically, we can compute the native pointer (P) from the object
 pointer (O) (with bitsize Z), given a shift (S) and a base (B):
@@ -126,7 +126,6 @@
 (G) costs the most in space, but has the fastest load time for
 pointers of the schemes that allow access to 4G of memory.
 
-
 A reasonable tradeoff in implementation complexity vs allowing our
 users enough flexibility might be to provide:
 
@@ -139,8 +138,13 @@
 #define GC_MODEL_Z  32
 #define GC_MODEL_S  1
 #define GC_MODEL_B  TRUE
+
 #define OBJPTR_TYPE__(z) uint ## z ## _t
 #define OBJPTR_TYPE_(z) OBJPTR_TYPE__(z)
 #define OBJPTR_TYPE OBJPTR_TYPE_(GC_MODEL_Z)
 typedef OBJPTR_TYPE objptr;
 #define OBJPTR_SIZE sizeof(objptr)
+#define PRIxOBJPTR__(z) PRIx ## z
+#define PRIxOBJPTR_(z) PRIxOBJPTR__(z)
+#define PRIxOBJPTR PRIxOBJPTR_(GC_MODEL_Z)
+#define FMTOBJPTR "0x%016"PRIxOBJPTR

Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gc/util.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gc/util.h	2005-09-04 02:08:38 UTC (rev 4061)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gc/util.h	2005-09-04 11:44:16 UTC (rev 4062)
@@ -49,6 +49,6 @@
                         __attribute__ ((noreturn));
 
 typedef void* pointer;
-#define FMTPTR "0x%08"PRIxPTR
+#define FMTPTR "0x%016"PRIxPTR
 
 #endif /* _UTIL_H_ */