/
resources.h
161 lines (142 loc) · 5.28 KB
/
resources.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* resources.h
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
* $Id$
* Overview:
* Defines the resource allocation API
* Data Structure and Algorithms:
* History:
* Notes:
* References:
*/
#if !defined(PARROT_RESOURCES_H_GUARD)
#define PARROT_RESOURCES_H_GUARD
#include "parrot/parrot.h"
struct Memory_Block {
size_t free;
size_t size;
struct Memory_Block *prev;
struct Memory_Block *next;
char *start;
char *top;
};
struct Memory_Pool {
struct Memory_Block *top_block;
void (*compact)(Interp *, struct Memory_Pool *);
size_t minimum_block_size;
size_t total_allocated; /* total bytes allocated to this pool */
size_t guaranteed_reclaimable; /* bytes that can definitely be reclaimed*/
size_t possibly_reclaimable; /* bytes that can possibly be reclaimed
* (above plus COW-freed bytes) */
FLOATVAL reclaim_factor; /* minimum percentage we will reclaim */
};
void *Parrot_allocate(Interp *, void *, size_t size);
void *Parrot_allocate_zeroed(Interp *, void *, size_t size);
void *Parrot_allocate_string(Interp *, STRING *, size_t size);
void *Parrot_reallocate(Interp *interpreter,
void *from, size_t tosize);
void *Parrot_reallocate_string(Interp *interpreter,
STRING *, size_t tosize);
void Parrot_initialize_memory_pools(Interp *);
void Parrot_destroy_memory_pools(Interp *interpreter);
void Parrot_go_collect(Interp *);
struct Arenas {
struct Memory_Pool *memory_pool;
struct Memory_Pool *constant_string_pool;
struct Small_Object_Pool *string_header_pool;
struct Small_Object_Pool *pmc_pool;
struct Small_Object_Pool *pmc_ext_pool;
struct Small_Object_Pool *constant_pmc_pool;
struct Small_Object_Pool *buffer_header_pool;
struct Small_Object_Pool *constant_string_header_pool;
struct Small_Object_Pool **sized_header_pools;
size_t num_sized;
/*
* function slots that each subsystem must provide
*/
void (*do_dod_run)(Interp*, int flags);
void (*de_init_gc_system) (Interp*);
void (*init_pool)(Interp *, struct Small_Object_Pool *);
/*
* statistics for DOD and GC
*/
size_t dod_runs; /* Number of times we've done a DOD sweep */
size_t lazy_dod_runs; /* Number of successful lazy DOD sweep */
size_t collect_runs; /* Number of times we've
* done a memory compaction
*/
size_t mem_allocs_since_last_collect; /* The number of memory
* allocations from the
* system since the last
* compaction run */
size_t header_allocs_since_last_collect; /* The number of header
* blocks allocated from
* the system since the last
* DOD run */
size_t memory_allocated; /* The total amount of
* allocatable memory
* allocated. Doesn't count
* memory for headers or
* internal structures or
* anything */
UINTVAL memory_collected; /* Total amount of memory copied
during collection */
UINTVAL num_early_DOD_PMCs; /* how many PMCs want immediate destruction */
UINTVAL num_early_PMCs_seen;/* how many such PMCs has DOD seen */
UINTVAL num_extended_PMCs; /* active PMCs having pmc_ext */
PMC* dod_mark_start; /* first PMC marked during a DOD run */
PMC* dod_mark_ptr; /* last PMC marked during a DOD run */
PMC* dod_trace_ptr; /* last PMC trace_children was called on */
int lazy_dod; /* flag that indicates whether we should stop
when we've seen all impatient PMCs */
/*
* DOD, GC blocking
*/
UINTVAL DOD_block_level; /* How many outstanding DOD block
requests are there? */
UINTVAL GC_block_level; /* How many outstanding GC block
requests are there? */
/*
* private data for the GC subsystem
*/
void * gc_private; /* gc subsystem data */
};
struct Stash {
struct PMC *stash_hash;
struct Stash *parent_stash;
};
/* &gen_from_enum(interpinfo.pasm) prefix(INTERPINFO_) */
typedef enum {
TOTAL_MEM_ALLOC = 1,
DOD_RUNS,
COLLECT_RUNS,
ACTIVE_PMCS,
ACTIVE_BUFFERS,
TOTAL_PMCS,
TOTAL_BUFFERS,
HEADER_ALLOCS_SINCE_COLLECT,
MEM_ALLOCS_SINCE_COLLECT,
TOTAL_COPIED,
IMPATIENT_PMCS,
LAZY_DOD_RUNS,
EXTENDED_PMCS,
/* interpinfo_p constants */
CURRENT_SUB,
CURRENT_CONT,
CURRENT_OBJECT,
NAMESPACE_ROOT,
CURRENT_LEXPAD,
/* interpinfo_s constants */
CURRENT_METHOD
} Interpinfo_enum;
/* &end_gen */
#endif /* PARROT_RESOURCES_H_GUARD */
/*
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
*/