aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/cerl_trees.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-12-15 15:00:10 +0100
committerBjörn Gustavsson <[email protected]>2016-12-15 18:17:08 +0100
commitb1dd1f6d63e404d5348c30836332ccbb112533f1 (patch)
treea97d501a6a356b9ebcd778948c4e4bb9a2dcf8d3 /lib/compiler/src/cerl_trees.erl
parent6cc04a974724f0e115b2c8caa111418ecbd3db97 (diff)
downloadotp-b1dd1f6d63e404d5348c30836332ccbb112533f1.tar.gz
otp-b1dd1f6d63e404d5348c30836332ccbb112533f1.tar.bz2
otp-b1dd1f6d63e404d5348c30836332ccbb112533f1.zip
compile: Reduce memory consumption during compilation
The compiler would keep the data structures for two compiler passes in memory. That could increase the maximum amount of memory that the compiler uses, and could also have a negative impact on performance (terms that would not be used again would be copied by a garbage collection). Here is an example that shows how the previous version of the code could get captured: a_compiler_pass(Mod, St) -> case Mod:module(St#compile.code, St#compile.options) of {ok,Code} -> {ok,St#compile{code=Code}}; ... The reference to the code from the previous pass will only be released when St is updated. We can avoid the problem by passing the current version of the code as a function argument: a_compiler_pass(Mod, Code0, St) -> case Mod:module(Code0, St#compile.options) of {ok,Code} -> {ok,Code,St}; ... In practice, this change does not seem to significantly speed up the compiler, but it does not do any harm either. It should help dialyzer in situations when dialyzer compiles several large modules at the same time.
Diffstat (limited to 'lib/compiler/src/cerl_trees.erl')
0 files changed, 0 insertions, 0 deletions