JIT: fix miscompilaton of char=?, char<?

When the first subexpression is complex and the second
is a literal character, the generated JIT code swaps the
argument order, but compilation didn't swap the test for
whether one or the other is a literal character to skip
a run-time test.
This commit is contained in:
Matthew Flatt 2018-06-20 13:43:19 -06:00
parent da41bdf43a
commit 598a5baf6a
2 changed files with 10 additions and 0 deletions

View File

@ -1055,6 +1055,13 @@
(test 9 dynamic-require ''assign-to-bytes-array-with-non-constant-offset 'out)
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Make sure `char=?` and similar don't get confused when trying to
;; reverse the argument order internally
(let ([f (lambda () (char=? (peek-char (open-input-string "")) #\x))])
(set! f f)
(err/rt-test (f)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(report-errs)

View File

@ -2697,6 +2697,9 @@ static int generate_binary_char(mz_jit_state *jitter, Scheme_App3_Rec *app, int
if (direction < 0) {
/* reverse sense of comparison */
GC_CAN_IGNORE Scheme_Object *tmp = r2;
r2 = r1;
r1 = tmp;
switch (cmp) {
case CMP_LEQ:
cmp = CMP_GEQ;