Chez Scheme: improve repair for arm32 return-address reference
Since the offset is always a multiple of 4, expand the range of compactly encoded offsets.
This commit is contained in:
parent
f5895ebc97
commit
3f0631116a
|
@ -1674,10 +1674,14 @@
|
|||
(bitwise-arithmetic-shift-left (logand n #xffffff) 8)
|
||||
(bitwise-arithmetic-shift-right n 24)))))))))
|
||||
|
||||
;; A region of funky12 where there's no number that fits when a smaller number doesn't
|
||||
(define connected-funky12
|
||||
;; restrict funky12 so that an code offset n will not fit
|
||||
;; if a smaller offset wouldn't fit, which prevents bouncing
|
||||
;; in the loop that computes label offsets
|
||||
(define code-offset-funky12
|
||||
(lambda (n)
|
||||
(and (fixnum? n) (#%$fxu< n #x100)
|
||||
(safe-assert (and (fixnum? n) (fx= 0 (fxand n 3))))
|
||||
(and (fixnum? n)
|
||||
(#%$fxu< n #x400)
|
||||
(funky12 n))))
|
||||
|
||||
(define shift-count?
|
||||
|
@ -2192,11 +2196,11 @@
|
|||
(let ([incr-offset (adjust-return-point-offset incr-offset l)])
|
||||
(let ([disp (fx- next-addr (fx- offset incr-offset) 4)])
|
||||
(cond
|
||||
[(connected-funky12 disp)
|
||||
[(code-offset-funky12 disp)
|
||||
(Trivit (dest)
|
||||
; aka adr, encoding A1
|
||||
(emit addi #f dest `(reg . ,%pc) disp '()))]
|
||||
[(connected-funky12 (- disp))
|
||||
[(code-offset-funky12 (- disp))
|
||||
(Trivit (dest)
|
||||
; aka adr, encoding A2
|
||||
(emit subi #f dest `(reg . ,%pc) (- disp) '()))]
|
||||
|
|
|
@ -15925,10 +15925,17 @@
|
|||
(dump (cdr trace-list) addr))))
|
||||
(car trace-list)))))
|
||||
(fprintf p "~d:~9t<end~@[ ~a~]>\n" size name))))
|
||||
; munge gets the code in forward order, but really wants to process it
|
||||
; backwards to find the label offsets. Maybe the size would be better
|
||||
; tracked by doing it more like cp2 does right now and then patching in
|
||||
; the foward jumps and tightening up the code.
|
||||
;; munge gets the code in forward order, but really wants to process it
|
||||
;; backwards to find the label offsets. Maybe the size would be better
|
||||
;; tracked by doing it more like cp2 does right now and then patching in
|
||||
;; the foward jumps and tightening up the code.
|
||||
;;
|
||||
;; If label addresses computed this time are not the same as last time,
|
||||
;; then `munge-recur?` is set, and some loop will try `munge` again.
|
||||
;; For that loop to converge, the instruction encoding for a larger label
|
||||
;; offset must not get smaller; otherwise, code might get further away,
|
||||
;; leading to some smaller encoding, which pulls code back closer, leading
|
||||
;; to a larger encoding, and so on.
|
||||
(define-who munge
|
||||
(lambda (c* size)
|
||||
(define (munge-pass c* iteration)
|
||||
|
|
Loading…
Reference in New Issue
Block a user