JIT: fix property predicate & selector handling

Commit 89512eda had accientally disabled the JIT's fast
path for structure-type property predicates and selectors.

Re-enable it, but but repair a problem with the way that
impersonator-property operations are handled by the same
code.
This commit is contained in:
Matthew Flatt 2017-12-22 17:40:13 -07:00
parent 5dec488ec4
commit 9092d31c29
3 changed files with 51 additions and 4 deletions

View File

@ -3310,6 +3310,29 @@
s-y (lambda (s v) (collect-garbage 'minor) v)
s-z (lambda (s v) (collect-garbage 'minor) v))))
;; ----------------------------------------
;; Make sure that a JIT-inlined predicate is sensitive to `prop:impersonator-of`
(let ()
(define-values (p:a a? a-ref) (make-impersonator-property 'a))
(struct posn (x y)
#:property prop:impersonator-of
(lambda (p) (posn-y p)))
(define p
(impersonate-struct (posn 1 #f) struct:posn
p:a 17))
(define (f p)
(a? p))
(set! f f)
(test #t f p)
(test #t f (posn 0 p))
(test #f f (posn 0 #f)))
;; ----------------------------------------
(report-errs)

View File

@ -1216,6 +1216,25 @@
(-set! v 3 'ok)
(test 'ok -ref v 3))
;; ----------------------------------------
;; Make sure that a JIT-inlined predicate doesn't
;; fail improperly on chaperones and struct types
(let ()
(define-values (prop:a a? a-ref) (make-struct-type-property 'a))
(struct posn (x y)
#:property prop:a 'yes)
(define (f p)
(and (a? p)
(a-ref p 'no)))
(set! f f)
(test 'yes f (posn 1 2))
(test 'yes f struct:posn)
(test #f f 5))
;; ----------------------------------------
(report-errs)

View File

@ -2164,8 +2164,6 @@ static int common4b(mz_jit_state *jitter, void *_data)
(void)jit_bnei_i(refslow, JIT_R2, prim_other_type);
CHECK_LIMIT();
(void)jit_jmpi(refslow);
/* Check argument: */
(void)jit_bmsi_ul(refno, JIT_R1, 0x1);
jit_ldxi_s(JIT_R2, JIT_R1, &((Scheme_Object *)0x0)->type);
@ -2208,9 +2206,16 @@ static int common4b(mz_jit_state *jitter, void *_data)
/* target struct-type property in V1 */
jit_ldxi_p(JIT_V1, JIT_R0, &((Scheme_Primitive_Closure *)0x0)->val);
ref3 = jit_beqr_p(jit_forward(), JIT_R2, JIT_V1);
/* If we're looking for an impersonator property, then we're
looking in the wrong place. But it's not ok to fail, because
we may need to go through a `prop:impersonator-of` mapping to
succeed. So, bail out for an impersonator-property operation,
since there was at least one property here. */
(void)mz_beqi_t(refslow, JIT_V1, scheme_chaperone_property_type, JIT_R2);
mz_get_local_p(JIT_V1, JIT_LOCAL3);
(void)jit_jmpi(refloop);