Skip to content

Commit a99fdee

Browse files
committed
flambda-backend: Merge pull request ocaml#10195 from stedolan/mark-prefetching
Speed up GC by prefetching during marking (cherry picked from commit 1dc70d3)
1 parent bd72dcb commit a99fdee

File tree

4 files changed

+269
-90
lines changed

4 files changed

+269
-90
lines changed

runtime/caml/major_gc.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,28 @@
2121
#include "freelist.h"
2222
#include "misc.h"
2323

24+
/* An interval of a single object to be scanned.
25+
The end pointer must always be one-past-the-end of a heap block,
26+
but the start pointer is not necessarily the start of the block */
27+
typedef struct {
28+
value* start;
29+
value* end;
30+
} mark_entry;
31+
2432
typedef struct {
2533
void *block; /* address of the malloced block this chunk lives in */
2634
asize_t alloc; /* in bytes, used for compaction */
2735
asize_t size; /* in bytes */
2836
char *next;
29-
value* redarken_start; /* first block in chunk to redarken */
30-
value* redarken_end; /* last block in chunk that needs redarkening */
37+
mark_entry redarken_first; /* first block in chunk to redarken */
38+
value* redarken_end; /* one-past-end of last block for redarkening */
3139
} heap_chunk_head;
3240

33-
#define Chunk_size(c) (((heap_chunk_head *) (c)) [-1]).size
34-
#define Chunk_alloc(c) (((heap_chunk_head *) (c)) [-1]).alloc
35-
#define Chunk_next(c) (((heap_chunk_head *) (c)) [-1]).next
36-
#define Chunk_block(c) (((heap_chunk_head *) (c)) [-1]).block
37-
#define Chunk_redarken_start(c) (((heap_chunk_head *) (c)) [-1]).redarken_start
38-
#define Chunk_redarken_end(c) (((heap_chunk_head *) (c)) [-1]).redarken_end
41+
#define Chunk_head(c) (((heap_chunk_head *) (c)) - 1)
42+
#define Chunk_size(c) Chunk_head(c)->size
43+
#define Chunk_alloc(c) Chunk_head(c)->alloc
44+
#define Chunk_next(c) Chunk_head(c)->next
45+
#define Chunk_block(c) Chunk_head(c)->block
3946

4047
extern int caml_gc_phase;
4148
extern int caml_gc_subphase;

runtime/caml/misc.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ CAMLdeprecated_typedef(addr, char *);
7474
#define Noreturn
7575
#endif
7676

77+
/* Manually preventing inlining */
78+
#if defined(__GNUC__)
79+
#define Caml_noinline __attribute__ ((noinline))
80+
#elif defined(_MSC_VER)
81+
#define Caml_noinline __declspec(noinline)
82+
#else
83+
#define Caml_noinline
84+
#endif
85+
7786
/* Export control (to mark primitives and to handle Windows DLL) */
7887

7988
#ifndef CAMLDLLIMPORT

0 commit comments

Comments
 (0)