fix JIT-inlined unsafe-flrandom

Relevant to racket/typed-racket#807
This commit is contained in:
Matthew Flatt 2019-02-28 09:24:28 -07:00
parent e970a6194a
commit d238007cf8
2 changed files with 26 additions and 0 deletions

View File

@ -934,6 +934,31 @@
(unsafe-fxlshift 1 63) (unsafe-fxlshift 1 63)
(unsafe-fxlshift 1 31))) (unsafe-fxlshift 1 31)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check that allocation by inlined `unsafe-flrandom` is ok
(test #t
symbol?
(let ([r (current-pseudo-random-generator)])
(for/fold ([v #f]) ([i (in-range 1000000)])
;; The pattern of `if`s here is intended to check the JIT's
;; runstack pointer is syned for allocation
(let* ([a (let ([v (unsafe-flrandom r)])
(if (negative? v)
(error "oops")
v))]
[b (let ([v (unsafe-flrandom r)])
(if (negative? v)
(error "oops")
v))]
[c (let ([v (unsafe-flrandom r)])
(if (negative? v)
(error "oops")
v))])
(if (and (eqv? a b) (eqv? b c))
'same
'diff)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs) (report-errs)

View File

@ -2151,6 +2151,7 @@ int scheme_generate_inlined_unary(mz_jit_state *jitter, Scheme_App2_Rec *app, in
scheme_mz_unbox_restore(jitter, &ubs); scheme_mz_unbox_restore(jitter, &ubs);
mz_runstack_unskipped(jitter, 1); mz_runstack_unskipped(jitter, 1);
mz_rs_sync();
mz_prepare(1); mz_prepare(1);
jit_pusharg_p(JIT_R0); jit_pusharg_p(JIT_R0);