| 1 | // Copyright (c) 2020-2024 Joe Conigliaro. All rights reserved. |
| 2 | // Use of this source code is governed by an MIT license |
| 3 | // that can be found in the LICENSE file. |
| 4 | module transformer |
| 5 | |
| 6 | import os |
| 7 | |
| 8 | // t_print_mem reports live malloc bytes at a transformer sub-phase boundary. |
| 9 | // Gated on V2_MEM. Under -gc none the value is monotonic on macOS, so deltas |
| 10 | // between stages are the exact bytes each sub-phase allocated. Defined for all |
| 11 | // platforms (transform_files calls it everywhere); the malloc-statistics probe |
| 12 | // is macOS-only, so other platforms just print the stage marker. |
| 13 | fn t_print_mem(stage string) { |
| 14 | if os.getenv('V2_MEM') == '' { |
| 15 | return |
| 16 | } |
| 17 | $if macos { |
| 18 | eprintln(' [mem] transform/${stage}: live ${darwin_transform_live_mb()} MB') |
| 19 | } $else { |
| 20 | eprintln(' [mem] transform/${stage}') |
| 21 | } |
| 22 | } |
| 23 | |