boehm-gc: revert all CACAO-specific modifications; this is now an exact copy of the...
[cacao.git] / src / mm / boehm-gc / include / private / gc_hdrs.h
index 70dfefe8fa7dc2725d2b14a409abe2fd7447a507..0e4c927dbda244b759232de49ae9ab562d237c33 100644 (file)
@@ -28,7 +28,7 @@ typedef struct hblkhdr hdr;
  * This defines HDR, GET_HDR, and SET_HDR, the main macros used to
  * retrieve and set object headers.
  *
- * Since 5.0 alpha 5, we can also take advantage of a header lookup
+ * We take advantage of a header lookup
  * cache.  This is a locally declared direct mapped cache, used inside
  * the marker.  The HC_GET_HDR macro uses and maintains this
  * cache.  Assuming we get reasonable hit rates, this shaves a few
@@ -54,28 +54,8 @@ typedef struct hblkhdr hdr;
 # define TOP_SZ (1 << LOG_TOP_SZ)
 # define BOTTOM_SZ (1 << LOG_BOTTOM_SZ)
 
-#ifndef SMALL_CONFIG
-# define USE_HDR_CACHE
-#endif
-
 /* #define COUNT_HDR_CACHE_HITS  */
 
-extern hdr * GC_invalid_header; /* header for an imaginary block       */
-                               /* containing no objects.               */
-
-
-/* Check whether p and corresponding hhdr point to long or invalid     */
-/* object.  If so, advance hhdr        to                                      */
-/* beginning of        block, or set hhdr to GC_invalid_header.                */
-#define ADVANCE(p, hhdr, source) \
-           { \
-             hdr * new_hdr = GC_invalid_header; \
-              p = GC_find_start(p, hhdr, &new_hdr); \
-             hhdr = new_hdr; \
-           }
-
-#ifdef USE_HDR_CACHE
-
 # ifdef COUNT_HDR_CACHE_HITS
     extern word GC_hdr_cache_hits;
     extern word GC_hdr_cache_misses;
@@ -96,7 +76,7 @@ extern hdr * GC_invalid_header; /* header for an imaginary block      */
 # define DECLARE_HDR_CACHE \
        hdr_cache_entry hdr_cache[HDR_CACHE_SIZE]
 
-# define INIT_HDR_CACHE BZERO(hdr_cache, sizeof(hdr_cache));
+# define INIT_HDR_CACHE BZERO(hdr_cache, sizeof(hdr_cache))
 
 # define HCE(h) hdr_cache + (((word)(h) >> LOG_HBLKSIZE) & (HDR_CACHE_SIZE-1))
 
@@ -105,44 +85,33 @@ extern hdr * GC_invalid_header; /* header for an imaginary block   */
 
 # define HCE_HDR(h) ((hce) -> hce_hdr)
 
+#ifdef PRINT_BLACK_LIST
+  hdr * GC_header_cache_miss(ptr_t p, hdr_cache_entry *hce, ptr_t source);
+# define HEADER_CACHE_MISS(p, hce, source) \
+         GC_header_cache_miss(p, hce, source)
+#else
+  hdr * GC_header_cache_miss(ptr_t p, hdr_cache_entry *hce);
+# define HEADER_CACHE_MISS(p, hce, source) GC_header_cache_miss(p, hce)
+#endif
 
-/* Analogous to GET_HDR, except that in the case of large objects, it  */
-/* Returns the header for the object beginning, and updates p.         */
-/* Returns GC_invalid_header instead of 0.  All of this saves a branch */
-/* in the fast path.                                                   */
-# define HC_GET_HDR(p, hhdr, source) \
+/* Set hhdr to the header for p.  Analogous to GET_HDR below,          */
+/* except that in the case of large objects, it                                */
+/* gets the header for the object beginning, if GC_all_interior_ptrs   */
+/* is set.                                                             */
+/* Returns zero if p points to somewhere other than the first page     */
+/* of an object, and it is not a valid pointer to the object.          */
+# define HC_GET_HDR(p, hhdr, source, exit_label) \
        { \
          hdr_cache_entry * hce = HCE(p); \
-         if (HCE_VALID_FOR(hce, p)) { \
+         if (EXPECT(HCE_VALID_FOR(hce, p), 1)) { \
            HC_HIT(); \
            hhdr = hce -> hce_hdr; \
          } else { \
-           HC_MISS(); \
-           GET_HDR(p, hhdr); \
-            if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { \
-             ADVANCE(p, hhdr, source); \
-           } else { \
-             hce -> block_addr = (word)(p) >> LOG_HBLKSIZE; \
-             hce -> hce_hdr = hhdr; \
-           } \
+           hhdr = HEADER_CACHE_MISS(p, hce, source); \
+           if (0 == hhdr) goto exit_label; \
          } \
        }
 
-#else /* !USE_HDR_CACHE */
-
-# define DECLARE_HDR_CACHE
-
-# define INIT_HDR_CACHE
-
-# define HC_GET_HDR(p, hhdr, source) \
-       { \
-         GET_HDR(p, hhdr); \
-          if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { \
-           ADVANCE(p, hhdr, source); \
-         } \
-       }
-#endif
-
 typedef struct bi {
     hdr * index[BOTTOM_SZ];
        /*
@@ -225,9 +194,9 @@ typedef struct bi {
                            
 /* Is the result a forwarding address to someplace closer to the       */
 /* beginning of the block or NIL?                                      */
-# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((unsigned long) (hhdr) <= MAX_JUMP)
+# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((size_t) (hhdr) <= MAX_JUMP)
 
 /* Get an HBLKSIZE aligned address closer to the beginning of the block */
 /* h.  Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr).            */
-# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (unsigned long)(hhdr))
+# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (size_t)(hhdr))
 # endif /*  GC_HEADERS_H */