File 0173-compile-Correctly-handle-time-for-modules-with-parse.patch of Package erlang
From 0f6e9749aebe0e3fca0cc4a7aa4a4489784339dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Sat, 28 Mar 2020 06:44:53 +0100
Subject: [PATCH 02/19] compile: Correctly handle `time` for modules with parse
transforms
---
lib/compiler/src/compile.erl | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 7dcfd5e423..8b69c5a252 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -455,11 +455,15 @@ run_sub_passes_1([{Name,Run}|Ps], Runner, St0)
run_sub_passes_1([], _, St) -> St.
run_tc({Name,Fun}, Code, St) ->
- put(?SUB_PASS_TIMES, []),
+ OldTimes = put(?SUB_PASS_TIMES, []),
T1 = erlang:monotonic_time(),
Val = (catch Fun(Code, St)),
T2 = erlang:monotonic_time(),
- Times = erase(?SUB_PASS_TIMES),
+ Times = get(?SUB_PASS_TIMES),
+ case OldTimes of
+ undefined -> erase(?SUB_PASS_TIMES);
+ _ -> put(?SUB_PASS_TIMES, OldTimes)
+ end,
Elapsed = erlang:convert_time_unit(T2 - T1, native, microsecond),
Mem0 = erts_debug:flat_size(Val)*erlang:system_info(wordsize),
Mem = lists:flatten(io_lib:format("~.1f kB", [Mem0/1024])),
--
2.16.4