bc: fix unsafe-mode handling of bitwise-{and,ior,xor}
They were being converted to fixnum operations in unsafe mode, but the intent was to use fixnum operations only when the argument are known to be fixnums.
This commit is contained in:
parent
dfad17b7bb
commit
638f6f2b44
|
@ -1020,6 +1020,25 @@
|
|||
(test #t immutable? (unsafe-vector*->immutable-vector! (make-vector 0)))
|
||||
(test #f immutable? (make-vector 0))))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Make sure `bitwise-{and,ior,xor}` are not converted to
|
||||
;; unsafe fixnum operations in `#:unsafe` mode
|
||||
|
||||
(module unsafe-but-not-restricted-to-fixnum racket/base
|
||||
(#%declare #:unsafe)
|
||||
(provide band bior bxor)
|
||||
(define (band x)
|
||||
(bitwise-and #xFF x))
|
||||
(define (bior x)
|
||||
(bitwise-ior #xFF x))
|
||||
(define (bxor x)
|
||||
(bitwise-xor #xFF x)))
|
||||
|
||||
(require 'unsafe-but-not-restricted-to-fixnum)
|
||||
(test #x55 band (+ #x5555 (expt 2 100)))
|
||||
(test (+ (expt 2 100) #x55FF) bior (+ #x5555 (expt 2 100)))
|
||||
(test (+ (expt 2 100) #x55AA) bxor (+ #x5555 (expt 2 100)))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -5150,11 +5150,11 @@ static Scheme_Object *finish_optimize_application3(Scheme_App3_Rec *app, Optimiz
|
|||
|
||||
if (SCHEME_PRIM_PROC_OPT_FLAGS(rator) & SCHEME_PRIM_AD_HOC_OPT) {
|
||||
check_known_both_variant(info, app_o, rator, rand1, rand2, "bitwise-and", scheme_fixnum_p_proc,
|
||||
scheme_unsafe_fxand_proc, info->unsafe_mode, scheme_real_p_proc);
|
||||
scheme_unsafe_fxand_proc, 0, scheme_real_p_proc);
|
||||
check_known_both_variant(info, app_o, rator, rand1, rand2, "bitwise-ior", scheme_fixnum_p_proc,
|
||||
scheme_unsafe_fxior_proc, info->unsafe_mode, scheme_real_p_proc);
|
||||
scheme_unsafe_fxior_proc, 0, scheme_real_p_proc);
|
||||
check_known_both_variant(info, app_o, rator, rand1, rand2, "bitwise-xor", scheme_fixnum_p_proc,
|
||||
scheme_unsafe_fxxor_proc, info->unsafe_mode, scheme_real_p_proc);
|
||||
scheme_unsafe_fxxor_proc, 0, scheme_real_p_proc);
|
||||
|
||||
check_known_both_variant(info, app_o, rator, rand1, rand2, "fxand", scheme_fixnum_p_proc,
|
||||
scheme_unsafe_fxand_proc, info->unsafe_mode, scheme_real_p_proc);
|
||||
|
|
Loading…
Reference in New Issue
Block a user