mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-18 18:40:22 +02:00
Always add a header onto objects
We're targetting systems that need to be able to inspect the kind of an object, so this information has to be somewhere. If it's out-of-line, we might save memory, but we would lose locality. Concretely in Guile the tag bits are in the object itself.
This commit is contained in:
parent
d8bcbf2d74
commit
cacc28b577
6 changed files with 14 additions and 20 deletions
2
bdw.h
2
bdw.h
|
@ -80,8 +80,6 @@ allocate_small(void **freelist, size_t idx, enum gc_inline_kind kind) {
|
|||
return head;
|
||||
}
|
||||
|
||||
#define GC_HEADER /**/
|
||||
|
||||
static inline void* allocate(struct mutator *mut, enum alloc_kind kind,
|
||||
size_t size) {
|
||||
size_t idx = gc_inline_bytes_to_freelist_index(size);
|
||||
|
|
4
gc-api.h
4
gc-api.h
|
@ -91,4 +91,8 @@ GC_API_ void gc_finish_for_thread(struct mutator *mut);
|
|||
GC_API_ void* gc_call_without_gc(struct mutator *mut, void* (*f)(void*),
|
||||
void *data) GC_NEVER_INLINE;
|
||||
|
||||
struct gc_header {
|
||||
uintptr_t tag;
|
||||
};
|
||||
|
||||
#endif // GC_API_H_
|
||||
|
|
14
mt-gcbench.c
14
mt-gcbench.c
|
@ -57,20 +57,20 @@ static const int min_tree_depth = 4;
|
|||
static const int max_tree_depth = 16;
|
||||
|
||||
struct Node {
|
||||
GC_HEADER;
|
||||
struct gc_header header;
|
||||
struct Node *left;
|
||||
struct Node *right;
|
||||
int i, j;
|
||||
};
|
||||
|
||||
struct DoubleArray {
|
||||
GC_HEADER;
|
||||
struct gc_header header;
|
||||
size_t length;
|
||||
double values[0];
|
||||
};
|
||||
|
||||
struct Hole {
|
||||
GC_HEADER;
|
||||
struct gc_header header;
|
||||
size_t length;
|
||||
uintptr_t values[0];
|
||||
};
|
||||
|
@ -373,13 +373,11 @@ static void *join_thread(void *data) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// Define size of Node without any GC header.
|
||||
size_t sizeof_node = 2 * sizeof(Node*) + 2 * sizeof(int);
|
||||
size_t sizeof_double_array = sizeof(size_t);
|
||||
size_t heap_max_live =
|
||||
tree_size(long_lived_tree_depth) * sizeof_node +
|
||||
tree_size(max_tree_depth) * sizeof_node +
|
||||
sizeof_double_array + sizeof(double) * array_size;
|
||||
tree_size(long_lived_tree_depth) * sizeof(Node) +
|
||||
tree_size(max_tree_depth) * sizeof(Node) +
|
||||
sizeof(DoubleArray) + sizeof(double) * array_size;
|
||||
if (argc != 4) {
|
||||
fprintf(stderr, "usage: %s MULTIPLIER NTHREADS PARALLELISM\n", argv[0]);
|
||||
return 1;
|
||||
|
|
6
quads.c
6
quads.c
|
@ -7,7 +7,7 @@
|
|||
#include "gc.h"
|
||||
|
||||
typedef struct Quad {
|
||||
GC_HEADER;
|
||||
struct gc_header header;
|
||||
struct Quad *kids[4];
|
||||
} Quad;
|
||||
static inline size_t quad_size(Quad *obj) {
|
||||
|
@ -125,10 +125,8 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
// Compute byte size not counting any header word, so as to compute the same
|
||||
// heap size whether a header word is there or not.
|
||||
size_t nquads = tree_size(depth);
|
||||
size_t tree_bytes = nquads * 4 * sizeof(Quad*);
|
||||
size_t tree_bytes = nquads * sizeof(Quad);
|
||||
size_t heap_size = tree_bytes * multiplier;
|
||||
|
||||
unsigned long gc_start = current_time();
|
||||
|
|
2
semi.h
2
semi.h
|
@ -48,8 +48,6 @@ static uintptr_t align_up(uintptr_t addr, size_t align) {
|
|||
return (addr + align - 1) & ~(align-1);
|
||||
}
|
||||
|
||||
#define GC_HEADER uintptr_t _gc_header
|
||||
|
||||
static inline void clear_memory(uintptr_t addr, size_t size) {
|
||||
memset((char*)addr, 0, size);
|
||||
}
|
||||
|
|
|
@ -392,8 +392,6 @@ static inline struct heap* mutator_heap(struct mutator *mutator) {
|
|||
return mutator->heap;
|
||||
}
|
||||
|
||||
#define GC_HEADER uintptr_t _gc_header
|
||||
|
||||
static inline void clear_memory(uintptr_t addr, size_t size) {
|
||||
memset((char*)addr, 0, size);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue