repair JIT bug

The bug incorrectly tracks the value that is available in virtual
register R0 --- only in the case that some value was known to be ready
in R0, and some other value was known to be ready in R1, and a value
is moved from R1 to R0.

Closes PR 14523
This commit is contained in:
Matthew Flatt 2014-05-25 21:41:43 +01:00
parent 5c2c3c65ff
commit 0e9f468d3f
2 changed files with 54 additions and 1 deletions

View File

@ -3436,6 +3436,59 @@
x)
exn:fail:contract:variable?)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Try to check that JIT's register shortcuts
;; (tracking when a value is ready in a register)
;; works ok. The example here failed once upon
;; a time, at least.
;; Example by Dale Vaillancourt
(module check-jit-registers-shortcut racket/base
(require racket/fixnum racket/match)
(struct bral-empty () #:transparent)
(struct bral-node (weight tree rest) #:transparent)
(struct node (val even odd) #:transparent)
(struct var (name idx) #:transparent)
(define (half n) (fxrshift n 1))
(define (lookup-tree w i t)
(if (node? t)
(if (zero? i)
(node-val t)
(let [(w/2 (half w))]
(if (<= i w/2)
(lookup-tree w/2 (fx- i 1) (node-even t))
(lookup-tree w/2 (- (- i 1) w/2) (node-odd t)))))
(if (zero? i) t #f)))
(define (lookup i ls)
(match ls
[(bral-empty) #f]
[(bral-node weight tree ls*)
(if (< i weight)
(lookup-tree weight i tree)
(lookup (- i weight) ls*))]))
(define a-node
(bral-node
15
(node
'a
(node 'b (node 'c 'd 'e) (node 'f 'g 'h))
(node 'i (node 'j 'k 'l) (node 'm 'n 'o)))
(bral-empty)))
(define result (lookup 2 a-node))
(provide result))
(test 'c dynamic-require ''check-jit-registers-shortcut 'result)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -2035,7 +2035,7 @@ int scheme_generate(Scheme_Object *obj, mz_jit_state *jitter, int is_tail, int w
if (target != JIT_R1) {
jit_movr_p(target, JIT_R1);
if (target == JIT_R0)
jitter->r1_status = pos;
jitter->r0_status = pos;
mz_SET_REG_STATUS_VALID(1);
}
} else {