struct pool_head core_table;
#ifdef INDIRECT_CORE
+int *core_table_mem;
+
static uint8_t masks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
static uint8_t bits[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
uint8_t *core_block_bitmap;
int core_block_next;
int core_block_avail;
-
-int *core_table_mem;
#endif
-int *core_block_mem;
+uint8_t *core_block_mem;
static void core_move(struct pool_item *item, int new_base) {
int base = item->base;
core_table_mem[new_base + i] = core_table_mem[base + i];
core_table_mem[base + i] = 0x55555555;
#else
- core_block_mem[new_base + i] = core_block_mem[base + i];
- core_block_mem[base + i] = 0xaaaaaaaa;
+ memcpy(
+ core_block_mem + (new_base + i) * BLOCK_SIZE,
+ core_block_mem + (base + i) * BLOCK_SIZE,
+ BLOCK_SIZE
+ );
+ memset(
+ core_block_mem + (base + i) * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
#endif
}
}
core_table_mem[new_limit + i] = core_table_mem[limit + i];
core_table_mem[limit + i] = 0x55555555;
#else
- core_block_mem[new_limit + i] = core_block_mem[limit + i];
- core_block_mem[limit + i] = 0xaaaaaaaa;
+ memcpy(
+ core_block_mem + (new_limit + i) * BLOCK_SIZE,
+ core_block_mem + (limit + i) * BLOCK_SIZE,
+ BLOCK_SIZE
+ );
+ memset(
+ core_block_mem + (limit + i) * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
#endif
}
}
core_block_avail = n_core_blocks;
#endif
- core_block_mem = malloc(n_blocks * sizeof(int));
+ core_block_mem = malloc(n_blocks * BLOCK_SIZE);
rassert(core_block_mem);
- memset(core_block_mem, 0xaa, n_blocks * sizeof(int));
+ memset(core_block_mem, 0xaa, n_blocks * BLOCK_SIZE);
}
#ifdef INDIRECT_CORE
void core_hash_init(int process, int core_base, int base, int limit) {
for (int i = base; i < limit; ++i) {
- long long hash = process * 17 + i * 29;
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
#ifdef INDIRECT_CORE
int core_block = core_table_mem[core_base + i];
#else
int core_block = core_base + i;
#endif
- rassert(core_block_mem[core_block] == 0xaaaaaaaa);
- core_block_mem[core_block] = (int)hash;
+ for (int j = 0; j < BLOCK_SIZE; ++j) {
+ long long hash = process * 17 + i * 29 + j * 37;
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffLL) + (hash >> 16);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ rassert(core_block_mem[core_block * BLOCK_SIZE + j] == 0xaa);
+ core_block_mem[core_block * BLOCK_SIZE + j] = (uint8_t)hash;
+ }
}
}
void core_hash_verify(int process, int core_base, int base, int limit) {
for (int i = base; i < limit; ++i) {
- long long hash = process * 17 + i * 29;
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
#ifdef INDIRECT_CORE
int core_block = core_table_mem[core_base + i];
#else
int core_block = core_base + i;
#endif
- rassert(core_block_mem[core_block] == (int)hash);
- core_block_mem[core_block] = 0xaaaaaaaa;
+ for (int j = 0; j < BLOCK_SIZE; ++j) {
+ long long hash = process * 17 + i * 29 + j * 37;
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffLL) + (hash >> 16);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ rassert(core_block_mem[core_block * BLOCK_SIZE + j] == (uint8_t)hash);
+ }
+ memset(
+ core_block_mem + core_block * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
}
}
//#define INDIRECT_CORE 1
#define MOVEABLE_CORE 1
+#define BLOCK_SIZE 0x1000
#ifdef MOVEABLE_CORE
#define core_table_alloc(item, size) \
extern struct pool_head core_table;
#ifdef INDIRECT_CORE
+extern int *core_table_mem;
+
extern int n_core_blocks;
int n_core_block_bitmap;
extern uint8_t *core_block_bitmap;
extern int core_block_next;
extern int core_block_avail;
-
-extern int *core_table_mem;
#endif
-extern int *core_block_mem;
+extern uint8_t *core_block_mem;
#ifdef INDIRECT_CORE
void core_init(int n_table, int n_blocks);
void hash_init(int item, int item_base, int base, int limit) {
for (int i = base; i < limit; ++i) {
long long hash = item * 17 + i * 29;
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
rassert(mem[item_base + i] == 0xaaaaaaaa);
mem[item_base + i] = (int)hash;
}
void hash_verify(int item, int item_base, int base, int limit) {
for (int i = base; i < limit; ++i) {
long long hash = item * 17 + i * 29;
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
rassert(mem[item_base + i] == (int)hash);
mem[item_base + i] = 0xaaaaaaaa;
}
}
#endif
for (int i = 0; i < n_core_blocks; ++i)
- rassert(core_block_mem[i] == 0xaaaaaaaa);
+ for (int j = 0; j < BLOCK_SIZE; ++j)
+ rassert(core_block_mem[i * BLOCK_SIZE + j] == 0xaa);
#ifdef INDIRECT_SWAP
for (int i = 0; i < swap_table_size; ++i)
rassert(swap_table_mem[i] == 0x55555555);
}
#endif
for (int i = 0; i < n_swap_blocks; ++i)
- rassert(swap_block_mem[i] == 0xaaaaaaaa);
+ for (int j = 0; j < BLOCK_SIZE; ++j)
+ rassert(swap_block_mem[i * BLOCK_SIZE + j] == 0xaa);
return 0;
}
struct pool_head swap_table;
#ifdef INDIRECT_SWAP
+int *swap_table_mem;
+
static uint8_t masks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
static uint8_t bits[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
uint8_t *swap_block_bitmap;
int swap_block_next;
int swap_block_avail;
-
-int *swap_table_mem;
#endif
-int *swap_block_mem;
+uint8_t *swap_block_mem;
// swap address native wrt. pool and complemented wrt. backing store,
// means that swap_move() moves upward in backing store, do backward
swap_table_mem[new_limit + i] = swap_table_mem[limit + i];
swap_table_mem[limit + i] = 0x55555555;
#else
- swap_block_mem[new_limit + i] = swap_block_mem[limit + i];
- swap_block_mem[limit + i] = 0xaaaaaaaa;
+ memcpy(
+ swap_block_mem + (new_limit + i) * BLOCK_SIZE,
+ swap_block_mem + (limit + i) * BLOCK_SIZE,
+ BLOCK_SIZE
+ );
+ memset(
+ swap_block_mem + (limit + i) * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
#endif
}
}
swap_table_mem[new_base + i] = swap_table_mem[base + i];
swap_table_mem[base + i] = 0x55555555;
#else
- swap_block_mem[new_base + i] = swap_block_mem[base + i];
- swap_block_mem[base + i] = 0xaaaaaaaa;
+ memcpy(
+ swap_block_mem + (new_base + i) * BLOCK_SIZE,
+ swap_block_mem + (base + i) * BLOCK_SIZE,
+ BLOCK_SIZE
+ );
+ memset(
+ swap_block_mem + (base + i) * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
#endif
}
}
swap_block_avail = n_swap_blocks;
#endif
- swap_block_mem = malloc(n_blocks * sizeof(int));
+ swap_block_mem = malloc(n_blocks * BLOCK_SIZE);
rassert(swap_block_mem);
- memset(swap_block_mem, 0xaa, n_blocks * sizeof(int));
+ memset(swap_block_mem, 0xaa, n_blocks * BLOCK_SIZE);
}
#ifdef INDIRECT_SWAP
#else
int core_block = core_base + i;
#endif
- assert(core_block_mem[core_block] == 0xaaaaaaaa);
- core_block_mem[core_block] = swap_block_mem[swap_block];
- swap_block_mem[swap_block] = 0xaaaaaaaa;
+ for (int j = 0; j < BLOCK_SIZE; ++j)
+ assert(core_block_mem[core_block * BLOCK_SIZE + j] == 0xaa);
+ memcpy(
+ core_block_mem + core_block * BLOCK_SIZE,
+ swap_block_mem + swap_block * BLOCK_SIZE,
+ BLOCK_SIZE
+ );
+ memset(
+ swap_block_mem + swap_block * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
}
#ifdef INDIRECT_SWAP
printf("\n");
#else
int swap_block = swap_base + i;
#endif
- assert(swap_block_mem[swap_block] == 0xaaaaaaaa);
- swap_block_mem[swap_block] = core_block_mem[core_block];
- core_block_mem[core_block] = 0xaaaaaaaa;
+ for (int j = 0; j < BLOCK_SIZE; ++j)
+ assert(swap_block_mem[swap_block * BLOCK_SIZE + j] == 0xaa);
+ memcpy(
+ swap_block_mem + swap_block * BLOCK_SIZE,
+ core_block_mem + core_block * BLOCK_SIZE,
+ BLOCK_SIZE
+ );
+ memset(
+ core_block_mem + core_block * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
}
#ifdef INDIRECT_SWAP
printf("\n");
int offset
) {
for (int i = base; i < limit; ++i) {
- long long hash = process * 17 + (i + offset) * 29;
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
- hash = (hash & 0xffffffffffffffffLL) + (hash >> 32);
#ifdef INDIRECT_SWAP
int swap_block = swap_table_mem[swap_base + i];
#else
int swap_block = swap_base + i;
#endif
- rassert(swap_block_mem[swap_block] == (int)hash);
- swap_block_mem[swap_block] = 0xaaaaaaaa;
+ for (int j = 0; j < BLOCK_SIZE; ++j) {
+ long long hash = process * 17 + (i + offset) * 29 + j * 37;
+ hash = (hash & 0xffffffffLL) + (hash >> 32);
+ hash = (hash & 0xffffLL) + (hash >> 16);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ hash = (hash & 0xffLL) + (hash >> 8);
+ rassert(swap_block_mem[swap_block * BLOCK_SIZE + j] == (uint8_t)hash);
+ }
+ memset(
+ swap_block_mem + swap_block * BLOCK_SIZE,
+ 0xaa,
+ BLOCK_SIZE
+ );
}
}
extern struct pool_head swap_table;
#ifdef INDIRECT_SWAP
+extern int *swap_table_mem;
+
extern int n_swap_blocks;
int n_swap_block_bitmap;
extern uint8_t *swap_block_bitmap;
extern int swap_block_next;
extern int swap_block_avail;
-
-extern int *swap_table_mem;
#endif
-extern int *swap_block_mem;
+extern uint8_t *swap_block_mem;
#ifdef INDIRECT_SWAP
void swap_init(int n_table, int n_blocks);