fix out-of-memory exception handling (PR 10489); misc compiler hushes
svn: r16206
This commit is contained in:
parent
954e850e20
commit
788ccc7f15
|
@ -206,7 +206,10 @@ static void *ofm_malloc_zero(size_t size) {
|
||||||
|
|
||||||
inline static void check_used_against_max(NewGC *gc, size_t len)
|
inline static void check_used_against_max(NewGC *gc, size_t len)
|
||||||
{
|
{
|
||||||
gc->used_pages += (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
long delta;
|
||||||
|
|
||||||
|
delta = (len / APAGE_SIZE) + (((len % APAGE_SIZE) == 0) ? 0 : 1);
|
||||||
|
gc->used_pages += delta;
|
||||||
|
|
||||||
if(gc->in_unsafe_allocation_mode) {
|
if(gc->in_unsafe_allocation_mode) {
|
||||||
if(gc->used_pages > gc->max_pages_in_heap)
|
if(gc->used_pages > gc->max_pages_in_heap)
|
||||||
|
@ -219,8 +222,10 @@ inline static void check_used_against_max(NewGC *gc, size_t len)
|
||||||
if(gc->used_pages > gc->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) {
|
||||||
|
gc->used_pages -= delta;
|
||||||
GC_out_of_memory();
|
GC_out_of_memory();
|
||||||
|
}
|
||||||
out_of_memory();
|
out_of_memory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,6 +542,7 @@ static void *allocate_big(const size_t request_size_bytes, int type)
|
||||||
NewGC *gc = GC_get_GC();
|
NewGC *gc = GC_get_GC();
|
||||||
mpage *bpage;
|
mpage *bpage;
|
||||||
size_t allocate_size;
|
size_t allocate_size;
|
||||||
|
void *addr;
|
||||||
|
|
||||||
#ifdef NEWGC_BTC_ACCOUNT
|
#ifdef NEWGC_BTC_ACCOUNT
|
||||||
if(GC_out_of_memory) {
|
if(GC_out_of_memory) {
|
||||||
|
@ -563,16 +569,20 @@ static void *allocate_big(const size_t request_size_bytes, int type)
|
||||||
if (!gc->dumping_avoid_collection)
|
if (!gc->dumping_avoid_collection)
|
||||||
garbage_collect(gc, 0);
|
garbage_collect(gc, 0);
|
||||||
}
|
}
|
||||||
gc->gen0.current_size += allocate_size;
|
|
||||||
|
|
||||||
/* We not only need APAGE_SIZE alignment, we
|
/* The following allocations may fail and escape if GC_out_of_memory is set.
|
||||||
|
We not only need APAGE_SIZE alignment, we
|
||||||
need everything consisently mapped within an APAGE_SIZE
|
need everything consisently mapped within an APAGE_SIZE
|
||||||
segment. So round up. */
|
segment. So round up. */
|
||||||
bpage = malloc_mpage();
|
|
||||||
if (type == PAGE_ATOMIC)
|
if (type == PAGE_ATOMIC)
|
||||||
bpage->addr = malloc_dirty_pages(gc, round_to_apage_size(allocate_size), APAGE_SIZE);
|
addr = malloc_dirty_pages(gc, round_to_apage_size(allocate_size), APAGE_SIZE);
|
||||||
else
|
else
|
||||||
bpage->addr = malloc_pages(gc, round_to_apage_size(allocate_size), APAGE_SIZE);
|
addr = malloc_pages(gc, round_to_apage_size(allocate_size), APAGE_SIZE);
|
||||||
|
|
||||||
|
gc->gen0.current_size += allocate_size;
|
||||||
|
|
||||||
|
bpage = malloc_mpage();
|
||||||
|
bpage->addr = addr;
|
||||||
bpage->size = allocate_size;
|
bpage->size = allocate_size;
|
||||||
bpage->size_class = 2;
|
bpage->size_class = 2;
|
||||||
bpage->page_type = type;
|
bpage->page_type = type;
|
||||||
|
|
|
@ -551,7 +551,7 @@ scheme_init_fun (Scheme_Env *env)
|
||||||
Scheme_Object *a[1];
|
Scheme_Object *a[1];
|
||||||
a[0] = scheme_intern_symbol("default");
|
a[0] = scheme_intern_symbol("default");
|
||||||
scheme_default_prompt_tag = make_prompt_tag(1, a);
|
scheme_default_prompt_tag = make_prompt_tag(1, a);
|
||||||
scheme_hash_key(SCHEME_PTR_VAL(scheme_default_prompt_tag));
|
(void)scheme_hash_key(SCHEME_PTR_VAL(scheme_default_prompt_tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_SO(original_default_prompt);
|
REGISTER_SO(original_default_prompt);
|
||||||
|
|
|
@ -338,7 +338,7 @@ void scheme_init_module(Scheme_Env *env)
|
||||||
scheme_make_pair(kernel_symbol,
|
scheme_make_pair(kernel_symbol,
|
||||||
scheme_null)),
|
scheme_null)),
|
||||||
scheme_false, kernel_modname);
|
scheme_false, kernel_modname);
|
||||||
scheme_hash_key(kernel_modidx);
|
(void)scheme_hash_key(kernel_modidx);
|
||||||
unsafe_modname = scheme_intern_resolved_module_path(scheme_intern_symbol("#%unsafe"));
|
unsafe_modname = scheme_intern_resolved_module_path(scheme_intern_symbol("#%unsafe"));
|
||||||
|
|
||||||
REGISTER_SO(module_symbol);
|
REGISTER_SO(module_symbol);
|
||||||
|
@ -5568,7 +5568,7 @@ static Scheme_Object *do_module(Scheme_Object *form, Scheme_Comp_Env *env,
|
||||||
REGISTER_SO(empty_self_modidx);
|
REGISTER_SO(empty_self_modidx);
|
||||||
REGISTER_SO(empty_self_modname);
|
REGISTER_SO(empty_self_modname);
|
||||||
empty_self_modidx = scheme_make_modidx(scheme_false, scheme_false, scheme_false);
|
empty_self_modidx = scheme_make_modidx(scheme_false, scheme_false, scheme_false);
|
||||||
scheme_hash_key(empty_self_modidx);
|
(void)scheme_hash_key(empty_self_modidx);
|
||||||
empty_self_modname = scheme_make_symbol("expanded module"); /* uninterned */
|
empty_self_modname = scheme_make_symbol("expanded module"); /* uninterned */
|
||||||
empty_self_modname = scheme_intern_resolved_module_path(empty_self_modname);
|
empty_self_modname = scheme_intern_resolved_module_path(empty_self_modname);
|
||||||
}
|
}
|
||||||
|
|
|
@ -907,6 +907,7 @@ void scheme_load_delayed_syntax(struct Resolve_Prefix *rp, long i);
|
||||||
XFORM_NONGCING Scheme_Object *scheme_phase_index_symbol(int src_phase_index);
|
XFORM_NONGCING Scheme_Object *scheme_phase_index_symbol(int src_phase_index);
|
||||||
|
|
||||||
Scheme_Object *scheme_explode_syntax(Scheme_Object *stx, Scheme_Hash_Table *ht);
|
Scheme_Object *scheme_explode_syntax(Scheme_Object *stx, Scheme_Hash_Table *ht);
|
||||||
|
void scheme_populate_pt_ht(struct Scheme_Module_Phase_Exports * pt);
|
||||||
|
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
/* syntax run-time structures */
|
/* syntax run-time structures */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user