fix problem with prompts, call/cc, and tail-buffer allocation

Merge to v5.3.1
(cherry picked from commit 8079ff6c4f)
This commit is contained in:
Matthew Flatt 2012-11-03 07:10:33 -06:00 committed by Ryan Culpepper
parent 9fb2a5b5ff
commit 67711f53da
3 changed files with 36 additions and 0 deletions

View File

@ -1280,6 +1280,21 @@ inline static uintptr_t allocate_slowpath(NewGC *gc, size_t allocate_size, uintp
return newptr;
}
static void check_allocation_time_invariants()
{
#if 0
Scheme_Thread *p = scheme_current_thread;
if (p) {
if (p->values_buffer) {
memset(p->values_buffer, 0, sizeof(Scheme_Object*) * p->values_buffer_size);
}
if (p->tail_buffer && (p->tail_buffer != p->runstack_tmp_keep)) {
memset(p->tail_buffer, 0, sizeof(Scheme_Object*) * p->tail_buffer_size);
}
}
#endif
}
inline static void *allocate(const size_t request_size, const int type)
{
size_t allocate_size;
@ -1287,6 +1302,8 @@ inline static void *allocate(const size_t request_size, const int type)
if(request_size == 0) return (void *) zero_sized;
check_allocation_time_invariants();
allocate_size = COMPUTE_ALLOC_SIZE_FOR_OBJECT_SIZE(request_size);
if(allocate_size > MAX_OBJECT_SIZE) return allocate_big(request_size, type);
@ -1338,6 +1355,8 @@ inline static void *fast_malloc_one_small_tagged(size_t request_size, int dirty)
uintptr_t newptr;
const size_t allocate_size = COMPUTE_ALLOC_SIZE_FOR_OBJECT_SIZE(request_size);
check_allocation_time_invariants();
newptr = GC_gen0_alloc_page_ptr + allocate_size;
if(OVERFLOWS_GEN0(newptr)) {
@ -1371,6 +1390,8 @@ void *GC_malloc_pair(void *car, void *cdr)
void *pair;
const size_t allocate_size = PAIR_SIZE_IN_BYTES;
check_allocation_time_invariants();
newptr = GC_gen0_alloc_page_ptr + allocate_size;
if(OVERFLOWS_GEN0(newptr)) {

View File

@ -1580,6 +1580,8 @@ Scheme_Object *scheme_jump_to_continuation(Scheme_Object *obj, int num_rands, Sc
else {
GC_CAN_IGNORE Scheme_Object *vals;
vals = scheme_values(num_rands, (Scheme_Object **)value);
if (SAME_OBJ(p->ku.multiple.array, p->values_buffer))
p->values_buffer = NULL;
c->value = vals;
}

View File

@ -6368,6 +6368,11 @@ static Scheme_Object *call_with_prompt (int in_argc, Scheme_Object *in_argv[])
p = scheme_current_thread;
if (v == SCHEME_MULTIPLE_VALUES) {
if (SAME_OBJ(p->ku.multiple.array, p->values_buffer))
p->values_buffer = NULL;
}
restore_from_prompt(prompt);
p->suspend_break = 0;
@ -6392,6 +6397,10 @@ static Scheme_Object *call_with_prompt (int in_argc, Scheme_Object *in_argv[])
if (v) {
/* Got a result: */
if (v == SCHEME_MULTIPLE_VALUES) {
if (SAME_OBJ(p->ku.multiple.array, p->values_buffer))
p->values_buffer = NULL;
}
prompt_unwind_one_dw(prompt_tag);
handler = NULL;
} else {
@ -6456,6 +6465,10 @@ static Scheme_Object *call_with_prompt (int in_argc, Scheme_Object *in_argv[])
if (SAME_OBJ(handler, scheme_values_func)) {
v = scheme_values(argc, argv);
if (v == SCHEME_MULTIPLE_VALUES) {
if (SAME_OBJ(p->ku.multiple.array, p->values_buffer))
p->values_buffer = NULL;
}
handler = NULL;
} else if (SCHEME_FALSEP(handler)) {
if (argc == 1) {