futures: fix `future' when given a non-JITted procedure
Merge to 5.1
This commit is contained in:
parent
7579b48791
commit
da6d4f3fba
|
@ -202,3 +202,15 @@ We should also test deep continuations.
|
||||||
(future (lambda ()
|
(future (lambda ()
|
||||||
(and (eq? (touch f) f)
|
(and (eq? (touch f) f)
|
||||||
(current-future)))))))
|
(current-future)))))))
|
||||||
|
|
||||||
|
;; Make sure that `future' doesn't mishandle functions
|
||||||
|
;; that aren't be JITted:
|
||||||
|
(check-equal?
|
||||||
|
(for/list ([i (in-range 10)]) (void))
|
||||||
|
(map
|
||||||
|
touch
|
||||||
|
(for/list ([i (in-range 10)])
|
||||||
|
(if (even? i)
|
||||||
|
(future void)
|
||||||
|
(future (parameterize ([eval-jit-enabled #f])
|
||||||
|
(eval #'(lambda () (void)))))))))
|
||||||
|
|
|
@ -642,8 +642,13 @@ Scheme_Object *scheme_future(int argc, Scheme_Object *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SAME_TYPE(SCHEME_TYPE(lambda), scheme_native_closure_type)) {
|
||||||
nc = (Scheme_Native_Closure*)lambda;
|
nc = (Scheme_Native_Closure*)lambda;
|
||||||
ncd = nc->code;
|
ncd = nc->code;
|
||||||
|
} else {
|
||||||
|
nc = NULL;
|
||||||
|
ncd = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the future descriptor and add to the queue as 'pending' */
|
/* Create the future descriptor and add to the queue as 'pending' */
|
||||||
ft = MALLOC_ONE_TAGGED(future_t);
|
ft = MALLOC_ONE_TAGGED(future_t);
|
||||||
|
@ -655,10 +660,9 @@ Scheme_Object *scheme_future(int argc, Scheme_Object *argv[])
|
||||||
ft->status = PENDING;
|
ft->status = PENDING;
|
||||||
|
|
||||||
/* JIT the code if not already JITted */
|
/* JIT the code if not already JITted */
|
||||||
|
if (ncd) {
|
||||||
if (ncd->code == scheme_on_demand_jit_code)
|
if (ncd->code == scheme_on_demand_jit_code)
|
||||||
{
|
|
||||||
scheme_on_demand_generate_lambda(nc, 0, NULL);
|
scheme_on_demand_generate_lambda(nc, 0, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
if (ncd->max_let_depth > FUTURE_RUNSTACK_SIZE * sizeof(void*)) {
|
if (ncd->max_let_depth > FUTURE_RUNSTACK_SIZE * sizeof(void*)) {
|
||||||
/* Can't even call it in a future thread */
|
/* Can't even call it in a future thread */
|
||||||
|
@ -666,6 +670,8 @@ Scheme_Object *scheme_future(int argc, Scheme_Object *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
ft->code = (void*)ncd->code;
|
ft->code = (void*)ncd->code;
|
||||||
|
} else
|
||||||
|
ft->status = PENDING_OVERSIZE;
|
||||||
|
|
||||||
if (ft->status != PENDING_OVERSIZE) {
|
if (ft->status != PENDING_OVERSIZE) {
|
||||||
mzrt_mutex_lock(fs->future_mutex);
|
mzrt_mutex_lock(fs->future_mutex);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user