cs: fix inlining of unsafe vector and box operations

Before this repair, `unsafe-vector-ref` was slower than `vector-ref`.
This commit is contained in:
Matthew Flatt 2019-10-12 13:29:01 -06:00
parent 61e39657fa
commit 77cdfde679
2 changed files with 35 additions and 7 deletions

View File

@ -635,9 +635,9 @@
ptr-ref/double ptr-set!/double ; not exported to Racket
ptr-ref/float ptr-set!/float ; not exported to Racket
unsafe-unbox
(rename [inline:unsafe-unbox unsafe-unbox]
[inline:unsafe-set-box! unsafe-set-box!])
unsafe-unbox*
unsafe-set-box!
unsafe-set-box*!
unsafe-box*-cas!
@ -646,12 +646,12 @@
unsafe-set-mcar!
unsafe-set-mcdr!
unsafe-vector-ref
unsafe-vector-set!
(rename [inline:unsafe-vector-ref unsafe-vector-ref]
[inline:unsafe-vector-set! unsafe-vector-set!]
[inline:unsafe-vector-length unsafe-vector-length])
unsafe-vector*-ref
unsafe-vector*-set!
unsafe-vector*-cas!
unsafe-vector-length
unsafe-vector*-length
unsafe-fxvector-length
@ -670,8 +670,8 @@
unsafe-string-ref
unsafe-string-set!
unsafe-struct-ref
unsafe-struct-set!
(rename [inline:unsafe-struct-ref unsafe-struct-ref]
[inline:unsafe-struct-set! unsafe-struct-set!])
unsafe-struct*-ref
unsafe-struct*-set!
unsafe-struct*-cas!

View File

@ -32,6 +32,18 @@
(#%$vector-set!-check? v i)
(#3%vector-set! v i n))
(define-inline (unsafe-vector-length v)
(#%vector? v)
(#3%vector-length v))
(define-inline (unsafe-vector-ref v i)
(#%vector? v)
(#3%vector-ref v i))
(define-inline (unsafe-vector-set! v i n)
(#%vector? v)
(#3%vector-set! v i n))
(define-inline (unbox b)
(#%box? b)
(#3%unbox b))
@ -40,6 +52,14 @@
(#%mutable-box? b)
(#3%set-box! b v))
(define-inline (unsafe-unbox b)
(#%box? b)
(#3%unbox b))
(define-inline (unsafe-set-box! b v)
(#%box? b)
(#3%set-box! b v))
(define-inline (mcar p)
(mpair? p)
(unsafe-mcar p))
@ -55,3 +75,11 @@
(define-inline (set-mcdr! p v)
(mpair? p)
(unsafe-set-mcdr! p v))
(define-inline (unsafe-struct-ref s i)
(not (impersonator? s))
(unsafe-struct*-ref s i))
(define-inline (unsafe-struct-set! s i v)
(not (impersonator? s))
(unsafe-struct*-set! s i v))