Initial revision
This commit is contained in:
118
gc/include/private/cord_pos.h
Normal file
118
gc/include/private/cord_pos.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
*
|
||||
* Permission is hereby granted to use or copy this program
|
||||
* for any purpose, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, May 19, 1994 2:23 pm PDT */
|
||||
# ifndef CORD_POSITION_H
|
||||
|
||||
/* The representation of CORD_position. This is private to the */
|
||||
/* implementation, but the size is known to clients. Also */
|
||||
/* the implementation of some exported macros relies on it. */
|
||||
/* Don't use anything defined here and not in cord.h. */
|
||||
|
||||
# define MAX_DEPTH 48
|
||||
/* The maximum depth of a balanced cord + 1. */
|
||||
/* We don't let cords get deeper than MAX_DEPTH. */
|
||||
|
||||
struct CORD_pe {
|
||||
CORD pe_cord;
|
||||
size_t pe_start_pos;
|
||||
};
|
||||
|
||||
/* A structure describing an entry on the path from the root */
|
||||
/* to current position. */
|
||||
typedef struct CORD_Pos {
|
||||
size_t cur_pos;
|
||||
int path_len;
|
||||
# define CORD_POS_INVALID (0x55555555)
|
||||
/* path_len == INVALID <==> position invalid */
|
||||
const char *cur_leaf; /* Current leaf, if it is a string. */
|
||||
/* If the current leaf is a function, */
|
||||
/* then this may point to function_buf */
|
||||
/* containing the next few characters. */
|
||||
/* Always points to a valid string */
|
||||
/* containing the current character */
|
||||
/* unless cur_end is 0. */
|
||||
size_t cur_start; /* Start position of cur_leaf */
|
||||
size_t cur_end; /* Ending position of cur_leaf */
|
||||
/* 0 if cur_leaf is invalid. */
|
||||
struct CORD_pe path[MAX_DEPTH + 1];
|
||||
/* path[path_len] is the leaf corresponding to cur_pos */
|
||||
/* path[0].pe_cord is the cord we point to. */
|
||||
# define FUNCTION_BUF_SZ 8
|
||||
char function_buf[FUNCTION_BUF_SZ]; /* Space for next few chars */
|
||||
/* from function node. */
|
||||
} CORD_pos[1];
|
||||
|
||||
/* Extract the cord from a position: */
|
||||
CORD CORD_pos_to_cord(CORD_pos p);
|
||||
|
||||
/* Extract the current index from a position: */
|
||||
size_t CORD_pos_to_index(CORD_pos p);
|
||||
|
||||
/* Fetch the character located at the given position: */
|
||||
char CORD_pos_fetch(CORD_pos p);
|
||||
|
||||
/* Initialize the position to refer to the give cord and index. */
|
||||
/* Note that this is the most expensive function on positions: */
|
||||
void CORD_set_pos(CORD_pos p, CORD x, size_t i);
|
||||
|
||||
/* Advance the position to the next character. */
|
||||
/* P must be initialized and valid. */
|
||||
/* Invalidates p if past end: */
|
||||
void CORD_next(CORD_pos p);
|
||||
|
||||
/* Move the position to the preceding character. */
|
||||
/* P must be initialized and valid. */
|
||||
/* Invalidates p if past beginning: */
|
||||
void CORD_prev(CORD_pos p);
|
||||
|
||||
/* Is the position valid, i.e. inside the cord? */
|
||||
int CORD_pos_valid(CORD_pos p);
|
||||
|
||||
char CORD__pos_fetch(CORD_pos);
|
||||
void CORD__next(CORD_pos);
|
||||
void CORD__prev(CORD_pos);
|
||||
|
||||
#define CORD_pos_fetch(p) \
|
||||
(((p)[0].cur_end != 0)? \
|
||||
(p)[0].cur_leaf[(p)[0].cur_pos - (p)[0].cur_start] \
|
||||
: CORD__pos_fetch(p))
|
||||
|
||||
#define CORD_next(p) \
|
||||
(((p)[0].cur_pos + 1 < (p)[0].cur_end)? \
|
||||
(p)[0].cur_pos++ \
|
||||
: (CORD__next(p), 0))
|
||||
|
||||
#define CORD_prev(p) \
|
||||
(((p)[0].cur_end != 0 && (p)[0].cur_pos > (p)[0].cur_start)? \
|
||||
(p)[0].cur_pos-- \
|
||||
: (CORD__prev(p), 0))
|
||||
|
||||
#define CORD_pos_to_index(p) ((p)[0].cur_pos)
|
||||
|
||||
#define CORD_pos_to_cord(p) ((p)[0].path[0].pe_cord)
|
||||
|
||||
#define CORD_pos_valid(p) ((p)[0].path_len != CORD_POS_INVALID)
|
||||
|
||||
/* Some grubby stuff for performance-critical friends: */
|
||||
#define CORD_pos_chars_left(p) ((long)((p)[0].cur_end) - (long)((p)[0].cur_pos))
|
||||
/* Number of characters in cache. <= 0 ==> none */
|
||||
|
||||
#define CORD_pos_advance(p,n) ((p)[0].cur_pos += (n) - 1, CORD_next(p))
|
||||
/* Advance position by n characters */
|
||||
/* 0 < n < CORD_pos_chars_left(p) */
|
||||
|
||||
#define CORD_pos_cur_char_addr(p) \
|
||||
(p)[0].cur_leaf + ((p)[0].cur_pos - (p)[0].cur_start)
|
||||
/* address of current character in cache. */
|
||||
|
||||
#endif
|
135
gc/include/private/gc_hdrs.h
Normal file
135
gc/include/private/gc_hdrs.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
|
||||
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
|
||||
*
|
||||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
||||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||||
*
|
||||
* Permission is hereby granted to use or copy this program
|
||||
* for any purpose, provided the above notices are retained on all copies.
|
||||
* Permission to modify the code and to distribute modified code is granted,
|
||||
* provided the above notices are retained, and a notice that the code was
|
||||
* modified is included with the above copyright notice.
|
||||
*/
|
||||
/* Boehm, July 11, 1995 11:54 am PDT */
|
||||
# ifndef GC_HEADERS_H
|
||||
# define GC_HEADERS_H
|
||||
typedef struct hblkhdr hdr;
|
||||
|
||||
# if CPP_WORDSZ != 32 && CPP_WORDSZ < 36
|
||||
--> Get a real machine.
|
||||
# endif
|
||||
|
||||
/*
|
||||
* The 2 level tree data structure that is used to find block headers.
|
||||
* If there are more than 32 bits in a pointer, the top level is a hash
|
||||
* table.
|
||||
*/
|
||||
|
||||
# if CPP_WORDSZ > 32
|
||||
# define HASH_TL
|
||||
# endif
|
||||
|
||||
/* Define appropriate out-degrees for each of the two tree levels */
|
||||
# ifdef SMALL_CONFIG
|
||||
# define LOG_BOTTOM_SZ 11
|
||||
/* Keep top index size reasonable with smaller blocks. */
|
||||
# else
|
||||
# define LOG_BOTTOM_SZ 10
|
||||
# endif
|
||||
# ifndef HASH_TL
|
||||
# define LOG_TOP_SZ (WORDSZ - LOG_BOTTOM_SZ - LOG_HBLKSIZE)
|
||||
# else
|
||||
# define LOG_TOP_SZ 11
|
||||
# endif
|
||||
# define TOP_SZ (1 << LOG_TOP_SZ)
|
||||
# define BOTTOM_SZ (1 << LOG_BOTTOM_SZ)
|
||||
|
||||
typedef struct bi {
|
||||
hdr * index[BOTTOM_SZ];
|
||||
/*
|
||||
* The bottom level index contains one of three kinds of values:
|
||||
* 0 means we're not responsible for this block,
|
||||
* or this is a block other than the first one in a free block.
|
||||
* 1 < (long)X <= MAX_JUMP means the block starts at least
|
||||
* X * HBLKSIZE bytes before the current address.
|
||||
* A valid pointer points to a hdr structure. (The above can't be
|
||||
* valid pointers due to the GET_MEM return convention.)
|
||||
*/
|
||||
struct bi * asc_link; /* All indices are linked in */
|
||||
/* ascending order... */
|
||||
struct bi * desc_link; /* ... and in descending order. */
|
||||
word key; /* high order address bits. */
|
||||
# ifdef HASH_TL
|
||||
struct bi * hash_link; /* Hash chain link. */
|
||||
# endif
|
||||
} bottom_index;
|
||||
|
||||
/* extern bottom_index GC_all_nils; - really part of GC_arrays */
|
||||
|
||||
/* extern bottom_index * GC_top_index []; - really part of GC_arrays */
|
||||
/* Each entry points to a bottom_index. */
|
||||
/* On a 32 bit machine, it points to */
|
||||
/* the index for a set of high order */
|
||||
/* bits equal to the index. For longer */
|
||||
/* addresses, we hash the high order */
|
||||
/* bits to compute the index in */
|
||||
/* GC_top_index, and each entry points */
|
||||
/* to a hash chain. */
|
||||
/* The last entry in each chain is */
|
||||
/* GC_all_nils. */
|
||||
|
||||
|
||||
# define MAX_JUMP (HBLKSIZE - 1)
|
||||
|
||||
# define HDR_FROM_BI(bi, p) \
|
||||
((bi)->index[((word)(p) >> LOG_HBLKSIZE) & (BOTTOM_SZ - 1)])
|
||||
# ifndef HASH_TL
|
||||
# define BI(p) (GC_top_index \
|
||||
[(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE)])
|
||||
# define HDR_INNER(p) HDR_FROM_BI(BI(p),p)
|
||||
# ifdef SMALL_CONFIG
|
||||
# define HDR(p) GC_find_header((ptr_t)(p))
|
||||
# else
|
||||
# define HDR(p) HDR_INNER(p)
|
||||
# endif
|
||||
# define GET_BI(p, bottom_indx) (bottom_indx) = BI(p)
|
||||
# define GET_HDR(p, hhdr) (hhdr) = HDR(p)
|
||||
# define SET_HDR(p, hhdr) HDR_INNER(p) = (hhdr)
|
||||
# define GET_HDR_ADDR(p, ha) (ha) = &(HDR_INNER(p))
|
||||
# else /* hash */
|
||||
/* Hash function for tree top level */
|
||||
# define TL_HASH(hi) ((hi) & (TOP_SZ - 1))
|
||||
/* Set bottom_indx to point to the bottom index for address p */
|
||||
# define GET_BI(p, bottom_indx) \
|
||||
{ \
|
||||
register word hi = \
|
||||
(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \
|
||||
register bottom_index * _bi = GC_top_index[TL_HASH(hi)]; \
|
||||
\
|
||||
while (_bi -> key != hi && _bi != GC_all_nils) \
|
||||
_bi = _bi -> hash_link; \
|
||||
(bottom_indx) = _bi; \
|
||||
}
|
||||
# define GET_HDR_ADDR(p, ha) \
|
||||
{ \
|
||||
register bottom_index * bi; \
|
||||
\
|
||||
GET_BI(p, bi); \
|
||||
(ha) = &(HDR_FROM_BI(bi, p)); \
|
||||
}
|
||||
# define GET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \
|
||||
(hhdr) = *_ha; }
|
||||
# define SET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \
|
||||
*_ha = (hhdr); }
|
||||
# define HDR(p) GC_find_header((ptr_t)(p))
|
||||
# endif
|
||||
|
||||
/* 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)
|
||||
|
||||
/* 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))
|
||||
# endif /* GC_HEADERS_H */
|
1748
gc/include/private/gc_priv.h
Normal file
1748
gc/include/private/gc_priv.h
Normal file
File diff suppressed because it is too large
Load Diff
1099
gc/include/private/gcconfig.h
Normal file
1099
gc/include/private/gcconfig.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user