* Added bytevector-ieee-double-native-ref/set!
This commit is contained in:
parent
7783cef318
commit
bcd96a8dd4
3271
benchmarks/timelog
3271
benchmarks/timelog
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -15,42 +15,45 @@
|
|||
|
||||
|
||||
(library (ikarus bytevectors)
|
||||
(export make-bytevector bytevector-length bytevector-s8-ref
|
||||
bytevector-u8-ref bytevector-u8-set! bytevector-s8-set!
|
||||
bytevector-copy! u8-list->bytevector bytevector->u8-list
|
||||
bytevector-u16-native-ref bytevector-u16-native-set!
|
||||
bytevector-u32-native-ref bytevector-u32-native-set!
|
||||
bytevector-s32-native-ref bytevector-s32-native-set!
|
||||
bytevector-u16-ref bytevector-u16-set!
|
||||
bytevector-u32-ref bytevector-u32-set!
|
||||
bytevector-s32-ref bytevector-s32-set!
|
||||
bytevector-s16-native-ref bytevector-s16-native-set!
|
||||
bytevector-s16-ref bytevector-s16-set!
|
||||
bytevector-fill! bytevector-copy bytevector=?
|
||||
bytevector-uint-ref bytevector-sint-ref
|
||||
bytevector-uint-set! bytevector-sint-set!
|
||||
bytevector->uint-list bytevector->sint-list
|
||||
uint-list->bytevector sint-list->bytevector
|
||||
native-endianness)
|
||||
(export
|
||||
make-bytevector bytevector-length bytevector-s8-ref
|
||||
bytevector-u8-ref bytevector-u8-set! bytevector-s8-set!
|
||||
bytevector-copy! u8-list->bytevector bytevector->u8-list
|
||||
bytevector-u16-native-ref bytevector-u16-native-set!
|
||||
bytevector-u32-native-ref bytevector-u32-native-set!
|
||||
bytevector-s32-native-ref bytevector-s32-native-set!
|
||||
bytevector-u16-ref bytevector-u16-set!
|
||||
bytevector-u32-ref bytevector-u32-set!
|
||||
bytevector-s32-ref bytevector-s32-set!
|
||||
bytevector-s16-native-ref bytevector-s16-native-set!
|
||||
bytevector-s16-ref bytevector-s16-set!
|
||||
bytevector-fill! bytevector-copy bytevector=?
|
||||
bytevector-uint-ref bytevector-sint-ref
|
||||
bytevector-uint-set! bytevector-sint-set!
|
||||
bytevector->uint-list bytevector->sint-list
|
||||
uint-list->bytevector sint-list->bytevector
|
||||
bytevector-ieee-double-native-ref bytevector-ieee-double-native-set!
|
||||
native-endianness)
|
||||
(import
|
||||
(except (ikarus)
|
||||
make-bytevector bytevector-length bytevector-s8-ref
|
||||
bytevector-u8-ref bytevector-u8-set! bytevector-s8-set!
|
||||
bytevector-copy! u8-list->bytevector bytevector->u8-list
|
||||
bytevector-u16-native-ref bytevector-u16-native-set!
|
||||
bytevector-u32-native-ref bytevector-u32-native-set!
|
||||
bytevector-s32-native-ref bytevector-s32-native-set!
|
||||
bytevector-u16-ref bytevector-u16-set!
|
||||
bytevector-u32-ref bytevector-u32-set!
|
||||
bytevector-s32-ref bytevector-s32-set!
|
||||
bytevector-s16-native-ref bytevector-s16-native-set!
|
||||
bytevector-s16-ref bytevector-s16-set!
|
||||
bytevector-fill! bytevector-copy bytevector=?
|
||||
bytevector-uint-ref bytevector-sint-ref
|
||||
bytevector-uint-set! bytevector-sint-set!
|
||||
bytevector->uint-list bytevector->sint-list
|
||||
uint-list->bytevector sint-list->bytevector
|
||||
native-endianness)
|
||||
make-bytevector bytevector-length bytevector-s8-ref
|
||||
bytevector-u8-ref bytevector-u8-set! bytevector-s8-set!
|
||||
bytevector-copy! u8-list->bytevector bytevector->u8-list
|
||||
bytevector-u16-native-ref bytevector-u16-native-set!
|
||||
bytevector-u32-native-ref bytevector-u32-native-set!
|
||||
bytevector-s32-native-ref bytevector-s32-native-set!
|
||||
bytevector-u16-ref bytevector-u16-set!
|
||||
bytevector-u32-ref bytevector-u32-set!
|
||||
bytevector-s32-ref bytevector-s32-set!
|
||||
bytevector-s16-native-ref bytevector-s16-native-set!
|
||||
bytevector-s16-ref bytevector-s16-set!
|
||||
bytevector-fill! bytevector-copy bytevector=?
|
||||
bytevector-uint-ref bytevector-sint-ref
|
||||
bytevector-uint-set! bytevector-sint-set!
|
||||
bytevector->uint-list bytevector->sint-list
|
||||
uint-list->bytevector sint-list->bytevector
|
||||
bytevector-ieee-double-native-ref bytevector-ieee-double-native-set!
|
||||
native-endianness)
|
||||
(ikarus system $fx)
|
||||
(ikarus system $bignums)
|
||||
(ikarus system $pairs)
|
||||
|
@ -969,6 +972,30 @@
|
|||
(make-xint-list->bytevector
|
||||
'sint-list->bytevector bytevector-sint-set!)))
|
||||
|
||||
(define (bytevector-ieee-double-native-ref bv i)
|
||||
(if (bytevector? bv)
|
||||
(if (and (fixnum? i)
|
||||
($fx>= i 0)
|
||||
($fxzero? ($fxlogand i 3))
|
||||
($fx< i ($bytevector-length bv)))
|
||||
($bytevector-ieee-double-native-ref bv i)
|
||||
(error 'bytevector-ieee-double-native-ref "invalid index" i))
|
||||
(error 'bytevector-ieee-double-native-ref "not a bytevector" bv)))
|
||||
|
||||
|
||||
(define (bytevector-ieee-double-native-set! bv i x)
|
||||
(if (bytevector? bv)
|
||||
(if (and (fixnum? i)
|
||||
($fx>= i 0)
|
||||
($fxzero? ($fxlogand i 3))
|
||||
($fx< i ($bytevector-length bv)))
|
||||
(if (flonum? x)
|
||||
($bytevector-ieee-double-native-set! bv i x)
|
||||
(error 'bytevector-ieee-double-native-ref "not a flonum" x))
|
||||
(error 'bytevector-ieee-double-native-ref "invalid index" i))
|
||||
(error 'bytevector-ieee-double-native-ref "not a bytevector" bv)))
|
||||
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -408,6 +408,8 @@
|
|||
[$bytevector-s8-ref $bytes]
|
||||
[$bytevector-u8-ref $bytes]
|
||||
[$bytevector-set! $bytes]
|
||||
[$bytevector-ieee-double-native-ref $bytes]
|
||||
[$bytevector-ieee-double-native-set! $bytes]
|
||||
[$flonum-u8-ref $flonums]
|
||||
[$make-flonum $flonums]
|
||||
[$flonum-set! $flonums]
|
||||
|
@ -860,8 +862,8 @@
|
|||
[bytevector-copy i r bv]
|
||||
[bytevector-copy! i r bv]
|
||||
[bytevector-fill! i r bv]
|
||||
[bytevector-ieee-double-native-ref r bv]
|
||||
[bytevector-ieee-double-native-set! r bv]
|
||||
[bytevector-ieee-double-native-ref i r bv]
|
||||
[bytevector-ieee-double-native-set! i r bv]
|
||||
[bytevector-ieee-double-ref r bv]
|
||||
[bytevector-ieee-single-native-ref r bv]
|
||||
[bytevector-ieee-single-native-set! r bv]
|
||||
|
|
|
@ -1364,6 +1364,25 @@
|
|||
(K (- disp-bytevector-data bytevector-tag)))
|
||||
(prm 'sll (T c) (K (- 8 fx-shift))))])])])
|
||||
|
||||
|
||||
(define-primop $bytevector-ieee-double-native-ref unsafe
|
||||
[(V bv i)
|
||||
(with-tmp ([x (prm 'alloc (K (align flonum-size)) (K vector-tag))])
|
||||
(prm 'mset x (K (- vector-tag)) (K flonum-tag))
|
||||
(prm 'fl:load
|
||||
(prm 'int+ (T bv) (prm 'sra (T i) (K fixnum-shift)))
|
||||
(K (- disp-bytevector-data bytevector-tag)))
|
||||
(prm 'fl:store x (K (- disp-flonum-data vector-tag)))
|
||||
x)])
|
||||
|
||||
(define-primop $bytevector-ieee-double-native-set! unsafe
|
||||
[(E bv i x)
|
||||
(seq*
|
||||
(prm 'fl:load (T x) (K (- disp-flonum-data vector-tag)))
|
||||
(prm 'fl:store
|
||||
(prm 'int+ (T bv) (prm 'sra (T i) (K fixnum-shift)))
|
||||
(K (- disp-bytevector-data bytevector-tag))))])
|
||||
|
||||
/section)
|
||||
|
||||
(section ;;; strings
|
||||
|
|
|
@ -277,6 +277,10 @@
|
|||
(bytevector-s32-set! v 0 -12345 'big)
|
||||
(bytevector-s32-ref v 0 'big))]
|
||||
|
||||
[(lambda (x) (= x 17.0))
|
||||
(let ([v (make-bytevector 8)])
|
||||
(bytevector-ieee-double-native-set! v 0 17.0)
|
||||
(bytevector-ieee-double-native-ref v 0))]
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -375,12 +375,14 @@
|
|||
[bytevector-copy C bv]
|
||||
[bytevector-copy! C bv]
|
||||
[bytevector-fill! C bv]
|
||||
[bytevector-ieee-double-native-ref S bv]
|
||||
[bytevector-ieee-double-native-set! S bv]
|
||||
[bytevector-ieee-double-native-ref C bv]
|
||||
[bytevector-ieee-double-native-set! C bv]
|
||||
[bytevector-ieee-double-ref S bv]
|
||||
[bytevector-ieee-double-set! S bv]
|
||||
[bytevector-ieee-single-native-ref S bv]
|
||||
[bytevector-ieee-single-native-set! S bv]
|
||||
[bytevector-ieee-single-ref S bv]
|
||||
[bytevector-ieee-single-set! S bv]
|
||||
[bytevector-length C bv]
|
||||
[bytevector-s16-native-ref C bv]
|
||||
[bytevector-s16-native-set! C bv]
|
||||
|
|
Loading…
Reference in New Issue