Skip to content

Commit 4d93c27

Browse files
committed
improve handling of local function bindings
Before they were pessimized a bit in a way that's no longer necessary after the function redesign. helps #15276
1 parent 6d5143c commit 4d93c27

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/julia-syntax.scm

+13-13
Original file line numberDiff line numberDiff line change
@@ -2379,11 +2379,10 @@
23792379
((=)
23802380
(let ((vi (var-info-for (cadr e) env)))
23812381
(if vi
2382-
(begin
2383-
(if (vinfo:asgn vi)
2384-
(vinfo:set-sa! vi #f)
2385-
(vinfo:set-sa! vi #t))
2386-
(vinfo:set-asgn! vi #t))))
2382+
(begin (if (vinfo:asgn vi)
2383+
(vinfo:set-sa! vi #f)
2384+
(vinfo:set-sa! vi #t))
2385+
(vinfo:set-asgn! vi #t))))
23872386
(analyze-vars (caddr e) env captvars sp))
23882387
((call)
23892388
(let ((vi (var-info-for (cadr e) env)))
@@ -2411,13 +2410,14 @@
24112410
(analyze-vars-lambda (cadr e) env captvars sp
24122411
(cddr e)))
24132412
((method)
2414-
(let ((vi (var-info-for (method-expr-name e) env)))
2415-
(if vi
2416-
(begin (vinfo:set-asgn! vi #t)
2417-
;; note: method defs require a memory loc. (issue #7658)
2418-
(vinfo:set-sa! vi #f))))
24192413
(if (length= e 2)
2420-
e
2414+
(let ((vi (var-info-for (method-expr-name e) env)))
2415+
(if vi
2416+
(begin (if (vinfo:asgn vi)
2417+
(vinfo:set-sa! vi #f)
2418+
(vinfo:set-sa! vi #t))
2419+
(vinfo:set-asgn! vi #t)))
2420+
e)
24212421
(begin (analyze-vars (caddr e) env captvars sp)
24222422
(assert (eq? (car (cadddr e)) 'lambda))
24232423
(analyze-vars-lambda (cadddr e) env captvars sp
@@ -2586,6 +2586,8 @@ f(x) = yt(x)
25862586
;; clear capture bit for vars assigned once at the top, to avoid allocating
25872587
;; some unnecessary Boxes.
25882588
(define (lambda-optimize-vars! lam)
2589+
;; flattening blocks helps us find more dominating statements
2590+
(set-car! (cdddr lam) (flatten-blocks (lam:body lam)))
25892591
(define (expr-uses-var ex v)
25902592
(cond ((assignment? ex) (expr-contains-eq v (caddr ex)))
25912593
((eq? (car ex) 'method)
@@ -2835,8 +2837,6 @@ f(x) = yt(x)
28352837
'(null)
28362838
(convert-assignment name mk-closure fname lam interp)))))))
28372839
((lambda) ;; should only happen inside (thunk ...)
2838-
;; flattening blocks helps lambda-optimize-vars! work
2839-
(set-car! (cdddr e) (flatten-blocks (lam:body e)))
28402840
`(lambda ,(cadr e)
28412841
(,(clear-capture-bits (car (lam:vinfo e)))
28422842
() ,@(cddr (lam:vinfo e)))

0 commit comments

Comments
 (0)