cs: avoid abuse of vector-ref for struct-ref

Use `$object-ref`, instead. Otherwise, cptypes can detect the abuse of
`#3%vector-ref` and make unwanted transformations.
This commit is contained in:
Matthew Flatt 2019-04-06 10:07:46 +02:00
parent d8125082a2
commit 5a638073eb
5 changed files with 9 additions and 7 deletions

View File

@ -242,6 +242,7 @@ future2-demo: $(BUILDDIR)rumble.$(CSO)
RUMBLE_SRCS = rumble/define.ss \
rumble/virtual-register.ss \
rumble/layout.ss \
rumble/check.ss \
rumble/syntax-rule.ss \
rumble/letrec.ss \

View File

@ -706,6 +706,7 @@
(include "rumble/define.ss")
(include "rumble/virtual-register.ss")
(include "rumble/layout.ss")
(include "rumble/begin0.ss")
(include "rumble/letrec.ss")
(include "rumble/syntax-rule.ss")

View File

@ -128,11 +128,6 @@
;; ----------------------------------------
;; HACK: hardwired numbers that depend on the tagging regime
;; and other representation details
(define bytevector-content-offset 9)
(define vector-content-offset (if (> (fixnum-width) 32) 9 5))
(define (object->addr v) ; call with GC disabled
(#%$object-address v 0))

View File

@ -0,0 +1,5 @@
;; HACK: hardwired numbers that depend on the tagging regime
;; and other representation details
(define bytevector-content-offset 9)
(define vector-content-offset (if (> (fixnum-width) 32) 9 5))
(define record-content-offset vector-content-offset)

View File

@ -974,9 +974,9 @@
(putprop (record-type-uid rtd) 'guards new-guards))))))
(define (unsafe-struct*-ref s i)
(#3%vector-ref s i))
(#%$object-ref 'scheme-object s (fx+ record-content-offset (fx* i (foreign-sizeof 'void*)))))
(define (unsafe-struct*-set! s i v)
(#3%vector-set! s i v))
(#%$object-set! 'scheme-object s (fx+ record-content-offset (fx* i (foreign-sizeof 'void*))) v))
(define (unsafe-struct? v r)
(#3%record? v r))