Moved pagesize counters to NewGC struct
svn: r12260
This commit is contained in:
parent
3ac1cb8d56
commit
fa1335ea8c
|
@ -116,10 +116,6 @@ static void *park_save[2];
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* OS-Level Memory Management Routines */
|
/* OS-Level Memory Management Routines */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static unsigned long max_pages_in_heap = 0;
|
|
||||||
static unsigned long max_pages_for_use = 0;
|
|
||||||
static unsigned long used_pages = 0;
|
|
||||||
static unsigned long actual_pages_size = 0;
|
|
||||||
static unsigned long in_unsafe_allocation_mode = 0;
|
static unsigned long in_unsafe_allocation_mode = 0;
|
||||||
static void (*unsafe_allocation_abort)();
|
static void (*unsafe_allocation_abort)();
|
||||||
static void garbage_collect(int);
|
static void garbage_collect(int);
|
||||||
|
@ -134,17 +130,17 @@ static void out_of_memory()
|
||||||
|
|
||||||
inline static void check_used_against_max(size_t len)
|
inline static void check_used_against_max(size_t len)
|
||||||
{
|
{
|
||||||
used_pages += (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
GC->used_pages += (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
||||||
|
|
||||||
if(in_unsafe_allocation_mode) {
|
if(in_unsafe_allocation_mode) {
|
||||||
if(used_pages > max_pages_in_heap)
|
if(GC->used_pages > GC->max_pages_in_heap)
|
||||||
unsafe_allocation_abort();
|
unsafe_allocation_abort();
|
||||||
} else {
|
} else {
|
||||||
if(used_pages > max_pages_for_use) {
|
if(GC->used_pages > GC->max_pages_for_use) {
|
||||||
garbage_collect(0); /* hopefully this will free enough space */
|
garbage_collect(0); /* hopefully this will free enough space */
|
||||||
if(used_pages > max_pages_for_use) {
|
if(GC->used_pages > GC->max_pages_for_use) {
|
||||||
garbage_collect(1); /* hopefully *this* will free enough space */
|
garbage_collect(1); /* hopefully *this* will free enough space */
|
||||||
if(used_pages > max_pages_for_use) {
|
if(GC->used_pages > GC->max_pages_for_use) {
|
||||||
/* too much memory allocated.
|
/* too much memory allocated.
|
||||||
* Inform the thunk and then die semi-gracefully */
|
* Inform the thunk and then die semi-gracefully */
|
||||||
if(GC_out_of_memory)
|
if(GC_out_of_memory)
|
||||||
|
@ -158,14 +154,14 @@ inline static void check_used_against_max(size_t len)
|
||||||
|
|
||||||
inline static void free_used_pages(size_t len)
|
inline static void free_used_pages(size_t len)
|
||||||
{
|
{
|
||||||
used_pages -= (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
GC->used_pages -= (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_USED_AGAINST_MAX(len) check_used_against_max(len)
|
#define CHECK_USED_AGAINST_MAX(len) check_used_against_max(len)
|
||||||
#define LOGICALLY_ALLOCATING_PAGES(len) /* empty */
|
#define LOGICALLY_ALLOCATING_PAGES(len) /* empty */
|
||||||
#define ACTUALLY_ALLOCATING_PAGES(len) actual_pages_size += len
|
#define ACTUALLY_ALLOCATING_PAGES(len) GC->actual_pages_size += len
|
||||||
#define LOGICALLY_FREEING_PAGES(len) free_used_pages(len)
|
#define LOGICALLY_FREEING_PAGES(len) free_used_pages(len)
|
||||||
#define ACTUALLY_FREEING_PAGES(len) actual_pages_size -= len
|
#define ACTUALLY_FREEING_PAGES(len) GC->actual_pages_size -= len
|
||||||
|
|
||||||
#include "page_range.c"
|
#include "page_range.c"
|
||||||
|
|
||||||
|
@ -1462,12 +1458,12 @@ void GC_init_type_tags(int count, int pair, int mutable_pair, int weakbox, int e
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Our best guess at what the OS will let us allocate: */
|
/* Our best guess at what the OS will let us allocate: */
|
||||||
max_pages_in_heap = determine_max_heap_size() / APAGE_SIZE;
|
GC->max_pages_in_heap = determine_max_heap_size() / APAGE_SIZE;
|
||||||
/* Not all of that memory is available for allocating GCable
|
/* Not all of that memory is available for allocating GCable
|
||||||
objects. There's the memory used by the stack, code,
|
objects. There's the memory used by the stack, code,
|
||||||
malloc()/free()ed memory, etc., and there's also the
|
malloc()/free()ed memory, etc., and there's also the
|
||||||
administrative structures for the GC itself. */
|
administrative structures for the GC itself. */
|
||||||
max_pages_for_use = max_pages_in_heap / 2;
|
GC->max_pages_for_use = GC->max_pages_in_heap / 2;
|
||||||
|
|
||||||
resize_gen0(GEN0_INITIAL_SIZE);
|
resize_gen0(GEN0_INITIAL_SIZE);
|
||||||
|
|
||||||
|
@ -1916,8 +1912,8 @@ void GC_dump_with_traces(int flags,
|
||||||
GCWARN((GCOUTF,"Current memory use: %li\n", GC_get_memory_use(NULL)));
|
GCWARN((GCOUTF,"Current memory use: %li\n", GC_get_memory_use(NULL)));
|
||||||
GCWARN((GCOUTF,"Peak memory use after a collection: %li\n",peak_memory_use));
|
GCWARN((GCOUTF,"Peak memory use after a collection: %li\n",peak_memory_use));
|
||||||
GCWARN((GCOUTF,"Allocated (+reserved) page sizes: %li (+%li)\n",
|
GCWARN((GCOUTF,"Allocated (+reserved) page sizes: %li (+%li)\n",
|
||||||
used_pages * APAGE_SIZE,
|
GC->used_pages * APAGE_SIZE,
|
||||||
actual_pages_size - (used_pages * APAGE_SIZE)));
|
GC->actual_pages_size - (GC->used_pages * APAGE_SIZE)));
|
||||||
GCWARN((GCOUTF,"# of major collections: %li\n", num_major_collects));
|
GCWARN((GCOUTF,"# of major collections: %li\n", num_major_collects));
|
||||||
GCWARN((GCOUTF,"# of minor collections: %li\n", num_minor_collects));
|
GCWARN((GCOUTF,"# of minor collections: %li\n", num_minor_collects));
|
||||||
GCWARN((GCOUTF,"# of installed finalizers: %i\n", num_fnls));
|
GCWARN((GCOUTF,"# of installed finalizers: %i\n", num_fnls));
|
||||||
|
@ -2523,7 +2519,7 @@ static void garbage_collect(int force_full)
|
||||||
no_further_modifications = 0;
|
no_further_modifications = 0;
|
||||||
|
|
||||||
/* If we have too many idle pages, flush: */
|
/* If we have too many idle pages, flush: */
|
||||||
if (actual_pages_size > ((used_pages << (LOG_APAGE_SIZE + 1)))) {
|
if (GC->actual_pages_size > ((GC->used_pages << (LOG_APAGE_SIZE + 1)))) {
|
||||||
flush_freed_pages();
|
flush_freed_pages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -446,8 +446,8 @@ inline static void run_account_hooks()
|
||||||
|
|
||||||
while(work) {
|
while(work) {
|
||||||
if( ((work->type == MZACCT_REQUIRE) &&
|
if( ((work->type == MZACCT_REQUIRE) &&
|
||||||
((used_pages > (max_pages_for_use / 2))
|
((GC->used_pages > (GC->max_pages_for_use / 2))
|
||||||
|| ((((max_pages_for_use / 2) - used_pages) * APAGE_SIZE)
|
|| ((((GC->max_pages_for_use / 2) - GC->used_pages) * APAGE_SIZE)
|
||||||
< (work->amount + custodian_super_require(work->c1)))))
|
< (work->amount + custodian_super_require(work->c1)))))
|
||||||
||
|
||
|
||||||
((work->type == MZACCT_LIMIT) &&
|
((work->type == MZACCT_LIMIT) &&
|
||||||
|
|
Loading…
Reference in New Issue
Block a user