|
116 | 116 | [else (super free-variables e)]
|
117 | 117 | ))
|
118 | 118 |
|
| 119 | + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 120 | + ;; expose-allocation |
| 121 | + |
| 122 | + (define/override (expose-allocation) |
| 123 | + (lambda (e) |
| 124 | + (verbose "expose-allocation" e) |
| 125 | + (match e |
| 126 | + [`(inject ,(app (expose-allocation) e) ,ty) |
| 127 | + `(inject ,e ,ty)] |
| 128 | + [`(project ,(app (expose-allocation) e) ,ty) |
| 129 | + `(project ,e ,ty)] |
| 130 | + [else |
| 131 | + ((super expose-allocation) e)] |
| 132 | + ))) |
| 133 | + |
119 | 134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
120 | 135 | ;; flatten
|
121 | 136 |
|
|
127 | 142 | (define-values (new-e e-ss xs) ((send this flatten #t) e))
|
128 | 143 | (cond [need-atomic
|
129 | 144 | (define tmp (gensym 'tmp))
|
130 |
| - (values `(has-type ,tmp ,ty2) |
131 |
| - (append e-ss `((assign ,tmp |
132 |
| - (has-type (inject ,new-e ,ty) |
133 |
| - ,ty2)))) |
| 145 | + (values tmp |
| 146 | + (append e-ss `((assign ,tmp (inject ,new-e ,ty)))) |
134 | 147 | (cons (cons tmp ty2) xs)
|
135 | 148 | )]
|
136 | 149 | [else
|
137 |
| - (values `(has-type (inject ,new-e ,ty) ,ty2) e-ss xs)])] |
| 150 | + (values `(inject ,new-e ,ty) e-ss xs)])] |
138 | 151 | [`(has-type (project ,e ,ty) ,ty2)
|
139 | 152 | (define-values (new-e e-ss xs) ((send this flatten #t) e))
|
140 | 153 | (cond [need-atomic
|
141 | 154 | (define tmp (gensym 'tmp))
|
142 |
| - (values `(has-type ,tmp ,ty2) |
143 |
| - (append e-ss `((assign ,tmp |
144 |
| - (has-type (project ,new-e ,ty) |
145 |
| - ,ty2)))) |
| 155 | + (values tmp |
| 156 | + (append e-ss `((assign ,tmp (project ,new-e ,ty)))) |
146 | 157 | (cons (cons tmp ty2) xs))]
|
147 | 158 | [else
|
148 |
| - (values `(has-type (project ,new-e ,ty) ,ty2) e-ss xs)])] |
| 159 | + (values `(project ,new-e ,ty) e-ss xs)])] |
149 | 160 | [else
|
150 | 161 | ((super flatten need-atomic) e)]
|
151 | 162 | )))
|
|
205 | 216 | [else
|
206 | 217 | `((movq ,new-e ,new-lhs)
|
207 | 218 | (orq (int ,(any-tag ty)) ,new-lhs))])]
|
208 |
| - ;; Old inefficient version of project. -Jeremy |
209 |
| - ;; [`(assign ,lhs (project ,e ,ty)) |
210 |
| - ;; (define new-lhs (recur lhs)) |
211 |
| - ;; (define new-e (recur e)) |
212 |
| - ;; `((movq ,new-e ,new-lhs) |
213 |
| - ;; (andq (int ,any-mask) ,new-lhs) |
214 |
| - ;; (if (eq? ,new-lhs (int ,(any-tag ty))) |
215 |
| - ;; ((andq (int ,pointer-mask) ,new-lhs) |
216 |
| - ;; (if (eq? ,new-lhs (int ,pointer-mask)) |
217 |
| - ;; ;; vectors and procedures. |
218 |
| - ;; ;; To do: check length of vector, arity of procedure. -Jeremy |
219 |
| - ;; ((movq (int ,any-mask) ,new-lhs) |
220 |
| - ;; (notq ,new-lhs) |
221 |
| - ;; (andq ,new-e ,new-lhs)) |
222 |
| - ;; ;; booleans and integers |
223 |
| - ;; ((movq ,new-e ,new-lhs) |
224 |
| - ;; (sarq (int ,tag-len) ,new-lhs)) |
225 |
| - ;; )) |
226 |
| - ;; ;; shouldn't we push the status code? -Jeremy |
227 |
| - ;; ((callq ,(string->symbol (label-name 'exit))))))] |
228 | 219 | [`(assign ,lhs (project ,e ,ty))
|
229 | 220 | (define new-lhs (recur lhs))
|
230 | 221 | (define new-e (recur e))
|
|
500 | 491 | ,(send interp interp-F '()))
|
501 | 492 | ("convert-to-closures" ,(send compiler convert-to-closures)
|
502 | 493 | ,(send interp interp-F '()))
|
503 |
| - ("flatten" ,(send compiler flatten #f) |
504 |
| - ,(send interp interp-C '())) |
505 | 494 | ("expose allocation"
|
506 | 495 | ,(send compiler expose-allocation)
|
| 496 | + ,(send interp interp-F '())) |
| 497 | + ("flatten" ,(send compiler flatten #f) |
507 | 498 | ,(send interp interp-C '()))
|
508 | 499 | ("instruction selection" ,(send compiler select-instructions)
|
509 | 500 | ,(send interp interp-x86 '()))
|
|
538 | 529 | ,(send interp interp-F '()))
|
539 | 530 | ("convert-to-closures" ,(send compiler convert-to-closures)
|
540 | 531 | ,(send interp interp-F '()))
|
541 |
| - ("flatten" ,(send compiler flatten #f) |
542 |
| - ,(send interp interp-C '())) |
543 | 532 | ("expose allocation"
|
544 | 533 | ,(send compiler expose-allocation)
|
| 534 | + ,(send interp interp-F '())) |
| 535 | + ("flatten" ,(send compiler flatten #f) |
545 | 536 | ,(send interp interp-C '()))
|
546 | 537 | ("instruction selection" ,(send compiler select-instructions)
|
547 | 538 | ,(send interp interp-x86 '()))
|
|
0 commit comments