external_markbits.c
Go to the documentation of this file.
1 /*
2  * external_markbits.c: R.Hanai
3  */
4 
5 #include <stdio.h>
6 #include "external_markbits.h"
7 #include "rgc_utils.h"
8 
9 #define bit_table_error(str)
10 
11 unsigned int hmin, hmax;
12 static char *bit_table;
13 unsigned int mingcheap, maxgcheap;
14 
15 void set_heap_range(unsigned int min, unsigned int max)
16 {
17  if(mingcheap == 0 || min < mingcheap) mingcheap = min;
18  if(maxgcheap == 0 || max > maxgcheap) maxgcheap = max;
19 }
20 
22 {
23  int size;
24 
26 
27  size = (maxgcheap-mingcheap+3)>>2;
28  //size *= 2;
29  hmin = mingcheap;
30  hmax = mingcheap + (size<<2);
31  //DPRINT2("allocate bit table [%x, %x)", hmin, hmax);
32  bit_table = (char *)malloc(size);
33 
34  ASSERT(bit_table); // "failed to allocate an external bit table")
35 }
36 
37 __inline__ void set_bit(unsigned int addr)
38 {
39  ASSERT(hmin <= addr && addr < hmax);
40 // DPRINT3("set: over the heap [%x;%x), addr=%x", hmin, hmax, addr);
41 // DPRINT3("set: under the heap. [%x;%x], addr=%x", hmin, hmax, addr);
42 
43 // ASSERT(!(addr & 0x3));
44 // DPRINT3("set: addr not word aligned, addr=%x", addr);
45 
46  bit_table[(addr - hmin) >> 2] = 1;
47 }
48 
49 __inline__ char read_bit(unsigned int addr)
50 {
51  ASSERT(hmin <= addr && addr < hmax);
52 // DPRINT3("read: over the heap [%x;%x), addr=%x", hmin, hmax, addr);
53 // DPRINT3("read: under the heap [%x;%x), addr=%x", hmin, hmax, addr);
54  /* copyobj in leo.c:619 < leo.c:632 */
55 
56 // ASSERT(!(addr & 0x3));
57 // DPRINT3("set: addr not word aligned, addr=%x", addr);
58 
59  return bit_table[(addr - hmin) >> 2];
60 }
61 
62 /*
63  * copyobj in leo.c:619 < leo.c:632
64  * SORT in sequence.c 978
65  * */
66 
68 {
69  memset(&bit_table[0], 0, (hmax-hmin+3)>>2);
70 }
71 
73 {
74  int i, size, prod;
75  size = (hmax-hmin+3)>>2;
76  prod = 0;
77  DPRINT2("bit-table size=%d", size);
78  for(i = 0; i < size; i++){
79  if(!(i&0xff)){
80  fprintf(stderr, "%d", prod);
81  prod = 0;
82  }
83  prod |= bit_table[i];
84  if(!(i%(80*256))) fprintf(stderr, "\n");
85  }
86 }
DPRINT2
#define DPRINT2
Definition: rgc_utils.h:20
hmin
unsigned int hmin
Definition: external_markbits.c:11
min
#define min(x, y)
Definition: rmflags.c:17
allocate_bit_table
void allocate_bit_table()
Definition: external_markbits.c:21
mingcheap
unsigned int mingcheap
Definition: external_markbits.c:13
memset
memset(serverAddr, 0, sizeof(*serverAddr))
read_bit
__inline__ char read_bit(unsigned int addr)
Definition: external_markbits.c:49
rgc_utils.h
set_bit
__inline__ void set_bit(unsigned int addr)
Definition: external_markbits.c:37
hmax
unsigned int hmax
Definition: external_markbits.c:11
external_markbits.h
print_bit_table
void print_bit_table()
Definition: external_markbits.c:72
set_heap_range
void set_heap_range(unsigned int min, unsigned int max)
Definition: external_markbits.c:15
max
#define max(I1, I2)
Definition: eustags.c:134
clear_bit_table
void clear_bit_table()
Definition: external_markbits.c:67
ASSERT
#define ASSERT(condition)
Definition: rgc_utils.h:28
maxgcheap
unsigned int maxgcheap
Definition: external_markbits.c:13
bit_table
static char * bit_table
Definition: external_markbits.c:12


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 15 2023 02:06:43