bc: fix rationals as place messages
When an exact (non-integer) rational is reconstructed from a place message, normalization could involve bignum operations --- and those operations might use a cache, but the cache should not refer to the pages that are specific to a place message being constructed. Normalization isn't necessary, since the parts were already in a rational, so the repair is just it skip it. Relevant to #3456
This commit is contained in:
parent
3dc37ee035
commit
c2797c0e9d
23
pkgs/racket-test/tests/racket/place-msg-rational.rkt
Normal file
23
pkgs/racket-test/tests/racket/place-msg-rational.rkt
Normal file
|
@ -0,0 +1,23 @@
|
|||
#lang racket/base
|
||||
(require racket/place)
|
||||
|
||||
(define N 100)
|
||||
|
||||
(define (go)
|
||||
(place
|
||||
pch
|
||||
(for/fold ([v 0]) ([x (in-range N)])
|
||||
(place-channel-put pch (for/vector ([l 1000])
|
||||
(/ (- (expt 2 300) (random 10))
|
||||
(expt 2 81))))
|
||||
(apply + (vector->list (place-channel-get pch))))))
|
||||
|
||||
(module+ main
|
||||
(define p1 (go))
|
||||
(for ([i (in-range N)])
|
||||
(define v (place-channel-get p1))
|
||||
(place-channel-put p1 v))
|
||||
(place-wait p1))
|
||||
|
||||
(module+ test
|
||||
(require (submod ".." main)))
|
|
@ -146,7 +146,7 @@ void scheme_clear_bignum_cache(void)
|
|||
# define SCHEME_BIGDIG_SAFE(b, s) SCHEME_BIGDIG(b)
|
||||
|
||||
# define PROTECT(digarray, len) /* no-op */
|
||||
#define RELEASE(digarray) /* no-op */
|
||||
# define RELEASE(digarray) /* no-op */
|
||||
|
||||
# define PROTECT_RESULT(len) allocate_bigdig_array(len)
|
||||
# define FINISH_RESULT(digarray, len) /* no-op */
|
||||
|
|
|
@ -948,7 +948,7 @@ static Scheme_Object *shallow_types_copy(Scheme_Object *so, Scheme_Hash_Table *h
|
|||
mode, can_raise_exn, master_chain, invalid_object);
|
||||
d = shallow_types_copy(d, NULL, fd_accumulators, delayed_err, delayed_errno, delayed_errkind,
|
||||
mode, can_raise_exn, master_chain, invalid_object);
|
||||
new_so = scheme_make_rational(n, d);
|
||||
new_so = scheme_make_rational_pre_normalized(n, d);
|
||||
}
|
||||
break;
|
||||
case scheme_float_type:
|
||||
|
|
|
@ -26,6 +26,11 @@ Scheme_Object *scheme_make_rational(const Scheme_Object *n, const Scheme_Object
|
|||
scheme_bignum_normalize(d), 1);
|
||||
}
|
||||
|
||||
Scheme_Object *scheme_make_rational_pre_normalized(const Scheme_Object *n, const Scheme_Object *d)
|
||||
{
|
||||
return make_rational(n, d, 0);
|
||||
}
|
||||
|
||||
Scheme_Object *scheme_integer_to_rational(const Scheme_Object *n)
|
||||
{
|
||||
return make_rational(n, one, 0);
|
||||
|
|
|
@ -2264,6 +2264,7 @@ typedef Scheme_Rational Small_Rational;
|
|||
|
||||
XFORM_NONGCING Scheme_Object *scheme_make_small_rational(intptr_t n, Small_Rational *space);
|
||||
XFORM_NONGCING Scheme_Object *scheme_make_small_bn_rational(Scheme_Object *n, Small_Rational *space);
|
||||
Scheme_Object *scheme_make_rational_pre_normalized(const Scheme_Object *n, const Scheme_Object *d);
|
||||
Scheme_Object *scheme_integer_to_rational(const Scheme_Object *n);
|
||||
Scheme_Object *scheme_make_fixnum_rational(intptr_t n, intptr_t d);
|
||||
XFORM_NONGCING int scheme_rational_eq(const Scheme_Object *a, const Scheme_Object *b);
|
||||
|
|
Loading…
Reference in New Issue
Block a user